wavesurfer.js 6.3.0 → 6.5.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 (59) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +36 -47
  3. package/dist/plugin/wavesurfer.cursor.js +45 -54
  4. package/dist/plugin/wavesurfer.cursor.js.map +1 -1
  5. package/dist/plugin/wavesurfer.cursor.min.js +2 -2
  6. package/dist/plugin/wavesurfer.cursor.min.js.map +1 -1
  7. package/dist/plugin/wavesurfer.elan.js +24 -51
  8. package/dist/plugin/wavesurfer.elan.js.map +1 -1
  9. package/dist/plugin/wavesurfer.elan.min.js +2 -2
  10. package/dist/plugin/wavesurfer.elan.min.js.map +1 -1
  11. package/dist/plugin/wavesurfer.markers.js +62 -74
  12. package/dist/plugin/wavesurfer.markers.js.map +1 -1
  13. package/dist/plugin/wavesurfer.markers.min.js +2 -2
  14. package/dist/plugin/wavesurfer.markers.min.js.map +1 -1
  15. package/dist/plugin/wavesurfer.mediasession.js +8 -16
  16. package/dist/plugin/wavesurfer.mediasession.js.map +1 -1
  17. package/dist/plugin/wavesurfer.mediasession.min.js +2 -2
  18. package/dist/plugin/wavesurfer.mediasession.min.js.map +1 -1
  19. package/dist/plugin/wavesurfer.microphone.js +48 -63
  20. package/dist/plugin/wavesurfer.microphone.js.map +1 -1
  21. package/dist/plugin/wavesurfer.microphone.min.js +2 -2
  22. package/dist/plugin/wavesurfer.microphone.min.js.map +1 -1
  23. package/dist/plugin/wavesurfer.minimap.js +20 -69
  24. package/dist/plugin/wavesurfer.minimap.js.map +1 -1
  25. package/dist/plugin/wavesurfer.minimap.min.js +2 -2
  26. package/dist/plugin/wavesurfer.minimap.min.js.map +1 -1
  27. package/dist/plugin/wavesurfer.playhead.js +6 -30
  28. package/dist/plugin/wavesurfer.playhead.js.map +1 -1
  29. package/dist/plugin/wavesurfer.playhead.min.js +2 -2
  30. package/dist/plugin/wavesurfer.playhead.min.js.map +1 -1
  31. package/dist/plugin/wavesurfer.regions.js +203 -260
  32. package/dist/plugin/wavesurfer.regions.js.map +1 -1
  33. package/dist/plugin/wavesurfer.regions.min.js +2 -2
  34. package/dist/plugin/wavesurfer.regions.min.js.map +1 -1
  35. package/dist/plugin/wavesurfer.spectrogram.js +55 -147
  36. package/dist/plugin/wavesurfer.spectrogram.js.map +1 -1
  37. package/dist/plugin/wavesurfer.spectrogram.min.js +2 -2
  38. package/dist/plugin/wavesurfer.spectrogram.min.js.map +1 -1
  39. package/dist/plugin/wavesurfer.timeline.js +53 -88
  40. package/dist/plugin/wavesurfer.timeline.js.map +1 -1
  41. package/dist/plugin/wavesurfer.timeline.min.js +2 -2
  42. package/dist/plugin/wavesurfer.timeline.min.js.map +1 -1
  43. package/dist/wavesurfer-html-init.js +34 -54
  44. package/dist/wavesurfer-html-init.js.map +1 -1
  45. package/dist/wavesurfer-html-init.min.js +2 -2
  46. package/dist/wavesurfer-html-init.min.js.map +1 -1
  47. package/dist/wavesurfer.js +490 -1003
  48. package/dist/wavesurfer.js.map +1 -1
  49. package/dist/wavesurfer.min.js +2 -2
  50. package/dist/wavesurfer.min.js.map +1 -1
  51. package/package.json +11 -11
  52. package/src/mediaelement.js +3 -0
  53. package/src/plugin/cursor/index.js +15 -3
  54. package/src/plugin/markers/index.js +40 -1
  55. package/src/plugin/regions/index.js +4 -0
  56. package/src/plugin/regions/region.js +76 -1
  57. package/src/util/silence-mode.js +7 -0
  58. package/src/wavesurfer.js +4 -0
  59. package/CHANGES.md +0 -482
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * wavesurfer.js timeline plugin 6.3.0 (2022-10-03)
2
+ * wavesurfer.js timeline plugin 6.5.0 (2023-03-11)
3
3
  * https://wavesurfer-js.org
4
4
  * @license BSD-3-Clause
5
5
  */
@@ -29,15 +29,13 @@ Object.defineProperty(exports, "__esModule", ({
29
29
  value: true
30
30
  }));
31
31
  exports["default"] = void 0;
32
-
32
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
33
33
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
34
-
35
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
36
-
34
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
37
35
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
38
-
39
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
40
-
36
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
37
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
38
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
41
39
  /**
42
40
  * @typedef {Object} TimelinePluginParams
43
41
  * @desc Extends the `WavesurferParams` wavesurfer was initialised with
@@ -71,7 +69,6 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
71
69
  * @property {?boolean} deferInit Set to true to manually call
72
70
  * `initPlugin('timeline')`
73
71
  */
74
-
75
72
  /**
76
73
  * Adds a timeline to the waveform.
77
74
  *
@@ -108,46 +105,44 @@ var TimelinePlugin = /*#__PURE__*/function () {
108
105
  */
109
106
  function TimelinePlugin(params, _ws) {
110
107
  var _this = this;
111
-
112
108
  _classCallCheck(this, TimelinePlugin);
113
-
109
+ // event handlers
114
110
  _defineProperty(this, "_onScroll", function () {
115
111
  if (_this.wrapper && _this.drawer.wrapper) {
116
112
  _this.wrapper.scrollLeft = _this.drawer.wrapper.scrollLeft;
117
113
  }
118
114
  });
119
-
115
+ /**
116
+ * @returns {void}
117
+ */
120
118
  _defineProperty(this, "_onRedraw", function () {
121
119
  return _this.render();
122
120
  });
123
-
124
121
  _defineProperty(this, "_onReady", function () {
125
122
  var ws = _this.wavesurfer;
126
123
  _this.drawer = ws.drawer;
127
124
  _this.pixelRatio = ws.drawer.params.pixelRatio;
128
125
  _this.maxCanvasWidth = ws.drawer.maxCanvasWidth || ws.drawer.width;
129
- _this.maxCanvasElementWidth = ws.drawer.maxCanvasElementWidth || Math.round(_this.maxCanvasWidth / _this.pixelRatio); // add listeners
126
+ _this.maxCanvasElementWidth = ws.drawer.maxCanvasElementWidth || Math.round(_this.maxCanvasWidth / _this.pixelRatio);
130
127
 
128
+ // add listeners
131
129
  ws.drawer.wrapper.addEventListener('scroll', _this._onScroll);
132
130
  ws.on('redraw', _this._onRedraw);
133
131
  ws.on('zoom', _this._onZoom);
134
-
135
132
  _this.render();
136
133
  });
137
-
134
+ /**
135
+ * @param {object} e Click event
136
+ */
138
137
  _defineProperty(this, "_onWrapperClick", function (e) {
139
138
  e.preventDefault();
140
139
  var relX = 'offsetX' in e ? e.offsetX : e.layerX;
141
-
142
140
  _this.fireEvent('click', relX / _this.wrapper.scrollWidth || 0);
143
141
  });
144
-
145
142
  this.container = 'string' == typeof params.container ? document.querySelector(params.container) : params.container;
146
-
147
143
  if (!this.container) {
148
144
  throw new Error('No container for wavesurfer timeline');
149
145
  }
150
-
151
146
  this.wavesurfer = _ws;
152
147
  this.util = _ws.util;
153
148
  this.params = Object.assign({}, {
@@ -184,18 +179,16 @@ var TimelinePlugin = /*#__PURE__*/function () {
184
179
  *
185
180
  * @returns {void}
186
181
  */
187
-
188
182
  this._onZoom = this.params.zoomDebounce ? this.wavesurfer.util.debounce(function () {
189
183
  return _this.render();
190
184
  }, this.params.zoomDebounce) : function () {
191
185
  return _this.render();
192
186
  };
193
187
  }
188
+
194
189
  /**
195
190
  * Initialisation function used by the plugin API
196
191
  */
197
-
198
-
199
192
  _createClass(TimelinePlugin, [{
200
193
  key: "init",
201
194
  value: function init() {
@@ -206,10 +199,10 @@ var TimelinePlugin = /*#__PURE__*/function () {
206
199
  this.wavesurfer.once('ready', this._onReady);
207
200
  }
208
201
  }
202
+
209
203
  /**
210
204
  * Destroy function used by the plugin API
211
205
  */
212
-
213
206
  }, {
214
207
  key: "destroy",
215
208
  value: function destroy() {
@@ -218,18 +211,17 @@ var TimelinePlugin = /*#__PURE__*/function () {
218
211
  this.wavesurfer.un('zoom', this._onZoom);
219
212
  this.wavesurfer.un('ready', this._onReady);
220
213
  this.wavesurfer.drawer.wrapper.removeEventListener('scroll', this._onScroll);
221
-
222
214
  if (this.wrapper && this.wrapper.parentNode) {
223
215
  this.wrapper.removeEventListener('click', this._onWrapperClick);
224
216
  this.wrapper.parentNode.removeChild(this.wrapper);
225
217
  this.wrapper = null;
226
218
  }
227
219
  }
220
+
228
221
  /**
229
222
  * Create a timeline element to wrap the canvases drawn by this plugin
230
223
  *
231
224
  */
232
-
233
225
  }, {
234
226
  key: "createWrapper",
235
227
  value: function createWrapper() {
@@ -243,7 +235,6 @@ var TimelinePlugin = /*#__PURE__*/function () {
243
235
  webkitUserSelect: 'none',
244
236
  height: "".concat(this.params.height, "px")
245
237
  });
246
-
247
238
  if (wsParams.fillParent || wsParams.scrollParent) {
248
239
  this.util.style(this.wrapper, {
249
240
  width: '100%',
@@ -251,30 +242,28 @@ var TimelinePlugin = /*#__PURE__*/function () {
251
242
  overflowY: 'hidden'
252
243
  });
253
244
  }
254
-
255
245
  this.wrapper.addEventListener('click', this._onWrapperClick);
256
246
  }
247
+
257
248
  /**
258
249
  * Render the timeline (also updates the already rendered timeline)
259
250
  *
260
251
  */
261
-
262
252
  }, {
263
253
  key: "render",
264
254
  value: function render() {
265
255
  if (!this.wrapper) {
266
256
  this.createWrapper();
267
257
  }
268
-
269
258
  this.updateCanvases();
270
259
  this.updateCanvasesPositioning();
271
260
  this.renderCanvases();
272
261
  }
262
+
273
263
  /**
274
264
  * Add new timeline canvas
275
265
  *
276
266
  */
277
-
278
267
  }, {
279
268
  key: "addCanvas",
280
269
  value: function addCanvas() {
@@ -285,59 +274,55 @@ var TimelinePlugin = /*#__PURE__*/function () {
285
274
  zIndex: 4
286
275
  });
287
276
  }
277
+
288
278
  /**
289
279
  * Remove timeline canvas
290
280
  *
291
281
  */
292
-
293
282
  }, {
294
283
  key: "removeCanvas",
295
284
  value: function removeCanvas() {
296
285
  var canvas = this.canvases.pop();
297
286
  canvas.parentElement.removeChild(canvas);
298
287
  }
288
+
299
289
  /**
300
290
  * Make sure the correct of timeline canvas elements exist and are cached in
301
291
  * this.canvases
302
292
  *
303
293
  */
304
-
305
294
  }, {
306
295
  key: "updateCanvases",
307
296
  value: function updateCanvases() {
308
297
  var totalWidth = Math.round(this.drawer.wrapper.scrollWidth);
309
298
  var requiredCanvases = Math.ceil(totalWidth / this.maxCanvasElementWidth);
310
-
311
299
  while (this.canvases.length < requiredCanvases) {
312
300
  this.addCanvas();
313
301
  }
314
-
315
302
  while (this.canvases.length > requiredCanvases) {
316
303
  this.removeCanvas();
317
304
  }
318
305
  }
306
+
319
307
  /**
320
308
  * Update the dimensions and positioning style for all the timeline canvases
321
309
  *
322
310
  */
323
-
324
311
  }, {
325
312
  key: "updateCanvasesPositioning",
326
313
  value: function updateCanvasesPositioning() {
327
314
  var _this2 = this;
328
-
329
315
  // cache length for performance
330
316
  var canvasesLength = this.canvases.length;
331
317
  this.canvases.forEach(function (canvas, i) {
332
318
  // canvas width is the max element width, or if it is the last the
333
319
  // required width
334
- var canvasWidth = i === canvasesLength - 1 ? _this2.drawer.wrapper.scrollWidth - _this2.maxCanvasElementWidth * (canvasesLength - 1) : _this2.maxCanvasElementWidth; // set dimensions and style
335
-
336
- canvas.width = canvasWidth * _this2.pixelRatio; // on certain pixel ratios the canvas appears cut off at the bottom,
320
+ var canvasWidth = i === canvasesLength - 1 ? _this2.drawer.wrapper.scrollWidth - _this2.maxCanvasElementWidth * (canvasesLength - 1) : _this2.maxCanvasElementWidth;
321
+ // set dimensions and style
322
+ canvas.width = canvasWidth * _this2.pixelRatio;
323
+ // on certain pixel ratios the canvas appears cut off at the bottom,
337
324
  // therefore leave 1px extra
338
-
339
325
  canvas.height = (_this2.params.height + 1) * _this2.pixelRatio;
340
-
341
326
  _this2.util.style(canvas, {
342
327
  width: "".concat(canvasWidth, "px"),
343
328
  height: "".concat(_this2.params.height, "px"),
@@ -345,22 +330,19 @@ var TimelinePlugin = /*#__PURE__*/function () {
345
330
  });
346
331
  });
347
332
  }
333
+
348
334
  /**
349
335
  * Render the timeline labels and notches
350
336
  *
351
337
  */
352
-
353
338
  }, {
354
339
  key: "renderCanvases",
355
340
  value: function renderCanvases() {
356
341
  var _this3 = this;
357
-
358
342
  var duration = this.params.duration || this.wavesurfer.backend.getDuration();
359
-
360
343
  if (duration <= 0) {
361
344
  return;
362
345
  }
363
-
364
346
  var wsParams = this.wavesurfer.params;
365
347
  var fontSize = this.params.fontSize * wsParams.pixelRatio;
366
348
  var totalSeconds = parseInt(duration, 10) + 1;
@@ -368,61 +350,60 @@ var TimelinePlugin = /*#__PURE__*/function () {
368
350
  var height1 = this.params.height * this.pixelRatio;
369
351
  var height2 = this.params.height * (this.params.notchPercentHeight / 100) * this.pixelRatio;
370
352
  var pixelsPerSecond = width / duration;
371
- var formatTime = this.params.formatTimeCallback; // if parameter is function, call the function with
353
+ var formatTime = this.params.formatTimeCallback;
354
+ // if parameter is function, call the function with
372
355
  // pixelsPerSecond, otherwise simply take the value as-is
373
-
374
356
  var intervalFnOrVal = function intervalFnOrVal(option) {
375
357
  return typeof option === 'function' ? option(pixelsPerSecond) : option;
376
358
  };
377
-
378
359
  var timeInterval = intervalFnOrVal(this.params.timeInterval);
379
360
  var primaryLabelInterval = intervalFnOrVal(this.params.primaryLabelInterval);
380
361
  var secondaryLabelInterval = intervalFnOrVal(this.params.secondaryLabelInterval);
381
362
  var curPixel = pixelsPerSecond * this.params.offset;
382
363
  var curSeconds = 0;
383
- var i; // build an array of position data with index, second and pixel data,
364
+ var i;
365
+ // build an array of position data with index, second and pixel data,
384
366
  // this is then used multiple times below
367
+ var positioning = [];
385
368
 
386
- var positioning = []; // render until end in case we have a negative offset
387
-
369
+ // render until end in case we have a negative offset
388
370
  var renderSeconds = this.params.offset < 0 ? totalSeconds - this.params.offset : totalSeconds;
389
-
390
371
  for (i = 0; i < renderSeconds / timeInterval; i++) {
391
372
  positioning.push([i, curSeconds, curPixel]);
392
373
  curSeconds += timeInterval;
393
374
  curPixel += pixelsPerSecond * timeInterval;
394
- } // iterate over each position
395
-
375
+ }
396
376
 
377
+ // iterate over each position
397
378
  var renderPositions = function renderPositions(cb) {
398
379
  positioning.forEach(function (pos) {
399
380
  cb(pos[0], pos[1], pos[2]);
400
381
  });
401
- }; // render primary labels
402
-
382
+ };
403
383
 
384
+ // render primary labels
404
385
  this.setFillStyles(this.params.primaryColor);
405
386
  this.setFonts("".concat(fontSize, "px ").concat(this.params.fontFamily));
406
387
  this.setFillStyles(this.params.primaryFontColor);
407
388
  renderPositions(function (i, curSeconds, curPixel) {
408
389
  if (i % primaryLabelInterval === 0) {
409
390
  _this3.fillRect(curPixel, 0, 1, height1);
410
-
411
391
  _this3.fillText(formatTime(curSeconds, pixelsPerSecond), curPixel + _this3.params.labelPadding * _this3.pixelRatio, height1);
412
392
  }
413
- }); // render secondary labels
393
+ });
414
394
 
395
+ // render secondary labels
415
396
  this.setFillStyles(this.params.secondaryColor);
416
397
  this.setFonts("".concat(fontSize, "px ").concat(this.params.fontFamily));
417
398
  this.setFillStyles(this.params.secondaryFontColor);
418
399
  renderPositions(function (i, curSeconds, curPixel) {
419
400
  if (i % secondaryLabelInterval === 0) {
420
401
  _this3.fillRect(curPixel, 0, 1, height1);
421
-
422
402
  _this3.fillText(formatTime(curSeconds, pixelsPerSecond), curPixel + _this3.params.labelPadding * _this3.pixelRatio, height1);
423
403
  }
424
- }); // render the actual notches (when no labels are used)
404
+ });
425
405
 
406
+ // render the actual notches (when no labels are used)
426
407
  this.setFillStyles(this.params.unlabeledNotchColor);
427
408
  renderPositions(function (i, curSeconds, curPixel) {
428
409
  if (i % secondaryLabelInterval !== 0 && i % primaryLabelInterval !== 0) {
@@ -430,41 +411,40 @@ var TimelinePlugin = /*#__PURE__*/function () {
430
411
  }
431
412
  });
432
413
  }
414
+
433
415
  /**
434
416
  * Set the canvas fill style
435
417
  *
436
418
  * @param {DOMString|CanvasGradient|CanvasPattern} fillStyle Fill style to
437
419
  * use
438
420
  */
439
-
440
421
  }, {
441
422
  key: "setFillStyles",
442
423
  value: function setFillStyles(fillStyle) {
443
424
  this.canvases.forEach(function (canvas) {
444
425
  var context = canvas.getContext('2d');
445
-
446
426
  if (context) {
447
427
  context.fillStyle = fillStyle;
448
428
  }
449
429
  });
450
430
  }
431
+
451
432
  /**
452
433
  * Set the canvas font
453
434
  *
454
435
  * @param {DOMString} font Font to use
455
436
  */
456
-
457
437
  }, {
458
438
  key: "setFonts",
459
439
  value: function setFonts(font) {
460
440
  this.canvases.forEach(function (canvas) {
461
441
  var context = canvas.getContext('2d');
462
-
463
442
  if (context) {
464
443
  context.font = font;
465
444
  }
466
445
  });
467
446
  }
447
+
468
448
  /**
469
449
  * Draw a rectangle on the canvases
470
450
  *
@@ -475,12 +455,10 @@ var TimelinePlugin = /*#__PURE__*/function () {
475
455
  * @param {number} width Width
476
456
  * @param {number} height Height
477
457
  */
478
-
479
458
  }, {
480
459
  key: "fillRect",
481
460
  value: function fillRect(x, y, width, height) {
482
461
  var _this4 = this;
483
-
484
462
  this.canvases.forEach(function (canvas, i) {
485
463
  var leftOffset = i * _this4.maxCanvasWidth;
486
464
  var intersection = {
@@ -489,16 +467,15 @@ var TimelinePlugin = /*#__PURE__*/function () {
489
467
  x2: Math.min(x + width, i * _this4.maxCanvasWidth + canvas.width),
490
468
  y2: y + height
491
469
  };
492
-
493
470
  if (intersection.x1 < intersection.x2) {
494
471
  var context = canvas.getContext('2d');
495
-
496
472
  if (context) {
497
473
  context.fillRect(intersection.x1 - leftOffset, intersection.y1, intersection.x2 - intersection.x1, intersection.y2 - intersection.y1);
498
474
  }
499
475
  }
500
476
  });
501
477
  }
478
+
502
479
  /**
503
480
  * Fill a given text on the canvases
504
481
  *
@@ -506,7 +483,6 @@ var TimelinePlugin = /*#__PURE__*/function () {
506
483
  * @param {number} x X-position
507
484
  * @param {number} y Y-position
508
485
  */
509
-
510
486
  }, {
511
487
  key: "fillText",
512
488
  value: function fillText(text, x, y) {
@@ -514,23 +490,20 @@ var TimelinePlugin = /*#__PURE__*/function () {
514
490
  var xOffset = 0;
515
491
  this.canvases.forEach(function (canvas) {
516
492
  var context = canvas.getContext('2d');
517
-
518
493
  if (context) {
519
494
  var canvasWidth = context.canvas.width;
520
-
521
495
  if (xOffset > x + textWidth) {
522
496
  return;
523
497
  }
524
-
525
498
  if (xOffset + canvasWidth > x && context) {
526
499
  textWidth = context.measureText(text).width;
527
500
  context.fillText(text, x - xOffset, y);
528
501
  }
529
-
530
502
  xOffset += canvasWidth;
531
503
  }
532
504
  });
533
505
  }
506
+
534
507
  /**
535
508
  * Turn the time into a suitable label for the time.
536
509
  *
@@ -538,28 +511,26 @@ var TimelinePlugin = /*#__PURE__*/function () {
538
511
  * @param {number} pxPerSec Pixels per second
539
512
  * @returns {number} Time
540
513
  */
541
-
542
514
  }, {
543
515
  key: "defaultFormatTimeCallback",
544
516
  value: function defaultFormatTimeCallback(seconds, pxPerSec) {
545
517
  if (seconds / 60 > 1) {
546
518
  // calculate minutes and seconds from seconds count
547
519
  var minutes = parseInt(seconds / 60, 10);
548
- seconds = parseInt(seconds % 60, 10); // fill up seconds with zeroes
549
-
520
+ seconds = parseInt(seconds % 60, 10);
521
+ // fill up seconds with zeroes
550
522
  seconds = seconds < 10 ? '0' + seconds : seconds;
551
523
  return "".concat(minutes, ":").concat(seconds);
552
524
  }
553
-
554
525
  return Math.round(seconds * 1000) / 1000;
555
526
  }
527
+
556
528
  /**
557
529
  * Return how many seconds should be between each notch
558
530
  *
559
531
  * @param {number} pxPerSec Pixels per second
560
532
  * @returns {number} Time
561
533
  */
562
-
563
534
  }, {
564
535
  key: "defaultTimeInterval",
565
536
  value: function defaultTimeInterval(pxPerSec) {
@@ -570,16 +541,15 @@ var TimelinePlugin = /*#__PURE__*/function () {
570
541
  } else if (pxPerSec * 15 >= 25) {
571
542
  return 15;
572
543
  }
573
-
574
544
  return Math.ceil(0.5 / pxPerSec) * 60;
575
545
  }
546
+
576
547
  /**
577
548
  * Return the cadence of notches that get labels in the primary color.
578
549
  *
579
550
  * @param {number} pxPerSec Pixels per second
580
551
  * @returns {number} Cadence
581
552
  */
582
-
583
553
  }, {
584
554
  key: "defaultPrimaryLabelInterval",
585
555
  value: function defaultPrimaryLabelInterval(pxPerSec) {
@@ -590,16 +560,15 @@ var TimelinePlugin = /*#__PURE__*/function () {
590
560
  } else if (pxPerSec * 15 >= 25) {
591
561
  return 4;
592
562
  }
593
-
594
563
  return 4;
595
564
  }
565
+
596
566
  /**
597
567
  * Return the cadence of notches that get labels in the secondary color.
598
568
  *
599
569
  * @param {number} pxPerSec Pixels per second
600
570
  * @returns {number} Cadence
601
571
  */
602
-
603
572
  }, {
604
573
  key: "defaultSecondaryLabelInterval",
605
574
  value: function defaultSecondaryLabelInterval(pxPerSec) {
@@ -610,7 +579,6 @@ var TimelinePlugin = /*#__PURE__*/function () {
610
579
  } else if (pxPerSec * 15 >= 25) {
611
580
  return 2;
612
581
  }
613
-
614
582
  return 2;
615
583
  }
616
584
  }], [{
@@ -632,13 +600,10 @@ var TimelinePlugin = /*#__PURE__*/function () {
632
600
  params: params,
633
601
  instance: TimelinePlugin
634
602
  };
635
- } // event handlers
636
-
603
+ }
637
604
  }]);
638
-
639
605
  return TimelinePlugin;
640
606
  }();
641
-
642
607
  exports["default"] = TimelinePlugin;
643
608
  module.exports = exports.default;
644
609