Skip to content

Commit 714ac44

Browse files
authored
feat(markers): add tooltip (#2595)
* feat: tooltip * fix: semi
1 parent 585311a commit 714ac44

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/plugin/markers/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @example wavesurfer.addMarker(regionParams);
55
* @property {number} time The time to set the marker at
66
* @property {?label} string An optional marker label
7+
* @property {?tooltip} string An optional marker tooltip
78
* @property {?color} string Background color for marker
89
* @property {?position} string "top" or "bottom", defaults to "bottom"
910
* @property {?markerElement} element An HTML element to display instead of the default marker image
@@ -159,6 +160,7 @@ export default class MarkersPlugin {
159160
let marker = {
160161
time: params.time,
161162
label: params.label,
163+
tooltip: params.tooltip,
162164
color: params.color || DEFAULT_FILL_COLOR,
163165
position: params.position || DEFAULT_POSITION,
164166
draggable: !!params.draggable,
@@ -231,6 +233,7 @@ export default class MarkersPlugin {
231233

232234
_createMarkerElement(marker, markerElement) {
233235
let label = marker.label;
236+
let tooltip = marker.tooltip;
234237

235238
const el = document.createElement('marker');
236239
el.className = "wavesurfer-marker";
@@ -265,6 +268,7 @@ export default class MarkersPlugin {
265268
if ( label ) {
266269
const labelEl = document.createElement('span');
267270
labelEl.innerText = label;
271+
labelEl.setAttribute('title', tooltip);
268272
this.style(labelEl, {
269273
"font-family": "monospace",
270274
"font-size": "90%"

0 commit comments

Comments
 (0)