wavesurfer.js 5.0.1 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGES.md +11 -1
  2. package/dist/plugin/wavesurfer.cursor.js +1 -1
  3. package/dist/plugin/wavesurfer.cursor.min.js +1 -1
  4. package/dist/plugin/wavesurfer.elan.js +1 -1
  5. package/dist/plugin/wavesurfer.elan.min.js +1 -1
  6. package/dist/plugin/wavesurfer.markers.js +16 -6
  7. package/dist/plugin/wavesurfer.markers.js.map +1 -1
  8. package/dist/plugin/wavesurfer.markers.min.js +2 -2
  9. package/dist/plugin/wavesurfer.markers.min.js.map +1 -1
  10. package/dist/plugin/wavesurfer.mediasession.js +1 -1
  11. package/dist/plugin/wavesurfer.mediasession.min.js +1 -1
  12. package/dist/plugin/wavesurfer.microphone.js +1 -1
  13. package/dist/plugin/wavesurfer.microphone.min.js +1 -1
  14. package/dist/plugin/wavesurfer.minimap.js +1 -1
  15. package/dist/plugin/wavesurfer.minimap.min.js +1 -1
  16. package/dist/plugin/wavesurfer.playhead.js +1 -1
  17. package/dist/plugin/wavesurfer.playhead.min.js +1 -1
  18. package/dist/plugin/wavesurfer.regions.js +5 -3
  19. package/dist/plugin/wavesurfer.regions.js.map +1 -1
  20. package/dist/plugin/wavesurfer.regions.min.js +2 -2
  21. package/dist/plugin/wavesurfer.regions.min.js.map +1 -1
  22. package/dist/plugin/wavesurfer.spectrogram.js +66 -60
  23. package/dist/plugin/wavesurfer.spectrogram.js.map +1 -1
  24. package/dist/plugin/wavesurfer.spectrogram.min.js +2 -2
  25. package/dist/plugin/wavesurfer.spectrogram.min.js.map +1 -1
  26. package/dist/plugin/wavesurfer.timeline.js +17 -5
  27. package/dist/plugin/wavesurfer.timeline.js.map +1 -1
  28. package/dist/plugin/wavesurfer.timeline.min.js +2 -2
  29. package/dist/plugin/wavesurfer.timeline.min.js.map +1 -1
  30. package/dist/wavesurfer-html-init.js +1 -1
  31. package/dist/wavesurfer-html-init.min.js +1 -1
  32. package/dist/wavesurfer.js +2 -2
  33. package/dist/wavesurfer.min.js +2 -2
  34. package/package.json +15 -15
  35. package/src/plugin/markers/index.js +13 -5
  36. package/src/plugin/regions/region.js +2 -2
  37. package/src/plugin/spectrogram/index.js +65 -61
  38. package/src/plugin/timeline/index.js +20 -11
package/CHANGES.md CHANGED
@@ -1,9 +1,19 @@
1
1
  wavesurfer.js changelog
2
2
  =======================
3
3
 
4
- 5.0.1 (05.05.2021)
4
+ 5.1.0 (20.06.2021)
5
5
  ------------------
6
+ - Markers plugin:
7
+ - Add the ability to use custom HTML elements in place of the default marker icon by
8
+ passing the new `markerElement` parameter to the marker constructor (#2269)
9
+ - Custom HTML elements are now centered over the marker line (#2298)
10
+ - Trigger `marker-click` event on wavesurfer (#2287)
11
+ - Regions plugin: handle rollover cursor bug fix (#2293)
12
+ - Timeline plugin: prevent calling `Canvas` context methods on `null` values (#2299)
13
+ - Spectrogram plugin: prevent calling `Canvas` context methods on `null` values (#2299)
6
14
 
15
+ 5.0.1 (05.05.2021)
16
+ ------------------
7
17
  - Fix removing DOM element on `destroy()` (#2258)
8
18
 
9
19
  5.0.0 (02.05.2021)
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js cursor plugin 5.0.1 (2021-05-05)
2
+ * wavesurfer.js cursor plugin 5.1.0 (2021-06-20)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js cursor plugin 5.0.1 (2021-05-05)
2
+ * wavesurfer.js cursor plugin 5.1.0 (2021-06-20)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js elan plugin 5.0.1 (2021-05-05)
2
+ * wavesurfer.js elan plugin 5.1.0 (2021-06-20)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js elan plugin 5.0.1 (2021-05-05)
2
+ * wavesurfer.js elan plugin 5.1.0 (2021-06-20)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js markers plugin 5.0.1 (2021-05-05)
2
+ * wavesurfer.js markers plugin 5.1.0 (2021-06-20)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -41,9 +41,10 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
41
41
  * @desc The parameters used to describe a marker.
42
42
  * @example wavesurfer.addMarker(regionParams);
43
43
  * @property {number} time The time to set the marker at
44
- * @property {?label} string an optional marker label
45
- * @property {?color} string background color for marker
44
+ * @property {?label} string An optional marker label
45
+ * @property {?color} string Background color for marker
46
46
  * @property {?position} string "top" or "bottom", defaults to "bottom"
47
+ * @property {?markerElement} element An HTML element to display instead of the default marker image
47
48
  */
48
49
 
49
50
  /**
@@ -150,7 +151,13 @@ var MarkersPlugin = /*#__PURE__*/function () {
150
151
  color: params.color || DEFAULT_FILL_COLOR,
151
152
  position: params.position || DEFAULT_POSITION
152
153
  };
153
- marker.el = this._createMarkerElement(marker);
154
+
155
+ if (params.markerElement) {
156
+ this.markerWidth = params.markerElement.width;
157
+ this.markerHeight = params.markerElement.height;
158
+ }
159
+
160
+ marker.el = this._createMarkerElement(marker, params.markerElement);
154
161
  this.wrapper.appendChild(marker.el);
155
162
  this.markers.push(marker);
156
163
 
@@ -204,7 +211,7 @@ var MarkersPlugin = /*#__PURE__*/function () {
204
211
  }
205
212
  }, {
206
213
  key: "_createMarkerElement",
207
- value: function _createMarkerElement(marker) {
214
+ value: function _createMarkerElement(marker, markerElement) {
208
215
  var _this2 = this;
209
216
 
210
217
  var label = marker.label;
@@ -229,7 +236,7 @@ var MarkersPlugin = /*#__PURE__*/function () {
229
236
  el.appendChild(line);
230
237
  var labelDiv = document.createElement('div');
231
238
 
232
- var point = this._createPointerSVG(marker.color, marker.position);
239
+ var point = markerElement || this._createPointerSVG(marker.color, marker.position);
233
240
 
234
241
  labelDiv.appendChild(point);
235
242
 
@@ -253,6 +260,8 @@ var MarkersPlugin = /*#__PURE__*/function () {
253
260
  e.stopPropagation();
254
261
 
255
262
  _this2.wavesurfer.setCurrentTime(time);
263
+
264
+ _this2.wavesurfer.fireEvent("marker-click", marker, e);
256
265
  });
257
266
  return el;
258
267
  }
@@ -289,6 +298,7 @@ var MarkersPlugin = /*#__PURE__*/function () {
289
298
  /**
290
299
  * @typedef {Object} MarkersPluginParams
291
300
  * @property {?MarkerParams[]} markers Initial set of markers
301
+ * @fires MarkersPlugin#marker-click
292
302
  */
293
303
 
294
304
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/markers/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"names":["DEFAULT_FILL_COLOR","DEFAULT_POSITION","MarkersPlugin","params","ws","wavesurfer","util","style","markerWidth","markerHeight","_onResize","_updateMarkerPositions","_onBackendCreated","wrapper","drawer","markers","forEach","marker","add","window","addEventListener","on","_onReady","isReady","once","un","removeEventListener","clear","time","label","color","position","el","_createMarkerElement","appendChild","push","index","removeChild","splice","svgNS","document","createElementNS","polygon","setAttribute","width","height","createElement","className","display","overflow","line","background","opacity","labelDiv","point","_createPointerSVG","labelEl","innerText","cursor","e","stopPropagation","setCurrentTime","duration","getDuration","i","length","elementWidth","pixelRatio","positionPct","Math","min","leftPx","remove","name","deferInit","staticProps","addMarker","options","initialisedPluginList","initPlugin","clearMarkers","instance"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,CAAC;AACD,O;;;;;;;;;;;;;;;;;;;;;;;ACT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C;AAC9B,aAAKO,MAAL,CAAY,CAAZ;AACH;AACJ;;;;AA1OD;AACJ;AACA;AACA;;AAEI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACI,oBAAcrE,MAAd,EAAsB;AAClB,aAAO;AACHsE,YAAI,EAAE,SADH;AAEHC,iBAAS,EAAEvE,MAAM,IAAIA,MAAM,CAACuE,SAAjB,GAA6BvE,MAAM,CAACuE,SAApC,GAAgD,KAFxD;AAGHvE,cAAM,EAAEA,MAHL;AAIHwE,mBAAW,EAAE;AACTC,mBADS,qBACCC,OADD,EACU;AACf,gBAAI,CAAC,KAAKC,qBAAL,CAA2B/D,OAAhC,EAAyC;AACrC,mBAAKgE,UAAL,CAAgB,SAAhB;AACH;;AACD,mBAAO,KAAKhE,OAAL,CAAaG,GAAb,CAAiB2D,OAAjB,CAAP;AACH,WANQ;AAOTG,sBAPS,0BAOM;AACX,iBAAKjE,OAAL,IAAgB,KAAKA,OAAL,CAAaY,KAAb,EAAhB;AACH;AATQ,SAJV;AAeHsD,gBAAQ,EAAE/E;AAfP,OAAP;AAiBH;;;;;;;;;;;;;UCvEL;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UCtBA;UACA;UACA;UACA","file":"wavesurfer.markers.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"markers\"] = factory();\n})(this, function() {\nreturn ","\n/**\n * @typedef {Object} MarkerParams\n * @desc The parameters used to describe a marker.\n * @example wavesurfer.addMarker(regionParams);\n * @property {number} time The time to set the marker at\n * @property {?label} string an optional marker label\n * @property {?color} string background color for marker\n * @property {?position} string \"top\" or \"bottom\", defaults to \"bottom\"\n */\n\n\n/**\n * Markers are points in time in the audio that can be jumped to.\n *\n * @implements {PluginClass}\n *\n * @example\n * import MarkersPlugin from 'wavesurfer.markers.js';\n *\n * // if you are using <script> tags\n * var MarkerPlugin = window.WaveSurfer.markers;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MarkersPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\n\nconst DEFAULT_FILL_COLOR = \"#D8D8D8\";\nconst DEFAULT_POSITION = \"bottom\";\n\nexport default class MarkersPlugin {\n /**\n * @typedef {Object} MarkersPluginParams\n * @property {?MarkerParams[]} markers Initial set of markers\n */\n\n /**\n * Markers plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {MarkersPluginParams} params parameters use to initialise the plugin\n * @since 4.6.0\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'markers',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n staticProps: {\n addMarker(options) {\n if (!this.initialisedPluginList.markers) {\n this.initPlugin('markers');\n }\n return this.markers.add(options);\n },\n clearMarkers() {\n this.markers && this.markers.clear();\n }\n },\n instance: MarkersPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n this.util = ws.util;\n this.style = this.util.style;\n this.markerWidth = 11;\n this.markerHeight = 22;\n\n\n this._onResize = () => {\n this._updateMarkerPositions();\n };\n\n this._onBackendCreated = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n if (this.params.markers) {\n this.params.markers.forEach(marker => this.add(marker));\n }\n window.addEventListener('resize', this._onResize, true);\n window.addEventListener('orientationchange', this._onResize, true);\n this.wavesurfer.on('zoom', this._onResize);\n };\n\n this.markers = [];\n this._onReady = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n this._updateMarkerPositions();\n };\n }\n\n init() {\n // Check if ws is ready\n if (this.wavesurfer.isReady) {\n this._onBackendCreated();\n this._onReady();\n } else {\n this.wavesurfer.once('ready', this._onReady);\n this.wavesurfer.once('backend-created', this._onBackendCreated);\n }\n }\n\n destroy() {\n this.wavesurfer.un('ready', this._onReady);\n this.wavesurfer.un('backend-created', this._onBackendCreated);\n\n this.wavesurfer.un('zoom', this._onResize);\n\n window.removeEventListener('resize', this._onResize, true);\n window.removeEventListener('orientationchange', this._onResize, true);\n\n this.clear();\n }\n\n /**\n * Add a marker\n *\n * @param {MarkerParams} params Marker definition\n * @return {object} The created marker\n */\n add(params) {\n let marker = {\n time: params.time,\n label: params.label,\n color: params.color || DEFAULT_FILL_COLOR,\n position: params.position || DEFAULT_POSITION\n };\n\n marker.el = this._createMarkerElement(marker);\n\n this.wrapper.appendChild(marker.el);\n this.markers.push(marker);\n this._updateMarkerPositions();\n\n return marker;\n }\n\n /**\n * Remove a marker\n *\n * @param {number} index Index of the marker to remove\n */\n remove(index) {\n let marker = this.markers[index];\n if (!marker) {\n return;\n }\n\n this.wrapper.removeChild(marker.el);\n this.markers.splice(index, 1);\n }\n\n _createPointerSVG(color, position) {\n const svgNS = \"http://www.w3.org/2000/svg\";\n\n const el = document.createElementNS(svgNS, \"svg\");\n const polygon = document.createElementNS(svgNS, \"polygon\");\n\n el.setAttribute(\"viewBox\", \"0 0 40 80\");\n\n polygon.setAttribute(\"id\", \"polygon\");\n polygon.setAttribute(\"stroke\", \"#979797\");\n polygon.setAttribute(\"fill\", color);\n polygon.setAttribute(\"points\", \"20 0 40 30 40 80 0 80 0 30\");\n if ( position == \"top\" ) {\n polygon.setAttribute(\"transform\", \"rotate(180, 20 40)\");\n }\n\n el.appendChild(polygon);\n\n this.style(el, {\n width: this.markerWidth + \"px\",\n height: this.markerHeight + \"px\",\n \"min-width\": this.markerWidth + \"px\",\n \"margin-right\": \"5px\",\n \"z-index\": 4\n });\n return el;\n }\n\n _createMarkerElement(marker) {\n let label = marker.label;\n let time = marker.time;\n\n const el = document.createElement('marker');\n el.className = \"wavesurfer-marker\";\n\n this.style(el, {\n position: \"absolute\",\n height: \"100%\",\n display: \"flex\",\n overflow: \"hidden\",\n \"flex-direction\": (marker.position == \"top\" ? \"column-reverse\" : \"column\")\n });\n\n const line = document.createElement('div');\n this.style(line, {\n \"flex-grow\": 1,\n \"margin-left\": (this.markerWidth / 2 - 0.5) + \"px\",\n background: \"black\",\n width: \"1px\",\n opacity: 0.1\n });\n el.appendChild(line);\n\n const labelDiv = document.createElement('div');\n const point = this._createPointerSVG(marker.color, marker.position);\n labelDiv.appendChild(point);\n\n if ( label ) {\n const labelEl = document.createElement('span');\n labelEl.innerText = label;\n this.style(labelEl, {\n \"font-family\": \"monospace\",\n \"font-size\": \"90%\"\n });\n labelDiv.appendChild(labelEl);\n }\n\n this.style(labelDiv, {\n display: \"flex\",\n \"align-items\": \"center\",\n cursor: \"pointer\"\n });\n\n el.appendChild(labelDiv);\n\n labelDiv.addEventListener(\"click\", e => {\n e.stopPropagation();\n this.wavesurfer.setCurrentTime(time);\n });\n\n return el;\n }\n\n _updateMarkerPositions() {\n const duration = this.wavesurfer.getDuration();\n\n for ( let i = 0 ; i < this.markers.length; i++ ) {\n let marker = this.markers[i];\n const elementWidth =\n this.wavesurfer.drawer.width /\n this.wavesurfer.params.pixelRatio;\n\n const positionPct = Math.min(marker.time / duration, 1);\n const leftPx = ((elementWidth * positionPct) - (this.markerWidth / 2));\n this.style(marker.el, {\n \"left\": leftPx + \"px\",\n \"max-width\": (elementWidth - leftPx) + \"px\"\n });\n }\n }\n\n /**\n * Remove all markers\n */\n clear() {\n while ( this.markers.length > 0 ) {\n this.remove(0);\n }\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(\"./src/plugin/markers/index.js\");\n"],"sourceRoot":""}
1
+ {"version":3,"sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/markers/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"names":["DEFAULT_FILL_COLOR","DEFAULT_POSITION","MarkersPlugin","params","ws","wavesurfer","util","style","markerWidth","markerHeight","_onResize","_updateMarkerPositions","_onBackendCreated","wrapper","drawer","markers","forEach","marker","add","window","addEventListener","on","_onReady","isReady","once","un","removeEventListener","clear","time","label","color","position","markerElement","width","height","el","_createMarkerElement","appendChild","push","index","removeChild","splice","svgNS","document","createElementNS","polygon","setAttribute","createElement","className","display","overflow","line","background","opacity","labelDiv","point","_createPointerSVG","labelEl","innerText","cursor","e","stopPropagation","setCurrentTime","fireEvent","duration","getDuration","i","length","elementWidth","pixelRatio","positionPct","Math","min","leftPx","remove","name","deferInit","staticProps","addMarker","options","initialisedPluginList","initPlugin","clearMarkers","instance"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,+CAA+C;AAC/C,CAAC;AACD,O;;;;;;;;;;;;;;;;;;;;;;;ACTA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,IAAMA,kBA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M,GAAG,IADA;AAElB,uBAAcL,YAAY,GAAGK,MAAhB,GAA0B;AAFrB,SAAtB;AAIH;AACJ;AAED;AACJ;AACA;;;;WACI,iBAAQ;AACJ,aAAQ,KAAK1D,OAAL,CAAaoD,MAAb,GAAsB,CAA9B,EAAkC;AAC9B,aAAKO,MAAL,CAAY,CAAZ;AACH;AACJ;;;;AAjPD;AACJ;AACA;AACA;AACA;;AAEI;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACI,oBAAcvE,MAAd,EAAsB;AAClB,aAAO;AACHwE,YAAI,EAAE,SADH;AAEHC,iBAAS,EAAEzE,MAAM,IAAIA,MAAM,CAACyE,SAAjB,GAA6BzE,MAAM,CAACyE,SAApC,GAAgD,KAFxD;AAGHzE,cAAM,EAAEA,MAHL;AAIH0E,mBAAW,EAAE;AACTC,mBADS,qBACCC,OADD,EACU;AACf,gBAAI,CAAC,KAAKC,qBAAL,CAA2BjE,OAAhC,EAAyC;AACrC,mBAAKkE,UAAL,CAAgB,SAAhB;AACH;;AACD,mBAAO,KAAKlE,OAAL,CAAaG,GAAb,CAAiB6D,OAAjB,CAAP;AACH,WANQ;AAOTG,sBAPS,0BAOM;AACX,iBAAKnE,OAAL,IAAgB,KAAKA,OAAL,CAAaY,KAAb,EAAhB;AACH;AATQ,SAJV;AAeHwD,gBAAQ,EAAEjF;AAfP,OAAP;AAiBH;;;;;;;;;;;;;UCzEL;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UCtBA;UACA;UACA;UACA","file":"wavesurfer.markers.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"markers\"] = factory();\n})(this, function() {\nreturn ","\n/**\n * @typedef {Object} MarkerParams\n * @desc The parameters used to describe a marker.\n * @example wavesurfer.addMarker(regionParams);\n * @property {number} time The time to set the marker at\n * @property {?label} string An optional marker label\n * @property {?color} string Background color for marker\n * @property {?position} string \"top\" or \"bottom\", defaults to \"bottom\"\n * @property {?markerElement} element An HTML element to display instead of the default marker image\n */\n\n\n/**\n * Markers are points in time in the audio that can be jumped to.\n *\n * @implements {PluginClass}\n *\n * @example\n * import MarkersPlugin from 'wavesurfer.markers.js';\n *\n * // if you are using <script> tags\n * var MarkerPlugin = window.WaveSurfer.markers;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MarkersPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\n\nconst DEFAULT_FILL_COLOR = \"#D8D8D8\";\nconst DEFAULT_POSITION = \"bottom\";\n\nexport default class MarkersPlugin {\n /**\n * @typedef {Object} MarkersPluginParams\n * @property {?MarkerParams[]} markers Initial set of markers\n * @fires MarkersPlugin#marker-click\n */\n\n /**\n * Markers plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {MarkersPluginParams} params parameters use to initialise the plugin\n * @since 4.6.0\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'markers',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n staticProps: {\n addMarker(options) {\n if (!this.initialisedPluginList.markers) {\n this.initPlugin('markers');\n }\n return this.markers.add(options);\n },\n clearMarkers() {\n this.markers && this.markers.clear();\n }\n },\n instance: MarkersPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n this.util = ws.util;\n this.style = this.util.style;\n this.markerWidth = 11;\n this.markerHeight = 22;\n\n\n this._onResize = () => {\n this._updateMarkerPositions();\n };\n\n this._onBackendCreated = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n if (this.params.markers) {\n this.params.markers.forEach(marker => this.add(marker));\n }\n window.addEventListener('resize', this._onResize, true);\n window.addEventListener('orientationchange', this._onResize, true);\n this.wavesurfer.on('zoom', this._onResize);\n };\n\n this.markers = [];\n this._onReady = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n this._updateMarkerPositions();\n };\n }\n\n init() {\n // Check if ws is ready\n if (this.wavesurfer.isReady) {\n this._onBackendCreated();\n this._onReady();\n } else {\n this.wavesurfer.once('ready', this._onReady);\n this.wavesurfer.once('backend-created', this._onBackendCreated);\n }\n }\n\n destroy() {\n this.wavesurfer.un('ready', this._onReady);\n this.wavesurfer.un('backend-created', this._onBackendCreated);\n\n this.wavesurfer.un('zoom', this._onResize);\n\n window.removeEventListener('resize', this._onResize, true);\n window.removeEventListener('orientationchange', this._onResize, true);\n\n this.clear();\n }\n\n /**\n * Add a marker\n *\n * @param {MarkerParams} params Marker definition\n * @return {object} The created marker\n */\n add(params) {\n let marker = {\n time: params.time,\n label: params.label,\n color: params.color || DEFAULT_FILL_COLOR,\n position: params.position || DEFAULT_POSITION\n };\n\n if (params.markerElement) {\n this.markerWidth = params.markerElement.width;\n this.markerHeight = params.markerElement.height;\n }\n\n marker.el = this._createMarkerElement(marker, params.markerElement);\n\n this.wrapper.appendChild(marker.el);\n this.markers.push(marker);\n this._updateMarkerPositions();\n\n return marker;\n }\n\n /**\n * Remove a marker\n *\n * @param {number} index Index of the marker to remove\n */\n remove(index) {\n let marker = this.markers[index];\n if (!marker) {\n return;\n }\n\n this.wrapper.removeChild(marker.el);\n this.markers.splice(index, 1);\n }\n\n _createPointerSVG(color, position) {\n const svgNS = \"http://www.w3.org/2000/svg\";\n\n const el = document.createElementNS(svgNS, \"svg\");\n const polygon = document.createElementNS(svgNS, \"polygon\");\n\n el.setAttribute(\"viewBox\", \"0 0 40 80\");\n\n polygon.setAttribute(\"id\", \"polygon\");\n polygon.setAttribute(\"stroke\", \"#979797\");\n polygon.setAttribute(\"fill\", color);\n polygon.setAttribute(\"points\", \"20 0 40 30 40 80 0 80 0 30\");\n if ( position == \"top\" ) {\n polygon.setAttribute(\"transform\", \"rotate(180, 20 40)\");\n }\n\n el.appendChild(polygon);\n\n this.style(el, {\n width: this.markerWidth + \"px\",\n height: this.markerHeight + \"px\",\n \"min-width\": this.markerWidth + \"px\",\n \"margin-right\": \"5px\",\n \"z-index\": 4\n });\n return el;\n }\n\n _createMarkerElement(marker, markerElement) {\n let label = marker.label;\n let time = marker.time;\n\n const el = document.createElement('marker');\n el.className = \"wavesurfer-marker\";\n\n this.style(el, {\n position: \"absolute\",\n height: \"100%\",\n display: \"flex\",\n overflow: \"hidden\",\n \"flex-direction\": (marker.position == \"top\" ? \"column-reverse\" : \"column\")\n });\n\n const line = document.createElement('div');\n this.style(line, {\n \"flex-grow\": 1,\n \"margin-left\": (this.markerWidth / 2 - 0.5) + \"px\",\n background: \"black\",\n width: \"1px\",\n opacity: 0.1\n });\n el.appendChild(line);\n\n const labelDiv = document.createElement('div');\n const point = markerElement || this._createPointerSVG(marker.color, marker.position);\n labelDiv.appendChild(point);\n\n if ( label ) {\n const labelEl = document.createElement('span');\n labelEl.innerText = label;\n this.style(labelEl, {\n \"font-family\": \"monospace\",\n \"font-size\": \"90%\"\n });\n labelDiv.appendChild(labelEl);\n }\n\n this.style(labelDiv, {\n display: \"flex\",\n \"align-items\": \"center\",\n cursor: \"pointer\"\n });\n\n el.appendChild(labelDiv);\n\n labelDiv.addEventListener(\"click\", e => {\n e.stopPropagation();\n this.wavesurfer.setCurrentTime(time);\n this.wavesurfer.fireEvent(\"marker-click\", marker, e);\n });\n\n return el;\n }\n\n _updateMarkerPositions() {\n const duration = this.wavesurfer.getDuration();\n\n for ( let i = 0 ; i < this.markers.length; i++ ) {\n let marker = this.markers[i];\n const elementWidth =\n this.wavesurfer.drawer.width /\n this.wavesurfer.params.pixelRatio;\n\n const positionPct = Math.min(marker.time / duration, 1);\n const leftPx = ((elementWidth * positionPct) - (this.markerWidth / 2));\n this.style(marker.el, {\n \"left\": leftPx + \"px\",\n \"max-width\": (elementWidth - leftPx) + \"px\"\n });\n }\n }\n\n /**\n * Remove all markers\n */\n clear() {\n while ( this.markers.length > 0 ) {\n this.remove(0);\n }\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(\"./src/plugin/markers/index.js\");\n"],"sourceRoot":""}
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * wavesurfer.js markers plugin 5.0.1 (2021-05-05)
2
+ * wavesurfer.js markers plugin 5.1.0 (2021-06-20)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
6
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("WaveSurfer",[],t):"object"==typeof exports?exports.WaveSurfer=t():(e.WaveSurfer=e.WaveSurfer||{},e.WaveSurfer.markers=t())}(this,(function(){return(()=>{"use strict";var e={188:(e,t)=>{function r(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(){function e(t,r){var i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.params=t,this.wavesurfer=r,this.util=r.util,this.style=this.util.style,this.markerWidth=11,this.markerHeight=22,this._onResize=function(){i._updateMarkerPositions()},this._onBackendCreated=function(){i.wrapper=i.wavesurfer.drawer.wrapper,i.params.markers&&i.params.markers.forEach((function(e){return i.add(e)})),window.addEventListener("resize",i._onResize,!0),window.addEventListener("orientationchange",i._onResize,!0),i.wavesurfer.on("zoom",i._onResize)},this.markers=[],this._onReady=function(){i.wrapper=i.wavesurfer.drawer.wrapper,i._updateMarkerPositions()}}var t,i,a;return t=e,a=[{key:"create",value:function(t){return{name:"markers",deferInit:!(!t||!t.deferInit)&&t.deferInit,params:t,staticProps:{addMarker:function(e){return this.initialisedPluginList.markers||this.initPlugin("markers"),this.markers.add(e)},clearMarkers:function(){this.markers&&this.markers.clear()}},instance:e}}}],(i=[{key:"init",value:function(){this.wavesurfer.isReady?(this._onBackendCreated(),this._onReady()):(this.wavesurfer.once("ready",this._onReady),this.wavesurfer.once("backend-created",this._onBackendCreated))}},{key:"destroy",value:function(){this.wavesurfer.un("ready",this._onReady),this.wavesurfer.un("backend-created",this._onBackendCreated),this.wavesurfer.un("zoom",this._onResize),window.removeEventListener("resize",this._onResize,!0),window.removeEventListener("orientationchange",this._onResize,!0),this.clear()}},{key:"add",value:function(e){var t={time:e.time,label:e.label,color:e.color||"#D8D8D8",position:e.position||"bottom"};return t.el=this._createMarkerElement(t),this.wrapper.appendChild(t.el),this.markers.push(t),this._updateMarkerPositions(),t}},{key:"remove",value:function(e){var t=this.markers[e];t&&(this.wrapper.removeChild(t.el),this.markers.splice(e,1))}},{key:"_createPointerSVG",value:function(e,t){var r="http://www.w3.org/2000/svg",i=document.createElementNS(r,"svg"),a=document.createElementNS(r,"polygon");return i.setAttribute("viewBox","0 0 40 80"),a.setAttribute("id","polygon"),a.setAttribute("stroke","#979797"),a.setAttribute("fill",e),a.setAttribute("points","20 0 40 30 40 80 0 80 0 30"),"top"==t&&a.setAttribute("transform","rotate(180, 20 40)"),i.appendChild(a),this.style(i,{width:this.markerWidth+"px",height:this.markerHeight+"px","min-width":this.markerWidth+"px","margin-right":"5px","z-index":4}),i}},{key:"_createMarkerElement",value:function(e){var t=this,r=e.label,i=e.time,a=document.createElement("marker");a.className="wavesurfer-marker",this.style(a,{position:"absolute",height:"100%",display:"flex",overflow:"hidden","flex-direction":"top"==e.position?"column-reverse":"column"});var n=document.createElement("div");this.style(n,{"flex-grow":1,"margin-left":this.markerWidth/2-.5+"px",background:"black",width:"1px",opacity:.1}),a.appendChild(n);var s=document.createElement("div"),o=this._createPointerSVG(e.color,e.position);if(s.appendChild(o),r){var u=document.createElement("span");u.innerText=r,this.style(u,{"font-family":"monospace","font-size":"90%"}),s.appendChild(u)}return this.style(s,{display:"flex","align-items":"center",cursor:"pointer"}),a.appendChild(s),s.addEventListener("click",(function(e){e.stopPropagation(),t.wavesurfer.setCurrentTime(i)})),a}},{key:"_updateMarkerPositions",value:function(){for(var e=this.wavesurfer.getDuration(),t=0;t<this.markers.length;t++){var r=this.markers[t],i=this.wavesurfer.drawer.width/this.wavesurfer.params.pixelRatio,a=i*Math.min(r.time/e,1)-this.markerWidth/2;this.style(r.el,{left:a+"px","max-width":i-a+"px"})}}},{key:"clear",value:function(){for(;this.markers.length>0;)this.remove(0)}}])&&r(t.prototype,i),a&&r(t,a),e}();t.default=i,e.exports=t.default}},t={};return function r(i){var a=t[i];if(void 0!==a)return a.exports;var n=t[i]={exports:{}};return e[i](n,n.exports,r),n.exports}(188)})()}));
6
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("WaveSurfer",[],t):"object"==typeof exports?exports.WaveSurfer=t():(e.WaveSurfer=e.WaveSurfer||{},e.WaveSurfer.markers=t())}(this,(function(){return(()=>{"use strict";var e={188:(e,t)=>{function r(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i=function(){function e(t,r){var i=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.params=t,this.wavesurfer=r,this.util=r.util,this.style=this.util.style,this.markerWidth=11,this.markerHeight=22,this._onResize=function(){i._updateMarkerPositions()},this._onBackendCreated=function(){i.wrapper=i.wavesurfer.drawer.wrapper,i.params.markers&&i.params.markers.forEach((function(e){return i.add(e)})),window.addEventListener("resize",i._onResize,!0),window.addEventListener("orientationchange",i._onResize,!0),i.wavesurfer.on("zoom",i._onResize)},this.markers=[],this._onReady=function(){i.wrapper=i.wavesurfer.drawer.wrapper,i._updateMarkerPositions()}}var t,i,a;return t=e,a=[{key:"create",value:function(t){return{name:"markers",deferInit:!(!t||!t.deferInit)&&t.deferInit,params:t,staticProps:{addMarker:function(e){return this.initialisedPluginList.markers||this.initPlugin("markers"),this.markers.add(e)},clearMarkers:function(){this.markers&&this.markers.clear()}},instance:e}}}],(i=[{key:"init",value:function(){this.wavesurfer.isReady?(this._onBackendCreated(),this._onReady()):(this.wavesurfer.once("ready",this._onReady),this.wavesurfer.once("backend-created",this._onBackendCreated))}},{key:"destroy",value:function(){this.wavesurfer.un("ready",this._onReady),this.wavesurfer.un("backend-created",this._onBackendCreated),this.wavesurfer.un("zoom",this._onResize),window.removeEventListener("resize",this._onResize,!0),window.removeEventListener("orientationchange",this._onResize,!0),this.clear()}},{key:"add",value:function(e){var t={time:e.time,label:e.label,color:e.color||"#D8D8D8",position:e.position||"bottom"};return e.markerElement&&(this.markerWidth=e.markerElement.width,this.markerHeight=e.markerElement.height),t.el=this._createMarkerElement(t,e.markerElement),this.wrapper.appendChild(t.el),this.markers.push(t),this._updateMarkerPositions(),t}},{key:"remove",value:function(e){var t=this.markers[e];t&&(this.wrapper.removeChild(t.el),this.markers.splice(e,1))}},{key:"_createPointerSVG",value:function(e,t){var r="http://www.w3.org/2000/svg",i=document.createElementNS(r,"svg"),a=document.createElementNS(r,"polygon");return i.setAttribute("viewBox","0 0 40 80"),a.setAttribute("id","polygon"),a.setAttribute("stroke","#979797"),a.setAttribute("fill",e),a.setAttribute("points","20 0 40 30 40 80 0 80 0 30"),"top"==t&&a.setAttribute("transform","rotate(180, 20 40)"),i.appendChild(a),this.style(i,{width:this.markerWidth+"px",height:this.markerHeight+"px","min-width":this.markerWidth+"px","margin-right":"5px","z-index":4}),i}},{key:"_createMarkerElement",value:function(e,t){var r=this,i=e.label,a=e.time,n=document.createElement("marker");n.className="wavesurfer-marker",this.style(n,{position:"absolute",height:"100%",display:"flex",overflow:"hidden","flex-direction":"top"==e.position?"column-reverse":"column"});var s=document.createElement("div");this.style(s,{"flex-grow":1,"margin-left":this.markerWidth/2-.5+"px",background:"black",width:"1px",opacity:.1}),n.appendChild(s);var o=document.createElement("div"),u=t||this._createPointerSVG(e.color,e.position);if(o.appendChild(u),i){var d=document.createElement("span");d.innerText=i,this.style(d,{"font-family":"monospace","font-size":"90%"}),o.appendChild(d)}return this.style(o,{display:"flex","align-items":"center",cursor:"pointer"}),n.appendChild(o),o.addEventListener("click",(function(t){t.stopPropagation(),r.wavesurfer.setCurrentTime(a),r.wavesurfer.fireEvent("marker-click",e,t)})),n}},{key:"_updateMarkerPositions",value:function(){for(var e=this.wavesurfer.getDuration(),t=0;t<this.markers.length;t++){var r=this.markers[t],i=this.wavesurfer.drawer.width/this.wavesurfer.params.pixelRatio,a=i*Math.min(r.time/e,1)-this.markerWidth/2;this.style(r.el,{left:a+"px","max-width":i-a+"px"})}}},{key:"clear",value:function(){for(;this.markers.length>0;)this.remove(0)}}])&&r(t.prototype,i),a&&r(t,a),e}();t.default=i,e.exports=t.default}},t={};return function r(i){var a=t[i];if(void 0!==a)return a.exports;var n=t[i]={exports:{}};return e[i](n,n.exports,r),n.exports}(188)})()}));
7
7
  //# sourceMappingURL=wavesurfer.markers.min.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/markers/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"names":["root","factory","exports","module","define","amd","this","MarkersPlugin","params","ws","wavesurfer","util","style","markerWidth","markerHeight","_onResize","_updateMarkerPositions","_onBackendCreated","wrapper","drawer","markers","forEach","marker","add","window","addEventListener","on","_onReady","name","deferInit","staticProps","addMarker","options","initialisedPluginList","initPlugin","clearMarkers","clear","instance","isReady","once","un","removeEventListener","time","label","color","position","el","_createMarkerElement","appendChild","push","index","removeChild","splice","svgNS","document","createElementNS","polygon","setAttribute","width","height","createElement","className","display","overflow","line","background","opacity","labelDiv","point","_createPointerSVG","labelEl","innerText","cursor","e","stopPropagation","setCurrentTime","duration","getDuration","i","length","elementWidth","pixelRatio","leftPx","Math","min","remove","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"mappings":";;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,aAAc,GAAIH,GACC,iBAAZC,QACdA,QAAoB,WAAID,KAExBD,EAAiB,WAAIA,EAAiB,YAAK,GAAIA,EAAiB,WAAW,QAAIC,KARjF,CASGK,MAAM,WACT,M,8QCwBA,IAGqBC,E,WAoCjB,WAAYC,EAAQC,GAAI,Y,4FAAA,SACpBH,KAAKE,OAASA,EACdF,KAAKI,WAAaD,EAClBH,KAAKK,KAAOF,EAAGE,KACfL,KAAKM,MAAQN,KAAKK,KAAKC,MACvBN,KAAKO,YAAc,GACnBP,KAAKQ,aAAe,GAGpBR,KAAKS,UAAY,WACb,EAAKC,0BAGTV,KAAKW,kBAAoB,WACrB,EAAKC,QAAU,EAAKR,WAAWS,OAAOD,QAClC,EAAKV,OAAOY,SACZ,EAAKZ,OAAOY,QAAQ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hBzB,EAAQ,CACT,IAAM2B,EAAUhB,SAASM,cAAc,QACvCU,EAAQC,UAAY5B,EACpBrC,KAAKM,MAAM0D,EAAS,CAChB,cAAe,YACf,YAAa,QAEjBH,EAASnB,YAAYsB,GAgBzB,OAbAhE,KAAKM,MAAMuD,EAAU,CACjBL,QAAS,OACT,cAAe,SACfU,OAAQ,YAGZ1B,EAAGE,YAAYmB,GAEfA,EAAS1C,iBAAiB,SAAS,SAAAgD,GAC/BA,EAAEC,kBACF,EAAKhE,WAAWiE,eAAejC,MAG5BI,I,oCAGX,WAGI,IAFA,IAAM8B,EAAWtE,KAAKI,WAAWmE,cAEvBC,EAAI,EAAIA,EAAIxE,KAAKc,QAAQ2D,OAAQD,IAAM,CAC7C,IAAIxD,EAAShB,KAAKc,QAAQ0D,GACpBE,EACF1E,KAAKI,WAAWS,OAAOuC,MACvBpD,KAAKI,WAAWF,OAAOyE,WAGrBC,EAAWF,EADGG,KAAKC,IAAI9D,EAAOoB,KAAOkC,EAAU,GACLtE,KAAKO,YAAc,EACnEP,KAAKM,MAAMU,EAAOwB,GAAI,CAClB,KAASoC,EAAS,KAClB,YAAcF,EAAeE,EAAU,U,mBAQnD,WACI,KAAQ5E,KAAKc,QAAQ2D,OAAS,GAC1BzE,KAAK+E,OAAO,Q,kEC7QpBC,EAA2B,G,OAG/B,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAavF,QAGrB,IAAIC,EAASmF,EAAyBE,GAAY,CAGjDtF,QAAS,IAOV,OAHAyF,EAAoBH,GAAUrF,EAAQA,EAAOD,QAASqF,GAG/CpF,EAAOD,QClBWqF,CAAoB,M","file":"wavesurfer.markers.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"markers\"] = factory();\n})(this, function() {\nreturn ","\n/**\n * @typedef {Object} MarkerParams\n * @desc The parameters used to describe a marker.\n * @example wavesurfer.addMarker(regionParams);\n * @property {number} time The time to set the marker at\n * @property {?label} string an optional marker label\n * @property {?color} string background color for marker\n * @property {?position} string \"top\" or \"bottom\", defaults to \"bottom\"\n */\n\n\n/**\n * Markers are points in time in the audio that can be jumped to.\n *\n * @implements {PluginClass}\n *\n * @example\n * import MarkersPlugin from 'wavesurfer.markers.js';\n *\n * // if you are using <script> tags\n * var MarkerPlugin = window.WaveSurfer.markers;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MarkersPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\n\nconst DEFAULT_FILL_COLOR = \"#D8D8D8\";\nconst DEFAULT_POSITION = \"bottom\";\n\nexport default class MarkersPlugin {\n /**\n * @typedef {Object} MarkersPluginParams\n * @property {?MarkerParams[]} markers Initial set of markers\n */\n\n /**\n * Markers plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {MarkersPluginParams} params parameters use to initialise the plugin\n * @since 4.6.0\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'markers',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n staticProps: {\n addMarker(options) {\n if (!this.initialisedPluginList.markers) {\n this.initPlugin('markers');\n }\n return this.markers.add(options);\n },\n clearMarkers() {\n this.markers && this.markers.clear();\n }\n },\n instance: MarkersPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n this.util = ws.util;\n this.style = this.util.style;\n this.markerWidth = 11;\n this.markerHeight = 22;\n\n\n this._onResize = () => {\n this._updateMarkerPositions();\n };\n\n this._onBackendCreated = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n if (this.params.markers) {\n this.params.markers.forEach(marker => this.add(marker));\n }\n window.addEventListener('resize', this._onResize, true);\n window.addEventListener('orientationchange', this._onResize, true);\n this.wavesurfer.on('zoom', this._onResize);\n };\n\n this.markers = [];\n this._onReady = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n this._updateMarkerPositions();\n };\n }\n\n init() {\n // Check if ws is ready\n if (this.wavesurfer.isReady) {\n this._onBackendCreated();\n this._onReady();\n } else {\n this.wavesurfer.once('ready', this._onReady);\n this.wavesurfer.once('backend-created', this._onBackendCreated);\n }\n }\n\n destroy() {\n this.wavesurfer.un('ready', this._onReady);\n this.wavesurfer.un('backend-created', this._onBackendCreated);\n\n this.wavesurfer.un('zoom', this._onResize);\n\n window.removeEventListener('resize', this._onResize, true);\n window.removeEventListener('orientationchange', this._onResize, true);\n\n this.clear();\n }\n\n /**\n * Add a marker\n *\n * @param {MarkerParams} params Marker definition\n * @return {object} The created marker\n */\n add(params) {\n let marker = {\n time: params.time,\n label: params.label,\n color: params.color || DEFAULT_FILL_COLOR,\n position: params.position || DEFAULT_POSITION\n };\n\n marker.el = this._createMarkerElement(marker);\n\n this.wrapper.appendChild(marker.el);\n this.markers.push(marker);\n this._updateMarkerPositions();\n\n return marker;\n }\n\n /**\n * Remove a marker\n *\n * @param {number} index Index of the marker to remove\n */\n remove(index) {\n let marker = this.markers[index];\n if (!marker) {\n return;\n }\n\n this.wrapper.removeChild(marker.el);\n this.markers.splice(index, 1);\n }\n\n _createPointerSVG(color, position) {\n const svgNS = \"http://www.w3.org/2000/svg\";\n\n const el = document.createElementNS(svgNS, \"svg\");\n const polygon = document.createElementNS(svgNS, \"polygon\");\n\n el.setAttribute(\"viewBox\", \"0 0 40 80\");\n\n polygon.setAttribute(\"id\", \"polygon\");\n polygon.setAttribute(\"stroke\", \"#979797\");\n polygon.setAttribute(\"fill\", color);\n polygon.setAttribute(\"points\", \"20 0 40 30 40 80 0 80 0 30\");\n if ( position == \"top\" ) {\n polygon.setAttribute(\"transform\", \"rotate(180, 20 40)\");\n }\n\n el.appendChild(polygon);\n\n this.style(el, {\n width: this.markerWidth + \"px\",\n height: this.markerHeight + \"px\",\n \"min-width\": this.markerWidth + \"px\",\n \"margin-right\": \"5px\",\n \"z-index\": 4\n });\n return el;\n }\n\n _createMarkerElement(marker) {\n let label = marker.label;\n let time = marker.time;\n\n const el = document.createElement('marker');\n el.className = \"wavesurfer-marker\";\n\n this.style(el, {\n position: \"absolute\",\n height: \"100%\",\n display: \"flex\",\n overflow: \"hidden\",\n \"flex-direction\": (marker.position == \"top\" ? \"column-reverse\" : \"column\")\n });\n\n const line = document.createElement('div');\n this.style(line, {\n \"flex-grow\": 1,\n \"margin-left\": (this.markerWidth / 2 - 0.5) + \"px\",\n background: \"black\",\n width: \"1px\",\n opacity: 0.1\n });\n el.appendChild(line);\n\n const labelDiv = document.createElement('div');\n const point = this._createPointerSVG(marker.color, marker.position);\n labelDiv.appendChild(point);\n\n if ( label ) {\n const labelEl = document.createElement('span');\n labelEl.innerText = label;\n this.style(labelEl, {\n \"font-family\": \"monospace\",\n \"font-size\": \"90%\"\n });\n labelDiv.appendChild(labelEl);\n }\n\n this.style(labelDiv, {\n display: \"flex\",\n \"align-items\": \"center\",\n cursor: \"pointer\"\n });\n\n el.appendChild(labelDiv);\n\n labelDiv.addEventListener(\"click\", e => {\n e.stopPropagation();\n this.wavesurfer.setCurrentTime(time);\n });\n\n return el;\n }\n\n _updateMarkerPositions() {\n const duration = this.wavesurfer.getDuration();\n\n for ( let i = 0 ; i < this.markers.length; i++ ) {\n let marker = this.markers[i];\n const elementWidth =\n this.wavesurfer.drawer.width /\n this.wavesurfer.params.pixelRatio;\n\n const positionPct = Math.min(marker.time / duration, 1);\n const leftPx = ((elementWidth * positionPct) - (this.markerWidth / 2));\n this.style(marker.el, {\n \"left\": leftPx + \"px\",\n \"max-width\": (elementWidth - leftPx) + \"px\"\n });\n }\n }\n\n /**\n * Remove all markers\n */\n clear() {\n while ( this.markers.length > 0 ) {\n this.remove(0);\n }\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(188);\n"],"sourceRoot":""}
1
+ {"version":3,"sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/markers/index.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"names":["root","factory","exports","module","define","amd","this","MarkersPlugin","params","ws","wavesurfer","util","style","markerWidth","markerHeight","_onResize","_updateMarkerPositions","_onBackendCreated","wrapper","drawer","markers","forEach","marker","add","window","addEventListener","on","_onReady","name","deferInit","staticProps","addMarker","options","initialisedPluginList","initPlugin","clearMarkers","clear","instance","isReady","once","un","removeEventListener","time","label","color","position","markerElement","width","height","el","_createMarkerElement","appendChild","push","index","removeChild","splice","svgNS","document","createElementNS","polygon","setAttribute","createElement","className","display","overflow","line","background","opacity","labelDiv","point","_createPointerSVG","labelEl","innerText","cursor","e","stopPropagation","setCurrentTime","fireEvent","duration","getDuration","i","length","elementWidth","pixelRatio","leftPx","Math","min","remove","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__"],"mappings":";;;;;CAAA,SAA2CA,EAAMC,GAC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AKc,QAAQ4D,GACpBE,EACF5E,KAAKI,WAAWS,OAAO4B,MACvBzC,KAAKI,WAAWF,OAAO2E,WAGrBC,EAAWF,EADGG,KAAKC,IAAIhE,EAAOoB,KAAOoC,EAAU,GACLxE,KAAKO,YAAc,EACnEP,KAAKM,MAAMU,EAAO2B,GAAI,CAClB,KAASmC,EAAS,KAClB,YAAcF,EAAeE,EAAU,U,mBAQnD,WACI,KAAQ9E,KAAKc,QAAQ6D,OAAS,GAC1B3E,KAAKiF,OAAO,Q,kECrRpBC,EAA2B,G,OAG/B,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAazF,QAGrB,IAAIC,EAASqF,EAAyBE,GAAY,CAGjDxF,QAAS,IAOV,OAHA2F,EAAoBH,GAAUvF,EAAQA,EAAOD,QAASuF,GAG/CtF,EAAOD,QClBWuF,CAAoB,M","file":"wavesurfer.markers.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"markers\"] = factory();\n})(this, function() {\nreturn ","\n/**\n * @typedef {Object} MarkerParams\n * @desc The parameters used to describe a marker.\n * @example wavesurfer.addMarker(regionParams);\n * @property {number} time The time to set the marker at\n * @property {?label} string An optional marker label\n * @property {?color} string Background color for marker\n * @property {?position} string \"top\" or \"bottom\", defaults to \"bottom\"\n * @property {?markerElement} element An HTML element to display instead of the default marker image\n */\n\n\n/**\n * Markers are points in time in the audio that can be jumped to.\n *\n * @implements {PluginClass}\n *\n * @example\n * import MarkersPlugin from 'wavesurfer.markers.js';\n *\n * // if you are using <script> tags\n * var MarkerPlugin = window.WaveSurfer.markers;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * MarkersPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\n\nconst DEFAULT_FILL_COLOR = \"#D8D8D8\";\nconst DEFAULT_POSITION = \"bottom\";\n\nexport default class MarkersPlugin {\n /**\n * @typedef {Object} MarkersPluginParams\n * @property {?MarkerParams[]} markers Initial set of markers\n * @fires MarkersPlugin#marker-click\n */\n\n /**\n * Markers plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {MarkersPluginParams} params parameters use to initialise the plugin\n * @since 4.6.0\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'markers',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n staticProps: {\n addMarker(options) {\n if (!this.initialisedPluginList.markers) {\n this.initPlugin('markers');\n }\n return this.markers.add(options);\n },\n clearMarkers() {\n this.markers && this.markers.clear();\n }\n },\n instance: MarkersPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n this.util = ws.util;\n this.style = this.util.style;\n this.markerWidth = 11;\n this.markerHeight = 22;\n\n\n this._onResize = () => {\n this._updateMarkerPositions();\n };\n\n this._onBackendCreated = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n if (this.params.markers) {\n this.params.markers.forEach(marker => this.add(marker));\n }\n window.addEventListener('resize', this._onResize, true);\n window.addEventListener('orientationchange', this._onResize, true);\n this.wavesurfer.on('zoom', this._onResize);\n };\n\n this.markers = [];\n this._onReady = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n this._updateMarkerPositions();\n };\n }\n\n init() {\n // Check if ws is ready\n if (this.wavesurfer.isReady) {\n this._onBackendCreated();\n this._onReady();\n } else {\n this.wavesurfer.once('ready', this._onReady);\n this.wavesurfer.once('backend-created', this._onBackendCreated);\n }\n }\n\n destroy() {\n this.wavesurfer.un('ready', this._onReady);\n this.wavesurfer.un('backend-created', this._onBackendCreated);\n\n this.wavesurfer.un('zoom', this._onResize);\n\n window.removeEventListener('resize', this._onResize, true);\n window.removeEventListener('orientationchange', this._onResize, true);\n\n this.clear();\n }\n\n /**\n * Add a marker\n *\n * @param {MarkerParams} params Marker definition\n * @return {object} The created marker\n */\n add(params) {\n let marker = {\n time: params.time,\n label: params.label,\n color: params.color || DEFAULT_FILL_COLOR,\n position: params.position || DEFAULT_POSITION\n };\n\n if (params.markerElement) {\n this.markerWidth = params.markerElement.width;\n this.markerHeight = params.markerElement.height;\n }\n\n marker.el = this._createMarkerElement(marker, params.markerElement);\n\n this.wrapper.appendChild(marker.el);\n this.markers.push(marker);\n this._updateMarkerPositions();\n\n return marker;\n }\n\n /**\n * Remove a marker\n *\n * @param {number} index Index of the marker to remove\n */\n remove(index) {\n let marker = this.markers[index];\n if (!marker) {\n return;\n }\n\n this.wrapper.removeChild(marker.el);\n this.markers.splice(index, 1);\n }\n\n _createPointerSVG(color, position) {\n const svgNS = \"http://www.w3.org/2000/svg\";\n\n const el = document.createElementNS(svgNS, \"svg\");\n const polygon = document.createElementNS(svgNS, \"polygon\");\n\n el.setAttribute(\"viewBox\", \"0 0 40 80\");\n\n polygon.setAttribute(\"id\", \"polygon\");\n polygon.setAttribute(\"stroke\", \"#979797\");\n polygon.setAttribute(\"fill\", color);\n polygon.setAttribute(\"points\", \"20 0 40 30 40 80 0 80 0 30\");\n if ( position == \"top\" ) {\n polygon.setAttribute(\"transform\", \"rotate(180, 20 40)\");\n }\n\n el.appendChild(polygon);\n\n this.style(el, {\n width: this.markerWidth + \"px\",\n height: this.markerHeight + \"px\",\n \"min-width\": this.markerWidth + \"px\",\n \"margin-right\": \"5px\",\n \"z-index\": 4\n });\n return el;\n }\n\n _createMarkerElement(marker, markerElement) {\n let label = marker.label;\n let time = marker.time;\n\n const el = document.createElement('marker');\n el.className = \"wavesurfer-marker\";\n\n this.style(el, {\n position: \"absolute\",\n height: \"100%\",\n display: \"flex\",\n overflow: \"hidden\",\n \"flex-direction\": (marker.position == \"top\" ? \"column-reverse\" : \"column\")\n });\n\n const line = document.createElement('div');\n this.style(line, {\n \"flex-grow\": 1,\n \"margin-left\": (this.markerWidth / 2 - 0.5) + \"px\",\n background: \"black\",\n width: \"1px\",\n opacity: 0.1\n });\n el.appendChild(line);\n\n const labelDiv = document.createElement('div');\n const point = markerElement || this._createPointerSVG(marker.color, marker.position);\n labelDiv.appendChild(point);\n\n if ( label ) {\n const labelEl = document.createElement('span');\n labelEl.innerText = label;\n this.style(labelEl, {\n \"font-family\": \"monospace\",\n \"font-size\": \"90%\"\n });\n labelDiv.appendChild(labelEl);\n }\n\n this.style(labelDiv, {\n display: \"flex\",\n \"align-items\": \"center\",\n cursor: \"pointer\"\n });\n\n el.appendChild(labelDiv);\n\n labelDiv.addEventListener(\"click\", e => {\n e.stopPropagation();\n this.wavesurfer.setCurrentTime(time);\n this.wavesurfer.fireEvent(\"marker-click\", marker, e);\n });\n\n return el;\n }\n\n _updateMarkerPositions() {\n const duration = this.wavesurfer.getDuration();\n\n for ( let i = 0 ; i < this.markers.length; i++ ) {\n let marker = this.markers[i];\n const elementWidth =\n this.wavesurfer.drawer.width /\n this.wavesurfer.params.pixelRatio;\n\n const positionPct = Math.min(marker.time / duration, 1);\n const leftPx = ((elementWidth * positionPct) - (this.markerWidth / 2));\n this.style(marker.el, {\n \"left\": leftPx + \"px\",\n \"max-width\": (elementWidth - leftPx) + \"px\"\n });\n }\n }\n\n /**\n * Remove all markers\n */\n clear() {\n while ( this.markers.length > 0 ) {\n this.remove(0);\n }\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(188);\n"],"sourceRoot":""}
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js mediasession plugin 5.0.1 (2021-05-05)
2
+ * wavesurfer.js mediasession plugin 5.1.0 (2021-06-20)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js mediasession plugin 5.0.1 (2021-05-05)
2
+ * wavesurfer.js mediasession plugin 5.1.0 (2021-06-20)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js microphone plugin 5.0.1 (2021-05-05)
2
+ * wavesurfer.js microphone plugin 5.1.0 (2021-06-20)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js microphone plugin 5.0.1 (2021-05-05)
2
+ * wavesurfer.js microphone plugin 5.1.0 (2021-06-20)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js minimap plugin 5.0.1 (2021-05-05)
2
+ * wavesurfer.js minimap plugin 5.1.0 (2021-06-20)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js minimap plugin 5.0.1 (2021-05-05)
2
+ * wavesurfer.js minimap plugin 5.1.0 (2021-06-20)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js playhead plugin 5.0.1 (2021-05-05)
2
+ * wavesurfer.js playhead plugin 5.1.0 (2021-06-20)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js playhead plugin 5.0.1 (2021-05-05)
2
+ * wavesurfer.js playhead plugin 5.1.0 (2021-06-20)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js regions plugin 5.0.1 (2021-05-05)
2
+ * wavesurfer.js regions plugin 5.1.0 (2021-06-20)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -719,7 +719,7 @@ var Region = /*#__PURE__*/function () {
719
719
  this.handleRightEl.className = 'wavesurfer-handle wavesurfer-handle-end'; // Default CSS properties for both handles.
720
720
 
721
721
  var css = {
722
- cursor: 'row-resize',
722
+ cursor: this.vertical ? 'row-resize' : 'col-resize',
723
723
  position: 'absolute',
724
724
  top: '0px',
725
725
  width: '2px',
@@ -1185,7 +1185,9 @@ var Region = /*#__PURE__*/function () {
1185
1185
  this.element.addEventListener('mousedown', onDown);
1186
1186
  this.element.addEventListener('touchstart', onDown);
1187
1187
  document.body.addEventListener('mousemove', onMove);
1188
- document.body.addEventListener('touchmove', onMove);
1188
+ document.body.addEventListener('touchmove', onMove, {
1189
+ passive: false
1190
+ });
1189
1191
  document.addEventListener('mouseup', onUp);
1190
1192
  document.body.addEventListener('touchend', onUp);
1191
1193
  this.on('remove', function () {