@checksub_team/peaks_timeline 1.16.1 → 2.0.0-alpha.2
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.
- package/package.json +1 -1
- package/peaks.js +4716 -4409
- package/peaks.js.d.ts +5 -5
- package/src/{timeline-axis.js → components/axis.js} +244 -244
- package/src/{data-retriever.js → components/data-retriever.js} +117 -117
- package/src/{default-segment-marker.js → components/default-segment-marker.js} +132 -132
- package/src/{invoker.js → components/invoker.js} +81 -81
- package/src/components/line-group.js +692 -0
- package/src/components/line-groups.js +585 -0
- package/src/{line-indicator.js → components/line-indicator.js} +308 -303
- package/src/{marker-factories.js → components/marker-factories.js} +1 -1
- package/src/{mode-layer.js → components/mode-layer.js} +8 -12
- package/src/{playhead-layer.js → components/playhead-layer.js} +3 -3
- package/src/{segment-marker.js → components/segment-marker.js} +2 -2
- package/src/{segment-shape.js → components/segment-shape.js} +508 -508
- package/src/{segments-group.js → components/segments-group.js} +805 -801
- package/src/{source-group.js → components/source-group.js} +1661 -1640
- package/src/{sources-layer.js → components/sources-layer.js} +716 -730
- package/src/{waveform-builder.js → components/waveform-builder.js} +2 -2
- package/src/{waveform-shape.js → components/waveform-shape.js} +214 -214
- package/src/keyboard-handler.js +9 -9
- package/src/line-handler.js +179 -0
- package/src/main.js +110 -71
- package/src/models/line.js +156 -0
- package/src/{segment.js → models/segment.js} +420 -419
- package/src/{source.js → models/source.js} +1311 -1315
- package/src/player.js +2 -2
- package/src/{timeline-segments.js → segment-handler.js} +435 -435
- package/src/{timeline-sources.js → source-handler.js} +521 -514
- package/src/utils.js +5 -1
- package/src/{timeline-zoomview.js → view.js} +136 -137
- package/src/line.js +0 -690
- package/src/lines.js +0 -427
- /package/src/{data.js → components/data.js} +0 -0
- /package/src/{loader.js → components/loader.js} +0 -0
- /package/src/{mouse-drag-handler.js → components/mouse-drag-handler.js} +0 -0
- /package/src/{svgs.js → components/svgs.js} +0 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file
|
|
3
3
|
*
|
|
4
|
-
* Defines the {@link
|
|
4
|
+
* Defines the {@link View} class.
|
|
5
5
|
*
|
|
6
|
-
* @module
|
|
6
|
+
* @module view
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
define([
|
|
10
|
-
'./mouse-drag-handler',
|
|
11
|
-
'./playhead-layer',
|
|
12
|
-
'./sources-layer',
|
|
13
|
-
'./mode-layer',
|
|
14
|
-
'./
|
|
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
|
-
|
|
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
|
|
31
|
+
* @alias View
|
|
32
32
|
*
|
|
33
33
|
* @param {HTMLElement} container
|
|
34
34
|
* @param {Peaks} peaks
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
|
-
function
|
|
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('
|
|
58
|
-
self._peaks.on('
|
|
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.
|
|
68
|
-
self._peaks.on('keyboard.
|
|
69
|
-
self._peaks.on('
|
|
70
|
-
self._peaks.on('
|
|
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
|
|
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.
|
|
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.
|
|
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('
|
|
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('
|
|
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('
|
|
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.
|
|
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.
|
|
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
|
-
|
|
313
|
+
View.prototype._mouseUp = function() {
|
|
308
314
|
this.clearScrollingInterval();
|
|
309
315
|
};
|
|
310
316
|
|
|
311
|
-
|
|
317
|
+
View.prototype.setClickable = function(clickable) {
|
|
312
318
|
this._isClickable = clickable;
|
|
313
319
|
};
|
|
314
320
|
|
|
315
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
386
|
+
View.prototype.getCurrentMode = function() {
|
|
377
387
|
return this._modeLayer.getCurrentMode();
|
|
378
388
|
};
|
|
379
389
|
|
|
380
|
-
|
|
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
|
-
|
|
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
|
-
|
|
401
|
+
View.prototype.getSelectedElements = function() {
|
|
394
402
|
return this._modeLayer.getSelectedElements();
|
|
395
403
|
};
|
|
396
404
|
|
|
397
|
-
|
|
405
|
+
View.prototype.getSourceGroupById = function(sourceId) {
|
|
398
406
|
return this._sourcesLayer.getSourceGroupById(sourceId);
|
|
399
407
|
};
|
|
400
408
|
|
|
401
|
-
|
|
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
|
-
|
|
417
|
+
View.prototype.selectSourcesOnLineAfter = function(lineId, time) {
|
|
410
418
|
const sources = this._sourcesLayer.getSourcesOnLineAfter(lineId, time);
|
|
411
419
|
|
|
412
420
|
if (sources) {
|
|
@@ -414,50 +422,54 @@ define([
|
|
|
414
422
|
}
|
|
415
423
|
};
|
|
416
424
|
|
|
417
|
-
|
|
425
|
+
View.prototype.deselectAll = function(notify) {
|
|
418
426
|
this._modeLayer.deselectDifference([], notify);
|
|
419
427
|
};
|
|
420
428
|
|
|
421
|
-
|
|
429
|
+
View.prototype.isListening = function() {
|
|
422
430
|
return this._stage.listening();
|
|
423
431
|
};
|
|
424
432
|
|
|
425
|
-
|
|
433
|
+
View.prototype.isFocused = function() {
|
|
426
434
|
return this._isFocused;
|
|
427
435
|
};
|
|
428
436
|
|
|
429
|
-
|
|
437
|
+
View.prototype.drawSourcesLayer = function() {
|
|
430
438
|
this._sourcesLayer.draw();
|
|
431
439
|
};
|
|
432
440
|
|
|
433
|
-
|
|
441
|
+
View.prototype.refresh = function() {
|
|
442
|
+
this._sourcesLayer.refresh();
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
View.prototype.getSegmentsGroup = function() {
|
|
434
446
|
return this._sourcesLayer.getSegmentsGroup();
|
|
435
447
|
};
|
|
436
448
|
|
|
437
|
-
|
|
449
|
+
View.prototype.getTimeToPixelsScale = function() {
|
|
438
450
|
return this._timeToPixelsScale;
|
|
439
451
|
};
|
|
440
452
|
|
|
441
|
-
|
|
453
|
+
View.prototype.getTimeToPixelsMaxZoom = function() {
|
|
442
454
|
return this._options.zoomRange[1];
|
|
443
455
|
};
|
|
444
456
|
|
|
445
|
-
|
|
457
|
+
View.prototype.setTimeToPixelsMaxZoom = function(value) {
|
|
446
458
|
this._options.zoomRange[1] = value;
|
|
447
459
|
if (value < this._timeToPixelsScale) {
|
|
448
460
|
this.setZoom(value);
|
|
449
461
|
}
|
|
450
462
|
};
|
|
451
463
|
|
|
452
|
-
|
|
464
|
+
View.prototype.getTimeToPixelsMinScale = function() {
|
|
453
465
|
return this._timeToPixelsMinScale;
|
|
454
466
|
};
|
|
455
467
|
|
|
456
|
-
|
|
468
|
+
View.prototype.getName = function() {
|
|
457
469
|
return 'zoomview';
|
|
458
470
|
};
|
|
459
471
|
|
|
460
|
-
|
|
472
|
+
View.prototype._onTimeUpdate = function(time) {
|
|
461
473
|
if (this._mouseDragHandler.isDragging()) {
|
|
462
474
|
return;
|
|
463
475
|
}
|
|
@@ -465,24 +477,24 @@ define([
|
|
|
465
477
|
this._syncPlayhead(time);
|
|
466
478
|
};
|
|
467
479
|
|
|
468
|
-
|
|
480
|
+
View.prototype._onSeek = function(time) {
|
|
469
481
|
var frameIndex = this.timeToPixels(time);
|
|
470
482
|
|
|
471
483
|
this.updateTimeline(frameIndex - Math.floor(this._width / 2));
|
|
472
484
|
this._playheadLayer.updatePlayheadTime(time);
|
|
473
485
|
};
|
|
474
486
|
|
|
475
|
-
|
|
487
|
+
View.prototype._onPlay = function(time) {
|
|
476
488
|
this._playheadLayer.updatePlayheadTime(time);
|
|
477
489
|
this.enableAutoScroll(true);
|
|
478
490
|
};
|
|
479
491
|
|
|
480
|
-
|
|
492
|
+
View.prototype._onPause = function(time) {
|
|
481
493
|
this._playheadLayer.stop(time);
|
|
482
494
|
this.enableAutoScroll(true);
|
|
483
495
|
};
|
|
484
496
|
|
|
485
|
-
|
|
497
|
+
View.prototype._onWindowResize = function() {
|
|
486
498
|
var self = this;
|
|
487
499
|
|
|
488
500
|
var width = self._container.clientWidth;
|
|
@@ -492,57 +504,57 @@ define([
|
|
|
492
504
|
self.updateTimeline(self._frameOffset, self._frameOffsetY);
|
|
493
505
|
};
|
|
494
506
|
|
|
495
|
-
|
|
507
|
+
View.prototype._onKeyboardLeft = function() {
|
|
496
508
|
if (this.isFocused()) {
|
|
497
509
|
this._keyboardScroll(-1, false);
|
|
498
510
|
}
|
|
499
511
|
};
|
|
500
512
|
|
|
501
|
-
|
|
513
|
+
View.prototype._onKeyboardRight = function() {
|
|
502
514
|
if (this.isFocused()) {
|
|
503
515
|
this._keyboardScroll(1, false);
|
|
504
516
|
}
|
|
505
517
|
};
|
|
506
518
|
|
|
507
|
-
|
|
519
|
+
View.prototype._onKeyboardShiftLeft = function() {
|
|
508
520
|
if (this.isFocused()) {
|
|
509
521
|
this._keyboardScroll(-1, true);
|
|
510
522
|
}
|
|
511
523
|
};
|
|
512
524
|
|
|
513
|
-
|
|
525
|
+
View.prototype._onKeyboardShiftRight = function() {
|
|
514
526
|
if (this.isFocused()) {
|
|
515
527
|
this._keyboardScroll(1, true);
|
|
516
528
|
}
|
|
517
529
|
};
|
|
518
530
|
|
|
519
|
-
|
|
531
|
+
View.prototype._onDefaultMode = function() {
|
|
520
532
|
this.preventWrappingChange(false);
|
|
521
533
|
this._modeLayer.setMode('default');
|
|
522
534
|
};
|
|
523
535
|
|
|
524
|
-
|
|
536
|
+
View.prototype._onCutMode = function() {
|
|
525
537
|
this.preventWrappingChange(true);
|
|
526
538
|
this._modeLayer.setMode('cut');
|
|
527
539
|
};
|
|
528
540
|
|
|
529
|
-
|
|
541
|
+
View.prototype.preventWrappingChange = function(bool) {
|
|
530
542
|
this._preventWrappingChange = bool;
|
|
531
543
|
};
|
|
532
544
|
|
|
533
|
-
|
|
545
|
+
View.prototype.isPreventingWrappingChange = function() {
|
|
534
546
|
return this._preventWrappingChange;
|
|
535
547
|
};
|
|
536
548
|
|
|
537
|
-
|
|
549
|
+
View.prototype.getHoveredElement = function() {
|
|
538
550
|
return this._hoveredElement;
|
|
539
551
|
};
|
|
540
552
|
|
|
541
|
-
|
|
553
|
+
View.prototype.setHoveredElement = function(element) {
|
|
542
554
|
this._hoveredElement = element;
|
|
543
555
|
};
|
|
544
556
|
|
|
545
|
-
|
|
557
|
+
View.prototype._keyboardScroll = function(direction, large) {
|
|
546
558
|
var increment;
|
|
547
559
|
|
|
548
560
|
if (large) {
|
|
@@ -555,7 +567,7 @@ define([
|
|
|
555
567
|
this.updateTimeline(this._frameOffset + increment);
|
|
556
568
|
};
|
|
557
569
|
|
|
558
|
-
|
|
570
|
+
View.prototype._syncPlayhead = function(time) {
|
|
559
571
|
this._playheadLayer.updatePlayheadTime(time);
|
|
560
572
|
|
|
561
573
|
if (this._enableAutoScroll) {
|
|
@@ -578,7 +590,7 @@ define([
|
|
|
578
590
|
}
|
|
579
591
|
};
|
|
580
592
|
|
|
581
|
-
|
|
593
|
+
View.prototype.showPlayhead = function() {
|
|
582
594
|
var newFrameOffset = this._playheadLayer.getPlayheadPixel() - Math.round(0.1 * this._width);
|
|
583
595
|
|
|
584
596
|
this.setFrameOffset(newFrameOffset);
|
|
@@ -592,11 +604,11 @@ define([
|
|
|
592
604
|
* @param {Number} scale The new zoom level, in samples per pixel.
|
|
593
605
|
*/
|
|
594
606
|
|
|
595
|
-
|
|
607
|
+
View.prototype._getScale = function(duration) {
|
|
596
608
|
return duration * this._data.sample_rate / this._width;
|
|
597
609
|
};
|
|
598
610
|
|
|
599
|
-
|
|
611
|
+
View.prototype.setZoom = function(newScale) {
|
|
600
612
|
newScale = Math.min(Math.max(this._options.zoomRange[0], newScale), this._options.zoomRange[1]);
|
|
601
613
|
|
|
602
614
|
if (newScale === this._timeToPixelsScale) {
|
|
@@ -630,14 +642,14 @@ define([
|
|
|
630
642
|
// Block interactions while updating the view.
|
|
631
643
|
this.overrideInteractions(true, true);
|
|
632
644
|
|
|
633
|
-
this.updateTimeline(this._frameOffset
|
|
645
|
+
this.updateTimeline(this._frameOffset);
|
|
634
646
|
|
|
635
647
|
this._sourcesLayer.rescale(true);
|
|
636
648
|
|
|
637
649
|
// Update the playhead position after zooming.
|
|
638
650
|
this._playheadLayer.updatePlayheadTime(currentTime);
|
|
639
651
|
|
|
640
|
-
this._peaks.emit('
|
|
652
|
+
this._peaks.emit('handler.view.updatezoom', newScale, prevScale);
|
|
641
653
|
|
|
642
654
|
// Re-enable interactions after updating the view.
|
|
643
655
|
this.overrideInteractions(false, true);
|
|
@@ -645,35 +657,35 @@ define([
|
|
|
645
657
|
return true;
|
|
646
658
|
};
|
|
647
659
|
|
|
648
|
-
|
|
660
|
+
View.prototype.getTimelineLength = function() {
|
|
649
661
|
return this._timelineLength;
|
|
650
662
|
};
|
|
651
663
|
|
|
652
|
-
|
|
664
|
+
View.prototype.updateTimelineLength = function() {
|
|
653
665
|
this._timelineLength = this._sourcesLayer.getLength() + this._peaks.options.horizontalPadding;
|
|
654
666
|
};
|
|
655
667
|
|
|
656
|
-
|
|
668
|
+
View.prototype.setTimelineLength = function(length) {
|
|
657
669
|
this._timelineLength = length;
|
|
658
670
|
};
|
|
659
671
|
|
|
660
|
-
|
|
672
|
+
View.prototype.getPointerPosition = function() {
|
|
661
673
|
return this._stage.getPointerPosition();
|
|
662
674
|
};
|
|
663
675
|
|
|
664
|
-
|
|
676
|
+
View.prototype.getStartTime = function() {
|
|
665
677
|
return this.pixelsToTime(this._frameOffset);
|
|
666
678
|
};
|
|
667
679
|
|
|
668
|
-
|
|
680
|
+
View.prototype.getEndTime = function() {
|
|
669
681
|
return this.pixelsToTime(this._frameOffset + this._width);
|
|
670
682
|
};
|
|
671
683
|
|
|
672
|
-
|
|
684
|
+
View.prototype.getLineByPosition = function(pos) {
|
|
673
685
|
return this._sourcesLayer.getLineByPosition(pos);
|
|
674
686
|
};
|
|
675
687
|
|
|
676
|
-
|
|
688
|
+
View.prototype.setStartTime = function(time) {
|
|
677
689
|
if (time < 0) {
|
|
678
690
|
time = 0;
|
|
679
691
|
}
|
|
@@ -688,7 +700,7 @@ define([
|
|
|
688
700
|
* @returns {Number} Pixel index.
|
|
689
701
|
*/
|
|
690
702
|
|
|
691
|
-
|
|
703
|
+
View.prototype.timeToPixels = function(time) {
|
|
692
704
|
return Math.round(time * this._timeToPixelsScale);
|
|
693
705
|
};
|
|
694
706
|
|
|
@@ -699,7 +711,7 @@ define([
|
|
|
699
711
|
* @returns {Number} Time, in seconds.
|
|
700
712
|
*/
|
|
701
713
|
|
|
702
|
-
|
|
714
|
+
View.prototype.pixelsToTime = function(pixels) {
|
|
703
715
|
return Utils.roundTime(pixels / this._timeToPixelsScale);
|
|
704
716
|
};
|
|
705
717
|
|
|
@@ -708,21 +720,21 @@ define([
|
|
|
708
720
|
* in pixels.
|
|
709
721
|
*/
|
|
710
722
|
|
|
711
|
-
|
|
723
|
+
View.prototype.getFrameOffset = function() {
|
|
712
724
|
return this._frameOffset;
|
|
713
725
|
};
|
|
714
726
|
|
|
715
|
-
|
|
727
|
+
View.prototype.setFrameOffset = function(newFrameOffset) {
|
|
716
728
|
newFrameOffset = Math.max(0, newFrameOffset);
|
|
717
729
|
this._frameOffset = Math.round(newFrameOffset);
|
|
718
730
|
this._timeOffset = this.pixelsToTime(this._frameOffset);
|
|
719
731
|
};
|
|
720
732
|
|
|
721
|
-
|
|
733
|
+
View.prototype.getTimeOffset = function() {
|
|
722
734
|
return this._timeOffset;
|
|
723
735
|
};
|
|
724
736
|
|
|
725
|
-
|
|
737
|
+
View.prototype.setTimeOffset = function(newTimeOffset) {
|
|
726
738
|
this._timeOffset = Utils.roundTime(newTimeOffset);
|
|
727
739
|
this._frameOffset = this.timeToPixels(this._timeOffset);
|
|
728
740
|
};
|
|
@@ -732,7 +744,7 @@ define([
|
|
|
732
744
|
* in pixels.
|
|
733
745
|
*/
|
|
734
746
|
|
|
735
|
-
|
|
747
|
+
View.prototype.getFrameOffsetY = function() {
|
|
736
748
|
return this._frameOffsetY;
|
|
737
749
|
};
|
|
738
750
|
|
|
@@ -740,7 +752,7 @@ define([
|
|
|
740
752
|
* @returns {Number} The width of the stage, in pixels.
|
|
741
753
|
*/
|
|
742
754
|
|
|
743
|
-
|
|
755
|
+
View.prototype.getWidth = function() {
|
|
744
756
|
return this._width;
|
|
745
757
|
};
|
|
746
758
|
|
|
@@ -748,7 +760,7 @@ define([
|
|
|
748
760
|
* @returns {Number} The width of the whole view, in pixels.
|
|
749
761
|
*/
|
|
750
762
|
|
|
751
|
-
|
|
763
|
+
View.prototype.getOriginalWidth = function() {
|
|
752
764
|
return this._originalWidth;
|
|
753
765
|
};
|
|
754
766
|
|
|
@@ -756,7 +768,7 @@ define([
|
|
|
756
768
|
* @returns {Number} The height of the view, in pixels.
|
|
757
769
|
*/
|
|
758
770
|
|
|
759
|
-
|
|
771
|
+
View.prototype.getHeight = function() {
|
|
760
772
|
return this._height;
|
|
761
773
|
};
|
|
762
774
|
|
|
@@ -767,7 +779,7 @@ define([
|
|
|
767
779
|
* @param {Number} scale The new amplitude scale factor
|
|
768
780
|
*/
|
|
769
781
|
|
|
770
|
-
|
|
782
|
+
View.prototype.setAmplitudeScale = function(scale) {
|
|
771
783
|
if (!Utils.isNumber(scale) || !Number.isFinite(scale)) {
|
|
772
784
|
throw new Error('view.setAmplitudeScale(): Scale must be a valid number');
|
|
773
785
|
}
|
|
@@ -775,7 +787,7 @@ define([
|
|
|
775
787
|
this._amplitudeScale = scale;
|
|
776
788
|
};
|
|
777
789
|
|
|
778
|
-
|
|
790
|
+
View.prototype.getAmplitudeScale = function() {
|
|
779
791
|
return this._amplitudeScale;
|
|
780
792
|
};
|
|
781
793
|
|
|
@@ -785,49 +797,36 @@ define([
|
|
|
785
797
|
* @param {Number} frameOffset The new frame offset, in pixels.
|
|
786
798
|
*/
|
|
787
799
|
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
var frameStartTime = null;
|
|
791
|
-
var frameEndTime = null;
|
|
792
|
-
|
|
793
|
-
if (frameOffset !== undefined && frameOffset !== null) {
|
|
800
|
+
View.prototype.updateTimeline = function(frameOffset, frameOffsetY) {
|
|
801
|
+
if (!Utils.isNullOrUndefined(frameOffset)) {
|
|
794
802
|
this.setFrameOffset(frameOffset);
|
|
795
803
|
|
|
796
|
-
|
|
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
|
-
}
|
|
804
|
+
const playheadPixel = this._playheadLayer.getPlayheadPixel();
|
|
805
805
|
|
|
806
|
+
this._playheadLayer.updatePlayheadTime(this.pixelsToTime(playheadPixel));
|
|
806
807
|
this._axis.draw();
|
|
807
|
-
|
|
808
|
-
this._peaks.emit('zoomview.displaying', frameStartTime, frameEndTime);
|
|
809
808
|
}
|
|
810
809
|
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
}
|
|
810
|
+
const frameStartTime = this.pixelsToTime(this._frameOffset);
|
|
811
|
+
const frameEndTime = this.pixelsToTime(this._frameOffset + this._width);
|
|
814
812
|
|
|
815
|
-
if (
|
|
816
|
-
|
|
813
|
+
if (!Utils.isNullOrUndefined(frameOffsetY)) {
|
|
814
|
+
this.setFrameOffsetY(frameOffsetY);
|
|
817
815
|
}
|
|
818
816
|
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
}
|
|
817
|
+
this._sourcesLayer.updateSources(frameStartTime, frameEndTime);
|
|
818
|
+
};
|
|
822
819
|
|
|
823
|
-
|
|
824
|
-
|
|
820
|
+
View.prototype.setFrameOffsetY = function(frameOffsetY) {
|
|
821
|
+
if (frameOffsetY === this._frameOffsetY) {
|
|
822
|
+
return;
|
|
825
823
|
}
|
|
826
824
|
|
|
827
|
-
this.
|
|
825
|
+
this._frameOffsetY = frameOffsetY;
|
|
826
|
+
this._peaks.emit('handler.view.setFrameOffsetY', frameOffsetY);
|
|
828
827
|
};
|
|
829
828
|
|
|
830
|
-
|
|
829
|
+
View.prototype.toggleMainCursor = function(on, type) {
|
|
831
830
|
this._isMainCursorToggled = on;
|
|
832
831
|
|
|
833
832
|
this._stage.container().style.cursor = on ?
|
|
@@ -835,26 +834,26 @@ define([
|
|
|
835
834
|
this._nativeCursor;
|
|
836
835
|
};
|
|
837
836
|
|
|
838
|
-
|
|
837
|
+
View.prototype.setCursor = function(type) {
|
|
839
838
|
this._nativeCursor = type;
|
|
840
839
|
if (!this._isMainCursorToggled) {
|
|
841
840
|
this._stage.container().style.cursor = type;
|
|
842
841
|
}
|
|
843
842
|
};
|
|
844
843
|
|
|
845
|
-
|
|
844
|
+
View.prototype.getCursor = function() {
|
|
846
845
|
return this._stage.container().style.cursor;
|
|
847
846
|
};
|
|
848
847
|
|
|
849
|
-
|
|
848
|
+
View.prototype.showPlayheadTime = function(show) {
|
|
850
849
|
this._playheadLayer.showPlayheadTime(show);
|
|
851
850
|
};
|
|
852
851
|
|
|
853
|
-
|
|
852
|
+
View.prototype.enableAutoScroll = function(enable) {
|
|
854
853
|
this._enableAutoScroll = enable;
|
|
855
854
|
};
|
|
856
855
|
|
|
857
|
-
|
|
856
|
+
View.prototype.fitToContainer = function() {
|
|
858
857
|
if (this._container.clientWidth === 0 && this._container.clientHeight === 0) {
|
|
859
858
|
return;
|
|
860
859
|
}
|
|
@@ -883,11 +882,11 @@ define([
|
|
|
883
882
|
}
|
|
884
883
|
};
|
|
885
884
|
|
|
886
|
-
|
|
885
|
+
View.prototype.getFullHeight = function() {
|
|
887
886
|
return this._sourcesLayer.getFullHeight();
|
|
888
887
|
};
|
|
889
888
|
|
|
890
|
-
|
|
889
|
+
View.prototype.destroy = function() {
|
|
891
890
|
if (this._resizeTimeoutId) {
|
|
892
891
|
clearTimeout(this._resizeTimeoutId);
|
|
893
892
|
this._resizeTimeoutId = null;
|
|
@@ -899,12 +898,12 @@ define([
|
|
|
899
898
|
this._peaks.off('player_play', this._onPlay);
|
|
900
899
|
this._peaks.off('player_pause', this._onPause);
|
|
901
900
|
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.
|
|
905
|
-
this._peaks.off('keyboard.
|
|
906
|
-
this._peaks.off('
|
|
907
|
-
this._peaks.off('
|
|
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);
|
|
908
907
|
|
|
909
908
|
if (this._stage) {
|
|
910
909
|
this._stage.destroy();
|
|
@@ -912,5 +911,5 @@ define([
|
|
|
912
911
|
}
|
|
913
912
|
};
|
|
914
913
|
|
|
915
|
-
return
|
|
914
|
+
return View;
|
|
916
915
|
});
|