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