@checksub_team/peaks_timeline 1.8.3 → 1.9.1
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 +239 -173
- package/src/line.js +22 -0
- package/src/lines.js +4 -0
- package/src/main.js +12 -2
- package/src/mode-layer.js +77 -30
- package/src/playhead-layer.js +3 -5
- package/src/segment-shape.js +18 -19
- package/src/segment.js +6 -0
- package/src/source-group.js +28 -139
- package/src/source.js +6 -0
- package/src/sources-layer.js +98 -3
- package/src/timeline-zoomview.js +50 -23
package/src/sources-layer.js
CHANGED
|
@@ -320,6 +320,95 @@ define([
|
|
|
320
320
|
}
|
|
321
321
|
};
|
|
322
322
|
|
|
323
|
+
SourcesLayer.prototype.onSourcesGroupDragStart = function(element) {
|
|
324
|
+
this._initialFrameOffset = this._view.getFrameOffset();
|
|
325
|
+
this._mouseDownX = this._view.getPointerPosition().x;
|
|
326
|
+
this._selectedElements = {};
|
|
327
|
+
|
|
328
|
+
const draggedElementId = element.currentTarget.attrs.sourceId;
|
|
329
|
+
const shouldDragSelectedElements = Object.keys(this._view.getSelectedElements()).includes(
|
|
330
|
+
draggedElementId
|
|
331
|
+
);
|
|
332
|
+
|
|
333
|
+
this._nonSelectedElement = shouldDragSelectedElements ?
|
|
334
|
+
null :
|
|
335
|
+
[this._sourcesGroup[draggedElementId].getSource()];
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
SourcesLayer.prototype.onSourcesGroupDragEnd = function() {
|
|
339
|
+
const updatedSources = (this._nonSelectedElement || Object.values(this._view.getSelectedElements())).map(
|
|
340
|
+
function(source) {
|
|
341
|
+
const sourceGroup = this._sourcesGroup[source.id];
|
|
342
|
+
|
|
343
|
+
if (sourceGroup) {
|
|
344
|
+
sourceGroup.prepareDragEnd();
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
return source;
|
|
348
|
+
}.bind(this)
|
|
349
|
+
);
|
|
350
|
+
|
|
351
|
+
this._view.drawSourcesLayer();
|
|
352
|
+
this._view.updateTimelineLength();
|
|
353
|
+
|
|
354
|
+
this._selectedElements = {};
|
|
355
|
+
|
|
356
|
+
this._peaks.emit('sources.updated', updatedSources);
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
SourcesLayer.prototype.onSourcesGroupDrag = function(draggedElement) {
|
|
360
|
+
this._view.updateWithAutoScroll(this._updateSourcesGroup.bind(this));
|
|
361
|
+
|
|
362
|
+
return {
|
|
363
|
+
x: draggedElement.absolutePosition().x,
|
|
364
|
+
y: draggedElement.absolutePosition().y
|
|
365
|
+
};
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
SourcesLayer.prototype._updateSourcesGroup = function() {
|
|
369
|
+
var mousePos = Math.min(
|
|
370
|
+
this._view.getWidth() - this._peaks.options.autoScrollThreshold * this._view.getWidth(),
|
|
371
|
+
Math.max(
|
|
372
|
+
0,
|
|
373
|
+
this._view.getPointerPosition().x
|
|
374
|
+
)
|
|
375
|
+
);
|
|
376
|
+
|
|
377
|
+
const diff = mousePos - this._mouseDownX;
|
|
378
|
+
const currentFrameOffset = this._view.getFrameOffset();
|
|
379
|
+
const mousePosY = this._view.getPointerPosition().y;
|
|
380
|
+
var newEnd = 0;
|
|
381
|
+
var shouldRedraw = false;
|
|
382
|
+
|
|
383
|
+
(this._nonSelectedElement || Object.values(this._view.getSelectedElements())).forEach(function(source) {
|
|
384
|
+
if (!this._selectedElements[source.id]) {
|
|
385
|
+
this._selectedElements[source.id] = {
|
|
386
|
+
startX: this._view.timeToPixels(source.startTime),
|
|
387
|
+
endX: this._view.timeToPixels(source.endTime)
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
const { startX, endX } = this._selectedElements[source.id];
|
|
392
|
+
|
|
393
|
+
newEnd = Math.max(newEnd, source.endTime);
|
|
394
|
+
|
|
395
|
+
shouldRedraw = this.updateSource(
|
|
396
|
+
source,
|
|
397
|
+
startX + diff + (currentFrameOffset - this._initialFrameOffset),
|
|
398
|
+
endX + diff + (currentFrameOffset - this._initialFrameOffset),
|
|
399
|
+
mousePosY
|
|
400
|
+
) || shouldRedraw;
|
|
401
|
+
}.bind(this));
|
|
402
|
+
|
|
403
|
+
if (shouldRedraw) {
|
|
404
|
+
this.draw();
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
this._view.setTimelineLength(
|
|
408
|
+
this._view.timeToPixels(newEnd) + this._view.getWidth()
|
|
409
|
+
);
|
|
410
|
+
};
|
|
411
|
+
|
|
323
412
|
SourcesLayer.prototype.findSources = function(startTime, endTime) {
|
|
324
413
|
var sources = this._peaks.sources.find(startTime, endTime);
|
|
325
414
|
var positions = this._lines.getVisibleLines();
|
|
@@ -357,8 +446,9 @@ define([
|
|
|
357
446
|
newXs.updateWidth
|
|
358
447
|
);
|
|
359
448
|
|
|
360
|
-
|
|
449
|
+
return true;
|
|
361
450
|
}
|
|
451
|
+
return false;
|
|
362
452
|
};
|
|
363
453
|
|
|
364
454
|
SourcesLayer.prototype.manageVerticalPosition = function(source, newY) {
|
|
@@ -410,8 +500,7 @@ define([
|
|
|
410
500
|
if (Utils.objectHasProperty(this._sourcesGroup, sourceId)) {
|
|
411
501
|
var source = this._sourcesGroup[sourceId].getSource();
|
|
412
502
|
|
|
413
|
-
if (!this._isSourceVisible(source, startTime, endTime)
|
|
414
|
-
&& !this._sourcesGroup[sourceId].isDragged()) {
|
|
503
|
+
if (!this._isSourceVisible(source, startTime, endTime)) {
|
|
415
504
|
this._removeSource(source);
|
|
416
505
|
count++;
|
|
417
506
|
}
|
|
@@ -516,6 +605,10 @@ define([
|
|
|
516
605
|
return this._sourcesGroup[sourceId];
|
|
517
606
|
};
|
|
518
607
|
|
|
608
|
+
SourcesLayer.prototype.getSourcesOnLineAfter = function(lineId, time) {
|
|
609
|
+
return this._lines.getSourcesOnLineAfter(lineId, time);
|
|
610
|
+
};
|
|
611
|
+
|
|
519
612
|
SourcesLayer.prototype._sourcesOverlapped = function(source1, source2) {
|
|
520
613
|
var endsLater = (source1.startTime < source2.startTime)
|
|
521
614
|
&& (source1.endTime > source2.startTime);
|
|
@@ -575,9 +668,11 @@ define([
|
|
|
575
668
|
this._peaks.off('sources.destroy', this._onSourcesDestroy);
|
|
576
669
|
this._peaks.off('sources.show', this._onSourcesShow);
|
|
577
670
|
this._peaks.off('sources.hide', this._onSourcesHide);
|
|
671
|
+
this._peaks.off('source.update', this._onSourceUpdate);
|
|
578
672
|
this._peaks.off('data.retrieved', this._onDataRetrieved);
|
|
579
673
|
this._peaks.off('sources.refresh', this._onSourcesRefresh);
|
|
580
674
|
this._peaks.off('segments.show', this._onSegmentsShow);
|
|
675
|
+
this._peaks.off('options.set.line_height', this._onOptionsLineHeightChange);
|
|
581
676
|
this._peaks.off('source.setIndicators', this.setIndicators);
|
|
582
677
|
};
|
|
583
678
|
|
package/src/timeline-zoomview.js
CHANGED
|
@@ -241,6 +241,10 @@ define([
|
|
|
241
241
|
// prevent parent scrolling
|
|
242
242
|
e.evt.preventDefault();
|
|
243
243
|
|
|
244
|
+
if (self._mouseDragHandler.isDragging()) {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
|
|
244
248
|
if (self._peaks.keyboardHandler.isCtrlCmdPressed()) {
|
|
245
249
|
if (e.evt.deltaY > 0) {
|
|
246
250
|
self.setZoom(
|
|
@@ -288,38 +292,50 @@ define([
|
|
|
288
292
|
}
|
|
289
293
|
}
|
|
290
294
|
});
|
|
295
|
+
|
|
296
|
+
window.addEventListener('mouseup', this._mouseUp.bind(this), false);
|
|
297
|
+
window.addEventListener('touchend', this._mouseUp.bind(this), false);
|
|
298
|
+
window.addEventListener('blur', this._mouseUp.bind(this), false);
|
|
291
299
|
}
|
|
292
300
|
|
|
293
|
-
TimelineZoomView.prototype.
|
|
301
|
+
TimelineZoomView.prototype._mouseUp = function() {
|
|
302
|
+
this.clearScrollingInterval();
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
TimelineZoomView.prototype.getSelectedElements = function() {
|
|
306
|
+
return this._modeLayer.getSelectedElements();
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
TimelineZoomView.prototype.updateWithAutoScroll = function(updateInInterval,
|
|
294
310
|
updateOutInterval) {
|
|
295
311
|
var self = this;
|
|
296
312
|
var posX = this.getPointerPosition().x;
|
|
297
313
|
var threshold = Math.round(this._peaks.options.autoScrollThreshold * this.getWidth());
|
|
298
314
|
|
|
299
|
-
|
|
315
|
+
this._limited = 0;
|
|
300
316
|
|
|
301
317
|
if (posX < threshold) {
|
|
302
|
-
|
|
318
|
+
this._limited = Math.round(-30 * Math.min(1, (threshold - posX) / threshold));
|
|
303
319
|
}
|
|
304
320
|
else if (posX > this.getWidth() - threshold) {
|
|
305
|
-
|
|
321
|
+
this._limited = Math.round(
|
|
306
322
|
30 * Math.min(1, (posX - (this.getWidth() - threshold)) / threshold)
|
|
307
323
|
);
|
|
308
324
|
}
|
|
309
325
|
|
|
310
|
-
if (
|
|
311
|
-
if (!
|
|
312
|
-
|
|
326
|
+
if (this._limited && self.getFrameOffset() > 0 || this._limited > 0) {
|
|
327
|
+
if (!this._scrollingInterval) {
|
|
328
|
+
this._scrollingInterval = setInterval(
|
|
313
329
|
function() {
|
|
314
|
-
var newOffset = self.getFrameOffset() +
|
|
330
|
+
var newOffset = self.getFrameOffset() + self._limited;
|
|
315
331
|
|
|
316
332
|
if (newOffset < 0) {
|
|
317
333
|
self.updateTimeline(0, null, false);
|
|
318
|
-
clearInterval(
|
|
319
|
-
|
|
334
|
+
clearInterval(self._scrollingInterval);
|
|
335
|
+
self._scrollingInterval = null;
|
|
320
336
|
}
|
|
321
337
|
else {
|
|
322
|
-
self.updateTimeline(self.getFrameOffset() +
|
|
338
|
+
self.updateTimeline(self.getFrameOffset() + self._limited, null, false);
|
|
323
339
|
}
|
|
324
340
|
|
|
325
341
|
updateInInterval();
|
|
@@ -329,10 +345,7 @@ define([
|
|
|
329
345
|
}
|
|
330
346
|
}
|
|
331
347
|
else {
|
|
332
|
-
|
|
333
|
-
clearInterval(obj._scrollingInterval);
|
|
334
|
-
obj._scrollingInterval = null;
|
|
335
|
-
}
|
|
348
|
+
this.clearScrollingInterval();
|
|
336
349
|
|
|
337
350
|
if (updateOutInterval) {
|
|
338
351
|
updateOutInterval();
|
|
@@ -341,11 +354,13 @@ define([
|
|
|
341
354
|
updateInInterval();
|
|
342
355
|
}
|
|
343
356
|
}
|
|
357
|
+
};
|
|
344
358
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
359
|
+
TimelineZoomView.prototype.clearScrollingInterval = function() {
|
|
360
|
+
if (this._scrollingInterval) {
|
|
361
|
+
clearInterval(this._scrollingInterval);
|
|
362
|
+
this._scrollingInterval = null;
|
|
363
|
+
}
|
|
349
364
|
};
|
|
350
365
|
|
|
351
366
|
TimelineZoomView.prototype.getCurrentMode = function() {
|
|
@@ -365,16 +380,28 @@ define([
|
|
|
365
380
|
this._sourcesLayer.draw();
|
|
366
381
|
};
|
|
367
382
|
|
|
383
|
+
TimelineZoomView.prototype.getSelectedElements = function() {
|
|
384
|
+
return this._modeLayer.getSelectedElements();
|
|
385
|
+
};
|
|
386
|
+
|
|
368
387
|
TimelineZoomView.prototype.selectSourceById = function(sourceId) {
|
|
369
|
-
|
|
388
|
+
const sourceGroup = this._sourcesLayer.getSourceGroupById(sourceId);
|
|
370
389
|
|
|
371
390
|
if (sourceGroup) {
|
|
372
|
-
this._modeLayer.
|
|
391
|
+
this._modeLayer.selectElements([sourceGroup.getSource()], false);
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
TimelineZoomView.prototype.selectSourcesOnLineAfter = function(lineId, time) {
|
|
396
|
+
const sources = this._sourcesLayer.getSourcesOnLineAfter(lineId, time);
|
|
397
|
+
|
|
398
|
+
if (sources) {
|
|
399
|
+
this._modeLayer.selectElements(sources, false);
|
|
373
400
|
}
|
|
374
401
|
};
|
|
375
402
|
|
|
376
|
-
TimelineZoomView.prototype.
|
|
377
|
-
this._modeLayer.
|
|
403
|
+
TimelineZoomView.prototype.deselectAll = function() {
|
|
404
|
+
this._modeLayer.deselectAll(false);
|
|
378
405
|
};
|
|
379
406
|
|
|
380
407
|
TimelineZoomView.prototype.isListening = function() {
|