@checksub_team/peaks_timeline 1.16.1 → 2.0.0-alpha.10

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 (37) hide show
  1. package/package.json +1 -1
  2. package/peaks.js +4691 -4380
  3. package/peaks.js.d.ts +5 -5
  4. package/src/{timeline-axis.js → components/axis.js} +244 -244
  5. package/src/{data-retriever.js → components/data-retriever.js} +117 -117
  6. package/src/{default-segment-marker.js → components/default-segment-marker.js} +132 -132
  7. package/src/{invoker.js → components/invoker.js} +81 -81
  8. package/src/components/line-group.js +696 -0
  9. package/src/components/line-groups.js +591 -0
  10. package/src/{line-indicator.js → components/line-indicator.js} +313 -303
  11. package/src/{marker-factories.js → components/marker-factories.js} +1 -1
  12. package/src/{mode-layer.js → components/mode-layer.js} +8 -12
  13. package/src/{playhead-layer.js → components/playhead-layer.js} +3 -3
  14. package/src/{segment-marker.js → components/segment-marker.js} +2 -2
  15. package/src/{segment-shape.js → components/segment-shape.js} +508 -508
  16. package/src/{segments-group.js → components/segments-group.js} +805 -801
  17. package/src/{source-group.js → components/source-group.js} +1663 -1640
  18. package/src/{sources-layer.js → components/sources-layer.js} +722 -730
  19. package/src/{waveform-builder.js → components/waveform-builder.js} +2 -2
  20. package/src/{waveform-shape.js → components/waveform-shape.js} +214 -214
  21. package/src/keyboard-handler.js +9 -9
  22. package/src/line-handler.js +180 -0
  23. package/src/main.js +109 -82
  24. package/src/models/line.js +156 -0
  25. package/src/{segment.js → models/segment.js} +420 -419
  26. package/src/{source.js → models/source.js} +1311 -1315
  27. package/src/player.js +2 -2
  28. package/src/{timeline-segments.js → segment-handler.js} +435 -435
  29. package/src/{timeline-sources.js → source-handler.js} +521 -514
  30. package/src/utils.js +5 -1
  31. package/src/{timeline-zoomview.js → view.js} +136 -143
  32. package/src/line.js +0 -690
  33. package/src/lines.js +0 -427
  34. /package/src/{data.js → components/data.js} +0 -0
  35. /package/src/{loader.js → components/loader.js} +0 -0
  36. /package/src/{mouse-drag-handler.js → components/mouse-drag-handler.js} +0 -0
  37. /package/src/{svgs.js → components/svgs.js} +0 -0
@@ -1,17 +1,17 @@
1
1
  /**
2
2
  * @file
3
3
  *
4
- * Defines the {@link TimelineZoomView} class.
4
+ * Defines the {@link View} class.
5
5
  *
6
- * @module timeline-zoomview
6
+ * @module view
7
7
  */
8
8
 
9
9
  define([
10
- './mouse-drag-handler',
11
- './playhead-layer',
12
- './sources-layer',
13
- './mode-layer',
14
- './timeline-axis',
10
+ './components/mouse-drag-handler',
11
+ './components/playhead-layer',
12
+ './components/sources-layer',
13
+ './components/mode-layer',
14
+ './components/axis',
15
15
  './utils',
16
16
  'konva'
17
17
  ], function(
@@ -19,7 +19,7 @@ define([
19
19
  PlayheadLayer,
20
20
  SourcesLayer,
21
21
  ModeLayer,
22
- TimelineAxis,
22
+ Axis,
23
23
  Utils,
24
24
  Konva) {
25
25
  'use strict';
@@ -28,13 +28,13 @@ define([
28
28
  * Creates a zoomable timeline view.
29
29
  *
30
30
  * @class
31
- * @alias TimelineZoomView
31
+ * @alias View
32
32
  *
33
33
  * @param {HTMLElement} container
34
34
  * @param {Peaks} peaks
35
35
  */
36
36
 
37
- function TimelineZoomView(container, peaks) {
37
+ function View(container, peaks) {
38
38
  var self = this;
39
39
 
40
40
  self._container = container;
@@ -54,20 +54,22 @@ define([
54
54
  self._onCutMode = self._onCutMode.bind(self);
55
55
 
56
56
  // Register event handlers
57
- self._peaks.on('timeline.update', self._onTimeUpdate);
58
- self._peaks.on('timeline.seek', self._onTimeUpdate);
57
+ self._peaks.on('main.overrideInteractions', self.overrideInteractions.bind(self));
58
+ self._peaks.on('main.allowInteractions', self.allowInteractions.bind(self));
59
+ self._peaks.on('handler.player.update', self._onTimeUpdate);
60
+ self._peaks.on('handler.player.seek', self._onTimeUpdate);
59
61
  self._peaks.on('playhead.drag', self._onTimeUpdate);
60
62
  self._peaks.on('playhead.dragend', self._onTimeUpdate);
61
63
  self._peaks.on('user_seek', self._onSeek);
62
64
  self._peaks.on('timeline.play', self._onPlay);
63
65
  self._peaks.on('timeline.pause', self._onPause);
64
66
  self._peaks.on('window_resize', self._onWindowResize);
65
- self._peaks.on('keyboard.left', self._onKeyboardLeft);
66
- self._peaks.on('keyboard.right', self._onKeyboardRight);
67
- self._peaks.on('keyboard.shift_left', self._onKeyboardShiftLeft);
68
- self._peaks.on('keyboard.shift_right', self._onKeyboardShiftRight);
69
- self._peaks.on('default_mode', self._onDefaultMode);
70
- self._peaks.on('cut_mode', self._onCutMode);
67
+ self._peaks.on('handler.keyboard.left', self._onKeyboardLeft);
68
+ self._peaks.on('handler.keyboard.right', self._onKeyboardRight);
69
+ self._peaks.on('handler.keyboard.shiftleft', self._onKeyboardShiftLeft);
70
+ self._peaks.on('handler.keyboard.shiftright', self._onKeyboardShiftRight);
71
+ self._peaks.on('handler.view.defaultmode', self._onDefaultMode);
72
+ self._peaks.on('handler.view.cutmode', self._onCutMode);
71
73
 
72
74
  self._enableAutoScroll = true;
73
75
  self._amplitudeScale = 1.0;
@@ -77,7 +79,6 @@ define([
77
79
  self._timeToPixelsScale = self._options.initialZoomLevel;
78
80
  self._timeToPixelsMinScale = self._options.minScale;
79
81
 
80
- self._resizeTimeoutId = null;
81
82
  self._isFocused = false;
82
83
  self._isClickable = true;
83
84
 
@@ -118,9 +119,11 @@ define([
118
119
  height: self._height
119
120
  });
120
121
 
122
+ self._tempGroup = new Konva.Group({ listening: false });
123
+
121
124
  self._width -= self._peaks.options.lineIndicatorWidth;
122
125
 
123
- self._axis = new TimelineAxis(self._peaks, self, {
126
+ self._axis = new Axis(self._peaks, self, {
124
127
  axisGridlineColor: this._options.axisGridlineColor,
125
128
  axisLabelColor: this._options.axisLabelColor
126
129
  });
@@ -130,6 +133,8 @@ define([
130
133
  self._sourcesLayer = new SourcesLayer(peaks, self, true);
131
134
  self._sourcesLayer.addToStage(self._stage);
132
135
 
136
+ self._sourcesLayer.add(self._tempGroup);
137
+
133
138
  self._axis.addFrontToStage(self._stage);
134
139
 
135
140
  self._playheadLayer = new PlayheadLayer(
@@ -173,7 +178,7 @@ define([
173
178
  );
174
179
  }
175
180
 
176
- var height = self._sourcesLayer._lines.height() - self._height;
181
+ var height = self._sourcesLayer.getFullHeight() - self._height;
177
182
  var newFrameOffsetY = 0;
178
183
 
179
184
  if (self._peaks.options.enableVerticalScrolling && height > 0) {
@@ -182,7 +187,7 @@ define([
182
187
  );
183
188
  }
184
189
  else {
185
- self._frameOffsetY = 0;
190
+ self.setFrameOffsetY(0);
186
191
  }
187
192
 
188
193
  if ((newFrameOffset !== this.initialFrameOffset)
@@ -214,7 +219,7 @@ define([
214
219
  return;
215
220
  }
216
221
 
217
- self._peaks.emit('zoomview.click', event);
222
+ self._peaks.emit('handler.view.click', event);
218
223
  // Set playhead position only on click release, when not dragging.
219
224
  if (self._modeLayer.getCurrentMode() === 'default' && !self._mouseDragHandler.isDragging()) {
220
225
  var mouseDownX = Math.floor(self._stage.getPointerPosition().x);
@@ -229,7 +234,7 @@ define([
229
234
  self._peaks.player.seek(time);
230
235
  }
231
236
 
232
- self._peaks.emit('zoomview.updateTime', event, time);
237
+ self._peaks.emit('handler.view.updateTime', event, time);
233
238
  }
234
239
  });
235
240
 
@@ -240,7 +245,7 @@ define([
240
245
 
241
246
  var time = self.pixelsToTime(pixelIndex);
242
247
 
243
- self._peaks.emit('zoomview.dblclick', time);
248
+ self._peaks.emit('handler.view.dblclick', time);
244
249
  });
245
250
 
246
251
  this._stage.on('wheel', function(e) {
@@ -277,7 +282,7 @@ define([
277
282
  );
278
283
  }
279
284
 
280
- var height = self._sourcesLayer._lines.height() - self._height;
285
+ var height = self._sourcesLayer.getFullHeight() - self._height;
281
286
  var newFrameOffsetY = 0;
282
287
 
283
288
  if (self._peaks.options.enableVerticalScrolling && height > 0) {
@@ -286,7 +291,7 @@ define([
286
291
  );
287
292
  }
288
293
  else {
289
- self._frameOffsetY = 0;
294
+ self.setFrameOffsetY(0);
290
295
  }
291
296
 
292
297
  if ((newFrameOffset !== self.getFrameOffset())
@@ -304,19 +309,23 @@ define([
304
309
  window.addEventListener('blur', this._mouseUp.bind(this), false);
305
310
  }
306
311
 
307
- TimelineZoomView.prototype._mouseUp = function() {
312
+ View.prototype._mouseUp = function() {
308
313
  this.clearScrollingInterval();
309
314
  };
310
315
 
311
- TimelineZoomView.prototype.setClickable = function(clickable) {
316
+ View.prototype.setClickable = function(clickable) {
312
317
  this._isClickable = clickable;
313
318
  };
314
319
 
315
- TimelineZoomView.prototype.getSelectedElements = function() {
320
+ View.prototype.getTempGroup = function() {
321
+ return this._tempGroup;
322
+ };
323
+
324
+ View.prototype.getSelectedElements = function() {
316
325
  return Object.values(this._modeLayer.getSelectedElements());
317
326
  };
318
327
 
319
- TimelineZoomView.prototype.updateWithAutoScroll = function(updateInInterval,
328
+ View.prototype.updateWithAutoScroll = function(updateInInterval,
320
329
  updateOutInterval) {
321
330
  var self = this;
322
331
  var posX = this.getPointerPosition().x;
@@ -340,12 +349,12 @@ define([
340
349
  var newOffset = self.getFrameOffset() + self._limited;
341
350
 
342
351
  if (newOffset < 0) {
343
- self.updateTimeline(0, null, false);
352
+ self.updateTimeline(0);
344
353
  clearInterval(self._scrollingInterval);
345
354
  self._scrollingInterval = null;
346
355
  }
347
356
  else {
348
- self.updateTimeline(self.getFrameOffset() + self._limited, null, false);
357
+ self.updateTimeline(self.getFrameOffset() + self._limited);
349
358
  }
350
359
 
351
360
  updateInInterval();
@@ -366,39 +375,37 @@ define([
366
375
  }
367
376
  };
368
377
 
369
- TimelineZoomView.prototype.clearScrollingInterval = function() {
378
+ View.prototype.clearScrollingInterval = function() {
370
379
  if (this._scrollingInterval) {
371
380
  clearInterval(this._scrollingInterval);
372
381
  this._scrollingInterval = null;
373
382
  }
374
383
  };
375
384
 
376
- TimelineZoomView.prototype.getCurrentMode = function() {
385
+ View.prototype.getCurrentMode = function() {
377
386
  return this._modeLayer.getCurrentMode();
378
387
  };
379
388
 
380
- TimelineZoomView.prototype.overrideInteractions = function(bool, areInteractionsAllowed) {
381
- this._sourcesLayer._lines.overrideInteractions(bool, areInteractionsAllowed);
389
+ View.prototype.overrideInteractions = function(areInteractionsAllowed) {
382
390
  this._playheadLayer.listening(areInteractionsAllowed);
383
391
  this._sourcesLayer.stopDrag();
384
392
  this._sourcesLayer.draw();
385
393
  };
386
394
 
387
- TimelineZoomView.prototype.allowInteractions = function(forSources, forSegments) {
388
- this._sourcesLayer._lines.allowInteractions(forSources, forSegments);
395
+ View.prototype.allowInteractions = function() {
389
396
  this._sourcesLayer.stopDrag();
390
397
  this._sourcesLayer.draw();
391
398
  };
392
399
 
393
- TimelineZoomView.prototype.getSelectedElements = function() {
400
+ View.prototype.getSelectedElements = function() {
394
401
  return this._modeLayer.getSelectedElements();
395
402
  };
396
403
 
397
- TimelineZoomView.prototype.getSourceGroupById = function(sourceId) {
404
+ View.prototype.getSourceGroupById = function(sourceId) {
398
405
  return this._sourcesLayer.getSourceGroupById(sourceId);
399
406
  };
400
407
 
401
- TimelineZoomView.prototype.selectSourceById = function(sourceId) {
408
+ View.prototype.selectSourceById = function(sourceId) {
402
409
  const sourceGroup = this._sourcesLayer.getSourceGroupById(sourceId);
403
410
 
404
411
  if (sourceGroup) {
@@ -406,7 +413,7 @@ define([
406
413
  }
407
414
  };
408
415
 
409
- TimelineZoomView.prototype.selectSourcesOnLineAfter = function(lineId, time) {
416
+ View.prototype.selectSourcesOnLineAfter = function(lineId, time) {
410
417
  const sources = this._sourcesLayer.getSourcesOnLineAfter(lineId, time);
411
418
 
412
419
  if (sources) {
@@ -414,50 +421,54 @@ define([
414
421
  }
415
422
  };
416
423
 
417
- TimelineZoomView.prototype.deselectAll = function(notify) {
424
+ View.prototype.deselectAll = function(notify) {
418
425
  this._modeLayer.deselectDifference([], notify);
419
426
  };
420
427
 
421
- TimelineZoomView.prototype.isListening = function() {
428
+ View.prototype.isListening = function() {
422
429
  return this._stage.listening();
423
430
  };
424
431
 
425
- TimelineZoomView.prototype.isFocused = function() {
432
+ View.prototype.isFocused = function() {
426
433
  return this._isFocused;
427
434
  };
428
435
 
429
- TimelineZoomView.prototype.drawSourcesLayer = function() {
436
+ View.prototype.drawSourcesLayer = function() {
430
437
  this._sourcesLayer.draw();
431
438
  };
432
439
 
433
- TimelineZoomView.prototype.getSegmentsGroup = function() {
440
+ View.prototype.refresh = function() {
441
+ this._sourcesLayer.refresh();
442
+ };
443
+
444
+ View.prototype.getSegmentsGroup = function() {
434
445
  return this._sourcesLayer.getSegmentsGroup();
435
446
  };
436
447
 
437
- TimelineZoomView.prototype.getTimeToPixelsScale = function() {
448
+ View.prototype.getTimeToPixelsScale = function() {
438
449
  return this._timeToPixelsScale;
439
450
  };
440
451
 
441
- TimelineZoomView.prototype.getTimeToPixelsMaxZoom = function() {
452
+ View.prototype.getTimeToPixelsMaxZoom = function() {
442
453
  return this._options.zoomRange[1];
443
454
  };
444
455
 
445
- TimelineZoomView.prototype.setTimeToPixelsMaxZoom = function(value) {
456
+ View.prototype.setTimeToPixelsMaxZoom = function(value) {
446
457
  this._options.zoomRange[1] = value;
447
458
  if (value < this._timeToPixelsScale) {
448
459
  this.setZoom(value);
449
460
  }
450
461
  };
451
462
 
452
- TimelineZoomView.prototype.getTimeToPixelsMinScale = function() {
463
+ View.prototype.getTimeToPixelsMinScale = function() {
453
464
  return this._timeToPixelsMinScale;
454
465
  };
455
466
 
456
- TimelineZoomView.prototype.getName = function() {
467
+ View.prototype.getName = function() {
457
468
  return 'zoomview';
458
469
  };
459
470
 
460
- TimelineZoomView.prototype._onTimeUpdate = function(time) {
471
+ View.prototype._onTimeUpdate = function(time) {
461
472
  if (this._mouseDragHandler.isDragging()) {
462
473
  return;
463
474
  }
@@ -465,24 +476,24 @@ define([
465
476
  this._syncPlayhead(time);
466
477
  };
467
478
 
468
- TimelineZoomView.prototype._onSeek = function(time) {
479
+ View.prototype._onSeek = function(time) {
469
480
  var frameIndex = this.timeToPixels(time);
470
481
 
471
482
  this.updateTimeline(frameIndex - Math.floor(this._width / 2));
472
483
  this._playheadLayer.updatePlayheadTime(time);
473
484
  };
474
485
 
475
- TimelineZoomView.prototype._onPlay = function(time) {
486
+ View.prototype._onPlay = function(time) {
476
487
  this._playheadLayer.updatePlayheadTime(time);
477
488
  this.enableAutoScroll(true);
478
489
  };
479
490
 
480
- TimelineZoomView.prototype._onPause = function(time) {
491
+ View.prototype._onPause = function(time) {
481
492
  this._playheadLayer.stop(time);
482
493
  this.enableAutoScroll(true);
483
494
  };
484
495
 
485
- TimelineZoomView.prototype._onWindowResize = function() {
496
+ View.prototype._onWindowResize = function() {
486
497
  var self = this;
487
498
 
488
499
  var width = self._container.clientWidth;
@@ -492,57 +503,57 @@ define([
492
503
  self.updateTimeline(self._frameOffset, self._frameOffsetY);
493
504
  };
494
505
 
495
- TimelineZoomView.prototype._onKeyboardLeft = function() {
506
+ View.prototype._onKeyboardLeft = function() {
496
507
  if (this.isFocused()) {
497
508
  this._keyboardScroll(-1, false);
498
509
  }
499
510
  };
500
511
 
501
- TimelineZoomView.prototype._onKeyboardRight = function() {
512
+ View.prototype._onKeyboardRight = function() {
502
513
  if (this.isFocused()) {
503
514
  this._keyboardScroll(1, false);
504
515
  }
505
516
  };
506
517
 
507
- TimelineZoomView.prototype._onKeyboardShiftLeft = function() {
518
+ View.prototype._onKeyboardShiftLeft = function() {
508
519
  if (this.isFocused()) {
509
520
  this._keyboardScroll(-1, true);
510
521
  }
511
522
  };
512
523
 
513
- TimelineZoomView.prototype._onKeyboardShiftRight = function() {
524
+ View.prototype._onKeyboardShiftRight = function() {
514
525
  if (this.isFocused()) {
515
526
  this._keyboardScroll(1, true);
516
527
  }
517
528
  };
518
529
 
519
- TimelineZoomView.prototype._onDefaultMode = function() {
530
+ View.prototype._onDefaultMode = function() {
520
531
  this.preventWrappingChange(false);
521
532
  this._modeLayer.setMode('default');
522
533
  };
523
534
 
524
- TimelineZoomView.prototype._onCutMode = function() {
535
+ View.prototype._onCutMode = function() {
525
536
  this.preventWrappingChange(true);
526
537
  this._modeLayer.setMode('cut');
527
538
  };
528
539
 
529
- TimelineZoomView.prototype.preventWrappingChange = function(bool) {
540
+ View.prototype.preventWrappingChange = function(bool) {
530
541
  this._preventWrappingChange = bool;
531
542
  };
532
543
 
533
- TimelineZoomView.prototype.isPreventingWrappingChange = function() {
544
+ View.prototype.isPreventingWrappingChange = function() {
534
545
  return this._preventWrappingChange;
535
546
  };
536
547
 
537
- TimelineZoomView.prototype.getHoveredElement = function() {
548
+ View.prototype.getHoveredElement = function() {
538
549
  return this._hoveredElement;
539
550
  };
540
551
 
541
- TimelineZoomView.prototype.setHoveredElement = function(element) {
552
+ View.prototype.setHoveredElement = function(element) {
542
553
  this._hoveredElement = element;
543
554
  };
544
555
 
545
- TimelineZoomView.prototype._keyboardScroll = function(direction, large) {
556
+ View.prototype._keyboardScroll = function(direction, large) {
546
557
  var increment;
547
558
 
548
559
  if (large) {
@@ -555,7 +566,7 @@ define([
555
566
  this.updateTimeline(this._frameOffset + increment);
556
567
  };
557
568
 
558
- TimelineZoomView.prototype._syncPlayhead = function(time) {
569
+ View.prototype._syncPlayhead = function(time) {
559
570
  this._playheadLayer.updatePlayheadTime(time);
560
571
 
561
572
  if (this._enableAutoScroll) {
@@ -578,7 +589,7 @@ define([
578
589
  }
579
590
  };
580
591
 
581
- TimelineZoomView.prototype.showPlayhead = function() {
592
+ View.prototype.showPlayhead = function() {
582
593
  var newFrameOffset = this._playheadLayer.getPlayheadPixel() - Math.round(0.1 * this._width);
583
594
 
584
595
  this.setFrameOffset(newFrameOffset);
@@ -592,11 +603,11 @@ define([
592
603
  * @param {Number} scale The new zoom level, in samples per pixel.
593
604
  */
594
605
 
595
- TimelineZoomView.prototype._getScale = function(duration) {
606
+ View.prototype._getScale = function(duration) {
596
607
  return duration * this._data.sample_rate / this._width;
597
608
  };
598
609
 
599
- TimelineZoomView.prototype.setZoom = function(newScale) {
610
+ View.prototype.setZoom = function(newScale) {
600
611
  newScale = Math.min(Math.max(this._options.zoomRange[0], newScale), this._options.zoomRange[1]);
601
612
 
602
613
  if (newScale === this._timeToPixelsScale) {
@@ -630,14 +641,14 @@ define([
630
641
  // Block interactions while updating the view.
631
642
  this.overrideInteractions(true, true);
632
643
 
633
- this.updateTimeline(this._frameOffset, undefined, undefined, true);
644
+ this.updateTimeline(this._frameOffset);
634
645
 
635
646
  this._sourcesLayer.rescale(true);
636
647
 
637
648
  // Update the playhead position after zooming.
638
649
  this._playheadLayer.updatePlayheadTime(currentTime);
639
650
 
640
- this._peaks.emit('zoom.update', newScale, prevScale);
651
+ this._peaks.emit('handler.view.updatezoom', newScale, prevScale);
641
652
 
642
653
  // Re-enable interactions after updating the view.
643
654
  this.overrideInteractions(false, true);
@@ -645,35 +656,35 @@ define([
645
656
  return true;
646
657
  };
647
658
 
648
- TimelineZoomView.prototype.getTimelineLength = function() {
659
+ View.prototype.getTimelineLength = function() {
649
660
  return this._timelineLength;
650
661
  };
651
662
 
652
- TimelineZoomView.prototype.updateTimelineLength = function() {
663
+ View.prototype.updateTimelineLength = function() {
653
664
  this._timelineLength = this._sourcesLayer.getLength() + this._peaks.options.horizontalPadding;
654
665
  };
655
666
 
656
- TimelineZoomView.prototype.setTimelineLength = function(length) {
667
+ View.prototype.setTimelineLength = function(length) {
657
668
  this._timelineLength = length;
658
669
  };
659
670
 
660
- TimelineZoomView.prototype.getPointerPosition = function() {
671
+ View.prototype.getPointerPosition = function() {
661
672
  return this._stage.getPointerPosition();
662
673
  };
663
674
 
664
- TimelineZoomView.prototype.getStartTime = function() {
675
+ View.prototype.getStartTime = function() {
665
676
  return this.pixelsToTime(this._frameOffset);
666
677
  };
667
678
 
668
- TimelineZoomView.prototype.getEndTime = function() {
679
+ View.prototype.getEndTime = function() {
669
680
  return this.pixelsToTime(this._frameOffset + this._width);
670
681
  };
671
682
 
672
- TimelineZoomView.prototype.getLineByPosition = function(pos) {
683
+ View.prototype.getLineByPosition = function(pos) {
673
684
  return this._sourcesLayer.getLineByPosition(pos);
674
685
  };
675
686
 
676
- TimelineZoomView.prototype.setStartTime = function(time) {
687
+ View.prototype.setStartTime = function(time) {
677
688
  if (time < 0) {
678
689
  time = 0;
679
690
  }
@@ -688,7 +699,7 @@ define([
688
699
  * @returns {Number} Pixel index.
689
700
  */
690
701
 
691
- TimelineZoomView.prototype.timeToPixels = function(time) {
702
+ View.prototype.timeToPixels = function(time) {
692
703
  return Math.round(time * this._timeToPixelsScale);
693
704
  };
694
705
 
@@ -699,7 +710,7 @@ define([
699
710
  * @returns {Number} Time, in seconds.
700
711
  */
701
712
 
702
- TimelineZoomView.prototype.pixelsToTime = function(pixels) {
713
+ View.prototype.pixelsToTime = function(pixels) {
703
714
  return Utils.roundTime(pixels / this._timeToPixelsScale);
704
715
  };
705
716
 
@@ -708,21 +719,21 @@ define([
708
719
  * in pixels.
709
720
  */
710
721
 
711
- TimelineZoomView.prototype.getFrameOffset = function() {
722
+ View.prototype.getFrameOffset = function() {
712
723
  return this._frameOffset;
713
724
  };
714
725
 
715
- TimelineZoomView.prototype.setFrameOffset = function(newFrameOffset) {
726
+ View.prototype.setFrameOffset = function(newFrameOffset) {
716
727
  newFrameOffset = Math.max(0, newFrameOffset);
717
728
  this._frameOffset = Math.round(newFrameOffset);
718
729
  this._timeOffset = this.pixelsToTime(this._frameOffset);
719
730
  };
720
731
 
721
- TimelineZoomView.prototype.getTimeOffset = function() {
732
+ View.prototype.getTimeOffset = function() {
722
733
  return this._timeOffset;
723
734
  };
724
735
 
725
- TimelineZoomView.prototype.setTimeOffset = function(newTimeOffset) {
736
+ View.prototype.setTimeOffset = function(newTimeOffset) {
726
737
  this._timeOffset = Utils.roundTime(newTimeOffset);
727
738
  this._frameOffset = this.timeToPixels(this._timeOffset);
728
739
  };
@@ -732,7 +743,7 @@ define([
732
743
  * in pixels.
733
744
  */
734
745
 
735
- TimelineZoomView.prototype.getFrameOffsetY = function() {
746
+ View.prototype.getFrameOffsetY = function() {
736
747
  return this._frameOffsetY;
737
748
  };
738
749
 
@@ -740,7 +751,7 @@ define([
740
751
  * @returns {Number} The width of the stage, in pixels.
741
752
  */
742
753
 
743
- TimelineZoomView.prototype.getWidth = function() {
754
+ View.prototype.getWidth = function() {
744
755
  return this._width;
745
756
  };
746
757
 
@@ -748,7 +759,7 @@ define([
748
759
  * @returns {Number} The width of the whole view, in pixels.
749
760
  */
750
761
 
751
- TimelineZoomView.prototype.getOriginalWidth = function() {
762
+ View.prototype.getOriginalWidth = function() {
752
763
  return this._originalWidth;
753
764
  };
754
765
 
@@ -756,7 +767,7 @@ define([
756
767
  * @returns {Number} The height of the view, in pixels.
757
768
  */
758
769
 
759
- TimelineZoomView.prototype.getHeight = function() {
770
+ View.prototype.getHeight = function() {
760
771
  return this._height;
761
772
  };
762
773
 
@@ -767,7 +778,7 @@ define([
767
778
  * @param {Number} scale The new amplitude scale factor
768
779
  */
769
780
 
770
- TimelineZoomView.prototype.setAmplitudeScale = function(scale) {
781
+ View.prototype.setAmplitudeScale = function(scale) {
771
782
  if (!Utils.isNumber(scale) || !Number.isFinite(scale)) {
772
783
  throw new Error('view.setAmplitudeScale(): Scale must be a valid number');
773
784
  }
@@ -775,7 +786,7 @@ define([
775
786
  this._amplitudeScale = scale;
776
787
  };
777
788
 
778
- TimelineZoomView.prototype.getAmplitudeScale = function() {
789
+ View.prototype.getAmplitudeScale = function() {
779
790
  return this._amplitudeScale;
780
791
  };
781
792
 
@@ -785,49 +796,36 @@ define([
785
796
  * @param {Number} frameOffset The new frame offset, in pixels.
786
797
  */
787
798
 
788
- TimelineZoomView.prototype.updateTimeline = function(frameOffset, frameOffsetY, fixPlayhead,
789
- ignoreRescale) {
790
- var frameStartTime = null;
791
- var frameEndTime = null;
792
-
793
- if (frameOffset !== undefined && frameOffset !== null) {
799
+ View.prototype.updateTimeline = function(frameOffset, frameOffsetY) {
800
+ if (!Utils.isNullOrUndefined(frameOffset)) {
794
801
  this.setFrameOffset(frameOffset);
795
802
 
796
- frameStartTime = this.pixelsToTime(this._frameOffset);
797
- frameEndTime = this.pixelsToTime(this._frameOffset + this._width);
798
-
799
- if (!fixPlayhead) {
800
- // Display playhead if it is within the zoom frame width.
801
- var playheadPixel = this._playheadLayer.getPlayheadPixel();
802
-
803
- this._playheadLayer.updatePlayheadTime(this.pixelsToTime(playheadPixel));
804
- }
803
+ const playheadPixel = this._playheadLayer.getPlayheadPixel();
805
804
 
805
+ this._playheadLayer.updatePlayheadTime(this.pixelsToTime(playheadPixel));
806
806
  this._axis.draw();
807
-
808
- this._peaks.emit('zoomview.displaying', frameStartTime, frameEndTime);
809
807
  }
810
808
 
811
- if (frameOffsetY !== undefined && frameOffsetY !== null) {
812
- this._frameOffsetY = frameOffsetY;
813
- }
809
+ const frameStartTime = this.pixelsToTime(this._frameOffset);
810
+ const frameEndTime = this.pixelsToTime(this._frameOffset + this._width);
814
811
 
815
- if (frameStartTime === null) {
816
- frameStartTime = this.pixelsToTime(this._frameOffset);
812
+ if (!Utils.isNullOrUndefined(frameOffsetY)) {
813
+ this.setFrameOffsetY(frameOffsetY);
817
814
  }
818
815
 
819
- if (frameEndTime === null) {
820
- frameEndTime = this.pixelsToTime(this._frameOffset + this._width);
821
- }
816
+ this._sourcesLayer.updateSources(frameStartTime, frameEndTime);
817
+ };
822
818
 
823
- if (!ignoreRescale) {
824
- this._sourcesLayer.rescale();
819
+ View.prototype.setFrameOffsetY = function(frameOffsetY) {
820
+ if (frameOffsetY === this._frameOffsetY) {
821
+ return;
825
822
  }
826
823
 
827
- this._sourcesLayer.updateSources(frameStartTime, frameEndTime);
824
+ this._frameOffsetY = frameOffsetY;
825
+ this._peaks.emit('handler.view.setFrameOffsetY', frameOffsetY);
828
826
  };
829
827
 
830
- TimelineZoomView.prototype.toggleMainCursor = function(on, type) {
828
+ View.prototype.toggleMainCursor = function(on, type) {
831
829
  this._isMainCursorToggled = on;
832
830
 
833
831
  this._stage.container().style.cursor = on ?
@@ -835,26 +833,26 @@ define([
835
833
  this._nativeCursor;
836
834
  };
837
835
 
838
- TimelineZoomView.prototype.setCursor = function(type) {
836
+ View.prototype.setCursor = function(type) {
839
837
  this._nativeCursor = type;
840
838
  if (!this._isMainCursorToggled) {
841
839
  this._stage.container().style.cursor = type;
842
840
  }
843
841
  };
844
842
 
845
- TimelineZoomView.prototype.getCursor = function() {
843
+ View.prototype.getCursor = function() {
846
844
  return this._stage.container().style.cursor;
847
845
  };
848
846
 
849
- TimelineZoomView.prototype.showPlayheadTime = function(show) {
847
+ View.prototype.showPlayheadTime = function(show) {
850
848
  this._playheadLayer.showPlayheadTime(show);
851
849
  };
852
850
 
853
- TimelineZoomView.prototype.enableAutoScroll = function(enable) {
851
+ View.prototype.enableAutoScroll = function(enable) {
854
852
  this._enableAutoScroll = enable;
855
853
  };
856
854
 
857
- TimelineZoomView.prototype.fitToContainer = function() {
855
+ View.prototype.fitToContainer = function() {
858
856
  if (this._container.clientWidth === 0 && this._container.clientHeight === 0) {
859
857
  return;
860
858
  }
@@ -883,28 +881,23 @@ define([
883
881
  }
884
882
  };
885
883
 
886
- TimelineZoomView.prototype.getFullHeight = function() {
884
+ View.prototype.getFullHeight = function() {
887
885
  return this._sourcesLayer.getFullHeight();
888
886
  };
889
887
 
890
- TimelineZoomView.prototype.destroy = function() {
891
- if (this._resizeTimeoutId) {
892
- clearTimeout(this._resizeTimeoutId);
893
- this._resizeTimeoutId = null;
894
- }
895
-
888
+ View.prototype.destroy = function() {
896
889
  // Unregister event handlers
897
890
  this._peaks.off('player_time_update', this._onTimeUpdate);
898
891
  this._peaks.off('user_seek', this._onSeek);
899
892
  this._peaks.off('player_play', this._onPlay);
900
893
  this._peaks.off('player_pause', this._onPause);
901
894
  this._peaks.off('window_resize', this._onWindowResize);
902
- this._peaks.off('keyboard.left', this._onKeyboardLeft);
903
- this._peaks.off('keyboard.right', this._onKeyboardRight);
904
- this._peaks.off('keyboard.shift_left', this._onKeyboardShiftLeft);
905
- this._peaks.off('keyboard.shift_right', this._onKeyboardShiftRight);
906
- this._peaks.off('default_mode', this._onDefaultMode);
907
- this._peaks.off('cut_mode', this._onCutMode);
895
+ this._peaks.off('handler.keyboard.left', this._onKeyboardLeft);
896
+ this._peaks.off('handler.keyboard.right', this._onKeyboardRight);
897
+ this._peaks.off('handler.keyboard.shiftleft', this._onKeyboardShiftLeft);
898
+ this._peaks.off('handler.keyboard.shiftright', this._onKeyboardShiftRight);
899
+ this._peaks.off('handler.view.defaultmode', this._onDefaultMode);
900
+ this._peaks.off('handler.view.cutmode', this._onCutMode);
908
901
 
909
902
  if (this._stage) {
910
903
  this._stage.destroy();
@@ -912,5 +905,5 @@ define([
912
905
  }
913
906
  };
914
907
 
915
- return TimelineZoomView;
908
+ return View;
916
909
  });