@checksub_team/peaks_timeline 1.8.2 → 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 +324 -177
- 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 +101 -139
- package/src/source.js +35 -3
- package/src/sources-layer.js +109 -3
- package/src/timeline-sources.js +2 -1
- package/src/timeline-zoomview.js +50 -23
package/peaks.js
CHANGED
|
@@ -15064,6 +15064,23 @@ module.exports = function (Konva, Utils) {
|
|
|
15064
15064
|
}
|
|
15065
15065
|
return newXs;
|
|
15066
15066
|
};
|
|
15067
|
+
Line.prototype.getSourcesAfter = function (time) {
|
|
15068
|
+
const sources = [];
|
|
15069
|
+
var currentId = this._firstSourceId;
|
|
15070
|
+
while (currentId) {
|
|
15071
|
+
var lineSource = this._sources[currentId];
|
|
15072
|
+
if (lineSource.source.startTime >= time) {
|
|
15073
|
+
while (currentId) {
|
|
15074
|
+
lineSource = this._sources[currentId];
|
|
15075
|
+
sources.push(lineSource.source);
|
|
15076
|
+
currentId = lineSource.nextSourceId;
|
|
15077
|
+
}
|
|
15078
|
+
break;
|
|
15079
|
+
}
|
|
15080
|
+
currentId = lineSource.nextSourceId;
|
|
15081
|
+
}
|
|
15082
|
+
return sources;
|
|
15083
|
+
};
|
|
15067
15084
|
Line.prototype.updatePosition = function (pos) {
|
|
15068
15085
|
for (var sourceId in this._sources) {
|
|
15069
15086
|
if (Utils.objectHasProperty(this._sources, sourceId)) {
|
|
@@ -15210,6 +15227,9 @@ module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
|
|
|
15210
15227
|
}
|
|
15211
15228
|
return positions;
|
|
15212
15229
|
};
|
|
15230
|
+
Lines.prototype.getSourcesOnLineAfter = function (lineId, time) {
|
|
15231
|
+
return this._linesByPosition[lineId].getSourcesAfter(time);
|
|
15232
|
+
};
|
|
15213
15233
|
Lines.prototype.getSegmentsGroups = function () {
|
|
15214
15234
|
return this._segmentsGroups;
|
|
15215
15235
|
};
|
|
@@ -15610,11 +15630,17 @@ module.exports = function (Colors, EventEmitter, TimelineSegments, TimelineSourc
|
|
|
15610
15630
|
Peaks.prototype.allowInteractions = function (forSources, forSegments) {
|
|
15611
15631
|
return this.view.allowInteractions(forSources, forSegments);
|
|
15612
15632
|
};
|
|
15633
|
+
Peaks.prototype.getSelectedElements = function () {
|
|
15634
|
+
return this.view.getSelectedElements();
|
|
15635
|
+
};
|
|
15613
15636
|
Peaks.prototype.selectSourceById = function (sourceId) {
|
|
15614
15637
|
return this.view.selectSourceById(sourceId);
|
|
15615
15638
|
};
|
|
15616
|
-
Peaks.prototype.
|
|
15617
|
-
return this.view.
|
|
15639
|
+
Peaks.prototype.selectSourcesOnLineAfter = function (lineId, time) {
|
|
15640
|
+
return this.view.selectSourcesOnLineAfter(lineId, time);
|
|
15641
|
+
};
|
|
15642
|
+
Peaks.prototype.deselectAll = function () {
|
|
15643
|
+
return this.view.deselectAll();
|
|
15618
15644
|
};
|
|
15619
15645
|
Peaks.prototype._addWindowResizeHandler = function () {
|
|
15620
15646
|
this._onResize = this._onResize.bind(this);
|
|
@@ -15687,7 +15713,7 @@ module.exports = function (DefaultSegmentMarker, Utils, Konva) {
|
|
|
15687
15713
|
};
|
|
15688
15714
|
}(_dereq_('./default-segment-marker'), _dereq_('./utils'), _dereq_('konva'));
|
|
15689
15715
|
},{"./default-segment-marker":88,"./utils":112,"konva":43}],96:[function(_dereq_,module,exports){
|
|
15690
|
-
module.exports = function (Utils, SourceGroup, Konva) {
|
|
15716
|
+
module.exports = function (Utils, Source, SourceGroup, Konva) {
|
|
15691
15717
|
'use strict';
|
|
15692
15718
|
var TIME_X_OFFSET = 20;
|
|
15693
15719
|
var TIME_Y_OFFSET = 10;
|
|
@@ -15697,6 +15723,8 @@ module.exports = function (Utils, SourceGroup, Konva) {
|
|
|
15697
15723
|
this._view = view;
|
|
15698
15724
|
this._playheadLayer = playheadLayer;
|
|
15699
15725
|
this._stage = stage;
|
|
15726
|
+
this._selectedElements = {};
|
|
15727
|
+
this._currentLine = null;
|
|
15700
15728
|
this._layer = new Konva.Layer({ listening: this._mode !== 'default' });
|
|
15701
15729
|
this._prepareDefaultMode();
|
|
15702
15730
|
this._onMouseClickInDefaultMode = this._onMouseClickInDefaultMode.bind(this);
|
|
@@ -15711,33 +15739,60 @@ module.exports = function (Utils, SourceGroup, Konva) {
|
|
|
15711
15739
|
ModeLayer.prototype.addToStage = function (stage) {
|
|
15712
15740
|
stage.add(this._layer);
|
|
15713
15741
|
};
|
|
15714
|
-
ModeLayer.prototype.
|
|
15715
|
-
|
|
15716
|
-
|
|
15717
|
-
|
|
15718
|
-
|
|
15742
|
+
ModeLayer.prototype.selectElements = function (elements, notify) {
|
|
15743
|
+
const sources = [];
|
|
15744
|
+
const segments = [];
|
|
15745
|
+
const self = this;
|
|
15746
|
+
this.deselectAll(true);
|
|
15747
|
+
elements.forEach(function (element) {
|
|
15748
|
+
self._selectedElements[element.id] = element;
|
|
15749
|
+
element.setSelected(true);
|
|
15719
15750
|
if (notify) {
|
|
15720
|
-
if (element instanceof
|
|
15721
|
-
|
|
15751
|
+
if (element instanceof Source) {
|
|
15752
|
+
sources.push(element);
|
|
15722
15753
|
} else {
|
|
15723
|
-
|
|
15754
|
+
segments.push(element);
|
|
15724
15755
|
}
|
|
15725
15756
|
}
|
|
15757
|
+
});
|
|
15758
|
+
if (notify) {
|
|
15759
|
+
if (sources.length) {
|
|
15760
|
+
this._peaks.emit('sources.selected', sources);
|
|
15761
|
+
}
|
|
15762
|
+
if (segments.length) {
|
|
15763
|
+
this._peaks.emit('segments.selected', segments);
|
|
15764
|
+
}
|
|
15726
15765
|
}
|
|
15727
15766
|
};
|
|
15728
|
-
ModeLayer.prototype.
|
|
15729
|
-
|
|
15730
|
-
|
|
15731
|
-
|
|
15732
|
-
|
|
15733
|
-
|
|
15734
|
-
|
|
15735
|
-
|
|
15767
|
+
ModeLayer.prototype.deselectAll = function (notify) {
|
|
15768
|
+
const sources = [];
|
|
15769
|
+
const segments = [];
|
|
15770
|
+
for (var id in this._selectedElements) {
|
|
15771
|
+
if (Utils.objectHasProperty(this._selectedElements, id)) {
|
|
15772
|
+
const element = this._selectedElements[id];
|
|
15773
|
+
element.setSelected(false);
|
|
15774
|
+
if (notify) {
|
|
15775
|
+
if (element instanceof Source) {
|
|
15776
|
+
sources.push(element);
|
|
15777
|
+
} else {
|
|
15778
|
+
segments.push(element);
|
|
15779
|
+
}
|
|
15736
15780
|
}
|
|
15781
|
+
delete this._selectedElements[id];
|
|
15782
|
+
}
|
|
15783
|
+
}
|
|
15784
|
+
if (notify) {
|
|
15785
|
+
if (sources.length) {
|
|
15786
|
+
this._peaks.emit('sources.deselected', sources);
|
|
15787
|
+
}
|
|
15788
|
+
if (segments.length) {
|
|
15789
|
+
this._peaks.emit('segments.deselected', segments);
|
|
15737
15790
|
}
|
|
15738
|
-
this._selectedElement = null;
|
|
15739
15791
|
}
|
|
15740
15792
|
};
|
|
15793
|
+
ModeLayer.prototype.getSelectedElements = function () {
|
|
15794
|
+
return this._selectedElements;
|
|
15795
|
+
};
|
|
15741
15796
|
ModeLayer.prototype._prepareDefaultMode = function () {
|
|
15742
15797
|
this._selectedElement = null;
|
|
15743
15798
|
};
|
|
@@ -15787,24 +15842,30 @@ module.exports = function (Utils, SourceGroup, Konva) {
|
|
|
15787
15842
|
this._layer.add(this._cutGroup);
|
|
15788
15843
|
};
|
|
15789
15844
|
ModeLayer.prototype._onMouseClickInDefaultMode = function () {
|
|
15790
|
-
|
|
15791
|
-
if (
|
|
15792
|
-
|
|
15845
|
+
const hoveredKonvaElement = this._view.getHoveredElement();
|
|
15846
|
+
if (hoveredKonvaElement) {
|
|
15847
|
+
if (hoveredKonvaElement instanceof SourceGroup) {
|
|
15848
|
+
this.selectElements([hoveredKonvaElement.getSource()], true);
|
|
15849
|
+
} else {
|
|
15850
|
+
this.selectElements([hoveredKonvaElement.getSegment()], true);
|
|
15851
|
+
}
|
|
15793
15852
|
} else {
|
|
15794
|
-
this.
|
|
15853
|
+
this.deselectAll(true);
|
|
15854
|
+
this._view.drawSourcesLayer();
|
|
15795
15855
|
}
|
|
15796
15856
|
};
|
|
15797
15857
|
ModeLayer.prototype._onKeyboardDelete = function () {
|
|
15798
|
-
|
|
15799
|
-
|
|
15800
|
-
|
|
15801
|
-
|
|
15858
|
+
const selectedElements = Object.values(this._selectedElements);
|
|
15859
|
+
if (selectedElements.length) {
|
|
15860
|
+
var selectedElement = selectedElements[0];
|
|
15861
|
+
this.deselectAll(true);
|
|
15862
|
+
if (selectedElement instanceof Source) {
|
|
15802
15863
|
if (selectedElement.isDeletable()) {
|
|
15803
|
-
this._peaks.destroySource(selectedElement.
|
|
15864
|
+
this._peaks.destroySource(selectedElement.id);
|
|
15804
15865
|
}
|
|
15805
15866
|
} else {
|
|
15806
15867
|
if (selectedElement.getSegment().allowDeletion) {
|
|
15807
|
-
this._peaks.destroySegment(selectedElement.
|
|
15868
|
+
this._peaks.destroySegment(selectedElement.id);
|
|
15808
15869
|
}
|
|
15809
15870
|
}
|
|
15810
15871
|
}
|
|
@@ -15943,7 +16004,7 @@ module.exports = function (Utils, SourceGroup, Konva) {
|
|
|
15943
16004
|
this._peaks.off('keyboard.delete', this._onKeyboardDelete);
|
|
15944
16005
|
break;
|
|
15945
16006
|
}
|
|
15946
|
-
this.
|
|
16007
|
+
this.deselectAll(true);
|
|
15947
16008
|
switch (mode) {
|
|
15948
16009
|
case 'cut':
|
|
15949
16010
|
this._stage.on('mouseover', this._onMouseEnterInCutMode);
|
|
@@ -15980,8 +16041,8 @@ module.exports = function (Utils, SourceGroup, Konva) {
|
|
|
15980
16041
|
return this._mode;
|
|
15981
16042
|
};
|
|
15982
16043
|
return ModeLayer;
|
|
15983
|
-
}(_dereq_('./utils'), _dereq_('./source-group'), _dereq_('konva'));
|
|
15984
|
-
},{"./source-group":104,"./utils":112,"konva":43}],97:[function(_dereq_,module,exports){
|
|
16044
|
+
}(_dereq_('./utils'), _dereq_('./source'), _dereq_('./source-group'), _dereq_('konva'));
|
|
16045
|
+
},{"./source":105,"./source-group":104,"./utils":112,"konva":43}],97:[function(_dereq_,module,exports){
|
|
15985
16046
|
module.exports = function (Konva) {
|
|
15986
16047
|
'use strict';
|
|
15987
16048
|
function getMarkerObject(obj) {
|
|
@@ -16184,15 +16245,15 @@ module.exports = function (Utils, Konva) {
|
|
|
16184
16245
|
draggable: true,
|
|
16185
16246
|
dragBoundFunc: function (pos) {
|
|
16186
16247
|
var time = Math.max(0, self._view.pixelsToTime(pos.x + self._view.getFrameOffset()));
|
|
16187
|
-
|
|
16248
|
+
self._view.updateWithAutoScroll(function () {
|
|
16188
16249
|
time = Math.max(0, self._view.pixelsToTime(self._view.getPointerPosition().x + self._view.getFrameOffset()));
|
|
16189
16250
|
self._onPlayheadDrag(time);
|
|
16190
16251
|
}, function () {
|
|
16191
16252
|
self._onPlayheadDrag(time);
|
|
16192
16253
|
});
|
|
16193
16254
|
return {
|
|
16194
|
-
x:
|
|
16195
|
-
y:
|
|
16255
|
+
x: Math.max(pos.x, 0),
|
|
16256
|
+
y: 0
|
|
16196
16257
|
};
|
|
16197
16258
|
}
|
|
16198
16259
|
});
|
|
@@ -16210,7 +16271,6 @@ module.exports = function (Utils, Konva) {
|
|
|
16210
16271
|
PlayheadLayer.prototype._onPlayheadDragStart = function () {
|
|
16211
16272
|
this._view.enableAutoScroll(false);
|
|
16212
16273
|
this._dragging = true;
|
|
16213
|
-
this._scrollInterval = null;
|
|
16214
16274
|
};
|
|
16215
16275
|
PlayheadLayer.prototype._onPlayheadDragEnd = function () {
|
|
16216
16276
|
this._view.enableAutoScroll(true);
|
|
@@ -16412,7 +16472,6 @@ module.exports = function (Konva, SegmentMarker, Utils) {
|
|
|
16412
16472
|
this._endMarker = null;
|
|
16413
16473
|
this._shapeGroup = null;
|
|
16414
16474
|
this._rectangle = null;
|
|
16415
|
-
this._isSelected = false;
|
|
16416
16475
|
this._indicators = {};
|
|
16417
16476
|
var self = this;
|
|
16418
16477
|
this._segmentWidth = this._view.timeToPixels(this._segment.endTime - this._segment.startTime);
|
|
@@ -16448,14 +16507,7 @@ module.exports = function (Konva, SegmentMarker, Utils) {
|
|
|
16448
16507
|
});
|
|
16449
16508
|
this._shapeGroup.add(this._rectangle);
|
|
16450
16509
|
this._shapeGroup.dragBoundFunc(function () {
|
|
16451
|
-
|
|
16452
|
-
self._group.updateSegment(self._segment, self._initialStartPixel + diff, self._initialEndPixel + diff);
|
|
16453
|
-
self._startMarker.timeUpdated(self._segment.startTime);
|
|
16454
|
-
self._endMarker.timeUpdated(self._segment.endTime);
|
|
16455
|
-
return {
|
|
16456
|
-
x: this.absolutePosition().x,
|
|
16457
|
-
y: this.absolutePosition().y
|
|
16458
|
-
};
|
|
16510
|
+
return self._onShapeGroupDrag(this);
|
|
16459
16511
|
});
|
|
16460
16512
|
this._shapeGroup.on('mouseenter', this._onMouseEnter.bind(this));
|
|
16461
16513
|
this._shapeGroup.on('mouseleave', this._onMouseLeave.bind(this));
|
|
@@ -16480,6 +16532,16 @@ module.exports = function (Konva, SegmentMarker, Utils) {
|
|
|
16480
16532
|
this._shapeGroup.add(this._indicatorsGroup);
|
|
16481
16533
|
this.createIndicators();
|
|
16482
16534
|
}
|
|
16535
|
+
SegmentShape.prototype._onShapeGroupDrag = function (draggedElement) {
|
|
16536
|
+
const diff = this._view.getPointerPosition().x - this._mouseDownX;
|
|
16537
|
+
this._group.updateSegment(this._segment, this._initialStartPixel + diff, this._initialEndPixel + diff);
|
|
16538
|
+
this._startMarker.timeUpdated(this._segment.startTime);
|
|
16539
|
+
this._endMarker.timeUpdated(this._segment.endTime);
|
|
16540
|
+
return {
|
|
16541
|
+
x: draggedElement.absolutePosition().x,
|
|
16542
|
+
y: draggedElement.absolutePosition().y
|
|
16543
|
+
};
|
|
16544
|
+
};
|
|
16483
16545
|
SegmentShape.prototype._cornerRadius = function () {
|
|
16484
16546
|
return this._segment.borderRadius !== undefined && this._segment.borderRadius !== null ? this._segment.borderRadius : SEGMENT_CORNER_RADIUS;
|
|
16485
16547
|
};
|
|
@@ -16709,9 +16771,6 @@ module.exports = function (Konva, SegmentMarker, Utils) {
|
|
|
16709
16771
|
var startMarker = segmentMarker.isStartMarker();
|
|
16710
16772
|
this._peaks.emit('segments.dragend', this._segment, startMarker);
|
|
16711
16773
|
};
|
|
16712
|
-
SegmentShape.prototype.setSelected = function (isSelected) {
|
|
16713
|
-
this._isSelected = isSelected;
|
|
16714
|
-
};
|
|
16715
16774
|
SegmentShape.prototype.fitToView = function () {
|
|
16716
16775
|
if (this._startMarker) {
|
|
16717
16776
|
this._startMarker.fitToView();
|
|
@@ -16845,6 +16904,7 @@ module.exports = function (Utils) {
|
|
|
16845
16904
|
this._indicators = opts.indicators;
|
|
16846
16905
|
this._minSize = peaks.options.minSegmentSize;
|
|
16847
16906
|
this._relativeId = 0;
|
|
16907
|
+
this._selected = false;
|
|
16848
16908
|
if (shouldNotifyUpdate) {
|
|
16849
16909
|
peaks.emit('segments.updated', [this]);
|
|
16850
16910
|
}
|
|
@@ -17024,6 +17084,9 @@ module.exports = function (Utils) {
|
|
|
17024
17084
|
this._indicators = opts.indicators;
|
|
17025
17085
|
this._peaks.emit('segment.updated', this);
|
|
17026
17086
|
};
|
|
17087
|
+
Segment.prototype.setSelected = function (selected) {
|
|
17088
|
+
this._selected = selected;
|
|
17089
|
+
};
|
|
17027
17090
|
Segment.prototype.isVisible = function (startTime, endTime) {
|
|
17028
17091
|
return this.startTime < endTime && startTime < this.endTime;
|
|
17029
17092
|
};
|
|
@@ -17565,11 +17628,15 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
|
|
|
17565
17628
|
var SPACING_BETWEEN_PREVIEW_AND_BORDER_RATIO = 0.15;
|
|
17566
17629
|
var SPACING_BETWEEN_PREVIEWS = 1.5;
|
|
17567
17630
|
var CORNER_RADIUS = 8;
|
|
17631
|
+
var INDICATOR_RADIUS = 4;
|
|
17632
|
+
var INDICATORS_MARGIN_LEFT = 8;
|
|
17633
|
+
var INDICATORS_MARGIN_TOP = 12;
|
|
17568
17634
|
function SourceGroup(source, peaks, layer, view) {
|
|
17569
17635
|
this._source = source;
|
|
17570
17636
|
this._peaks = peaks;
|
|
17571
17637
|
this._layer = layer;
|
|
17572
17638
|
this._view = view;
|
|
17639
|
+
this._indicators = {};
|
|
17573
17640
|
var self = this;
|
|
17574
17641
|
this._x = this._view.timeToPixels(source.startTime);
|
|
17575
17642
|
this._width = this._view.timeToPixels(source.endTime - source.startTime);
|
|
@@ -17579,15 +17646,14 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
|
|
|
17579
17646
|
this._previewList = [];
|
|
17580
17647
|
this._group = new Konva.Group({
|
|
17581
17648
|
x: this._x,
|
|
17649
|
+
sourceId: this._source.id,
|
|
17582
17650
|
draggable: this._source.draggable,
|
|
17583
17651
|
dragBoundFunc: function () {
|
|
17584
|
-
return
|
|
17585
|
-
x: this.absolutePosition().x,
|
|
17586
|
-
y: this.absolutePosition().y
|
|
17587
|
-
};
|
|
17652
|
+
return self._layer.onSourcesGroupDrag(this);
|
|
17588
17653
|
}
|
|
17589
17654
|
});
|
|
17590
|
-
this._group.on('dragstart', this.
|
|
17655
|
+
this._group.on('dragstart', this._layer.onSourcesGroupDragStart.bind(this._layer));
|
|
17656
|
+
this._group.on('dragend', this._layer.onSourcesGroupDragEnd.bind(this._layer));
|
|
17591
17657
|
this._group.on('mouseover', function () {
|
|
17592
17658
|
self._view.setHoveredElement(self);
|
|
17593
17659
|
if (self._view.getCurrentMode() === 'cut') {
|
|
@@ -17602,7 +17668,6 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
|
|
|
17602
17668
|
self.toggleResizing(true);
|
|
17603
17669
|
}
|
|
17604
17670
|
});
|
|
17605
|
-
this._group.on('dragend', this._onSourceGroupDragEnd.bind(this));
|
|
17606
17671
|
this._group.add(new Konva.Group());
|
|
17607
17672
|
if (this._borderWidth) {
|
|
17608
17673
|
this._border = new Konva.Shape({
|
|
@@ -17615,48 +17680,27 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
|
|
|
17615
17680
|
}
|
|
17616
17681
|
this._addHandles();
|
|
17617
17682
|
this.setWrapping(source.wrapped);
|
|
17683
|
+
this._setSelected();
|
|
17684
|
+
this._indicatorsGroup = new Konva.Group();
|
|
17685
|
+
this._group.add(this._indicatorsGroup);
|
|
17686
|
+
this.createIndicators();
|
|
17618
17687
|
}
|
|
17619
|
-
SourceGroup.prototype.
|
|
17620
|
-
this._dragged = true;
|
|
17621
|
-
this._mouseDownX = this._view.getPointerPosition().x;
|
|
17622
|
-
this._initialStartTime = this._source.startTime;
|
|
17623
|
-
this._initialStartPixel = this._view.timeToPixels(this._initialStartTime);
|
|
17624
|
-
this._initialEndTime = this._source.endTime;
|
|
17625
|
-
this._initialEndPixel = this._view.timeToPixels(this._initialEndTime);
|
|
17626
|
-
this._initialFrameOffset = this._view.getFrameOffset();
|
|
17627
|
-
};
|
|
17628
|
-
SourceGroup.prototype._onSourceGroupDragEnd = function () {
|
|
17688
|
+
SourceGroup.prototype.prepareDragEnd = function () {
|
|
17629
17689
|
var handleWidth = Math.min(this._peaks.options.sourceHandleWidth, this._width / 2);
|
|
17630
17690
|
this._leftHandle.width(handleWidth);
|
|
17631
17691
|
this._rightHandle.width(handleWidth);
|
|
17632
17692
|
this._rightHandle.x(this._width - handleWidth);
|
|
17633
|
-
this._view.drawSourcesLayer();
|
|
17634
|
-
this._dragged = false;
|
|
17635
|
-
this._view.updateTimelineLength();
|
|
17636
|
-
this._peaks.emit('sources.updated', [this._source]);
|
|
17637
|
-
};
|
|
17638
|
-
SourceGroup.prototype._onSourceGroupDrag = function (draggedElement) {
|
|
17639
|
-
var self = this;
|
|
17640
|
-
var pos = this._view.updateWithAutoScroll(draggedElement, function () {
|
|
17641
|
-
var mousePos = Math.min(self._view.getWidth() - self._peaks.options.autoScrollThreshold * self._view.getWidth(), Math.max(0, self._view.getPointerPosition().x));
|
|
17642
|
-
var diff = mousePos - self._mouseDownX;
|
|
17643
|
-
self._layer.updateSource(self._source, self._initialStartPixel + diff + (self._view.getFrameOffset() - self._initialFrameOffset), self._initialEndPixel + diff + (self._view.getFrameOffset() - self._initialFrameOffset), self._view.getPointerPosition().y);
|
|
17644
|
-
self._view.setTimelineLength(self._view.timeToPixels(self._source.endTime) + self._view.getWidth());
|
|
17645
|
-
});
|
|
17646
|
-
return {
|
|
17647
|
-
x: pos.x,
|
|
17648
|
-
y: pos.y
|
|
17649
|
-
};
|
|
17650
17693
|
};
|
|
17651
17694
|
SourceGroup.prototype._onSourceGroupHandleDrag = function (draggedElement, dragPos, leftHandle) {
|
|
17652
|
-
|
|
17653
|
-
|
|
17654
|
-
|
|
17655
|
-
|
|
17695
|
+
this._view.updateWithAutoScroll(function () {
|
|
17696
|
+
if (this._layer.updateSource(this._source, leftHandle ? dragPos.x + this._view.getFrameOffset() : null, leftHandle ? null : dragPos.x + draggedElement.width() + this._view.getFrameOffset())) {
|
|
17697
|
+
this._layer.draw();
|
|
17698
|
+
}
|
|
17699
|
+
}.bind(this));
|
|
17656
17700
|
this._view.setTimelineLength(this._view.timeToPixels(this._source.endTime) + this._view.getWidth());
|
|
17657
17701
|
return {
|
|
17658
|
-
x:
|
|
17659
|
-
y:
|
|
17702
|
+
x: draggedElement.absolutePosition().x,
|
|
17703
|
+
y: draggedElement.absolutePosition().y
|
|
17660
17704
|
};
|
|
17661
17705
|
};
|
|
17662
17706
|
SourceGroup.prototype.update = function () {
|
|
@@ -17710,12 +17754,6 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
|
|
|
17710
17754
|
}
|
|
17711
17755
|
});
|
|
17712
17756
|
if (this._source.resizable) {
|
|
17713
|
-
this._leftHandle.on('dragend', function () {
|
|
17714
|
-
if (this._scrollingInterval) {
|
|
17715
|
-
clearInterval(this._scrollingInterval);
|
|
17716
|
-
this._scrollingInterval = null;
|
|
17717
|
-
}
|
|
17718
|
-
});
|
|
17719
17757
|
this._leftHandle.on('mouseover', function () {
|
|
17720
17758
|
self._view.setCursor('ew-resize');
|
|
17721
17759
|
});
|
|
@@ -17736,12 +17774,6 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
|
|
|
17736
17774
|
}
|
|
17737
17775
|
});
|
|
17738
17776
|
if (this._source.resizable) {
|
|
17739
|
-
this._rightHandle.on('dragend', function () {
|
|
17740
|
-
if (this._scrollingInterval) {
|
|
17741
|
-
clearInterval(this._scrollingInterval);
|
|
17742
|
-
this._scrollingInterval = null;
|
|
17743
|
-
}
|
|
17744
|
-
});
|
|
17745
17777
|
this._rightHandle.on('mouseover', function () {
|
|
17746
17778
|
self._view.setCursor('ew-resize');
|
|
17747
17779
|
});
|
|
@@ -17812,13 +17844,6 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
|
|
|
17812
17844
|
var unwrap = new Konva.Group({
|
|
17813
17845
|
width: this._width,
|
|
17814
17846
|
height: this._unwrappedHeight,
|
|
17815
|
-
draggable: this._source.draggable,
|
|
17816
|
-
dragBoundFunc: function () {
|
|
17817
|
-
return {
|
|
17818
|
-
x: this.absolutePosition().x,
|
|
17819
|
-
y: this.absolutePosition().y
|
|
17820
|
-
};
|
|
17821
|
-
},
|
|
17822
17847
|
clipFunc: function (ctx) {
|
|
17823
17848
|
self.drawSourceShape(ctx, null, true);
|
|
17824
17849
|
}
|
|
@@ -17830,25 +17855,12 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
|
|
|
17830
17855
|
unwrap.on('mouseout', function () {
|
|
17831
17856
|
self._view.setCursor('default');
|
|
17832
17857
|
});
|
|
17833
|
-
unwrap.on('dragstart', function () {
|
|
17834
|
-
this._scrollInterval = null;
|
|
17835
|
-
});
|
|
17836
|
-
unwrap.on('dragend', function () {
|
|
17837
|
-
if (this._scrollingInterval) {
|
|
17838
|
-
clearInterval(this._scrollingInterval);
|
|
17839
|
-
this._scrollingInterval = null;
|
|
17840
|
-
}
|
|
17841
|
-
});
|
|
17842
17858
|
}
|
|
17843
17859
|
var background = new Konva.Group();
|
|
17844
17860
|
background.add(new Konva.Shape({
|
|
17845
17861
|
fill: this._source.backgroundColor,
|
|
17846
17862
|
sceneFunc: function (ctx, shape) {
|
|
17847
17863
|
self.drawSourceShape(ctx, shape, true);
|
|
17848
|
-
},
|
|
17849
|
-
draggable: this._source.draggable,
|
|
17850
|
-
dragBoundFunc: function () {
|
|
17851
|
-
return self._onSourceGroupDrag(this);
|
|
17852
17864
|
}
|
|
17853
17865
|
}));
|
|
17854
17866
|
unwrap.add(background);
|
|
@@ -17878,13 +17890,6 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
|
|
|
17878
17890
|
var wrap = new Konva.Group({
|
|
17879
17891
|
width: this._width,
|
|
17880
17892
|
height: this._wrappedHeight,
|
|
17881
|
-
draggable: this._source.draggable,
|
|
17882
|
-
dragBoundFunc: function () {
|
|
17883
|
-
return {
|
|
17884
|
-
x: this.absolutePosition().x,
|
|
17885
|
-
y: this.absolutePosition().y
|
|
17886
|
-
};
|
|
17887
|
-
},
|
|
17888
17893
|
clipFunc: function (ctx) {
|
|
17889
17894
|
self.drawSourceShape(ctx, null, true);
|
|
17890
17895
|
}
|
|
@@ -17896,25 +17901,12 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
|
|
|
17896
17901
|
wrap.on('mouseout', function () {
|
|
17897
17902
|
self._view.setCursor('default');
|
|
17898
17903
|
});
|
|
17899
|
-
wrap.on('dragstart', function () {
|
|
17900
|
-
this._scrollInterval = null;
|
|
17901
|
-
});
|
|
17902
|
-
wrap.on('dragend', function () {
|
|
17903
|
-
if (this._scrollingInterval) {
|
|
17904
|
-
clearInterval(this._scrollingInterval);
|
|
17905
|
-
this._scrollingInterval = null;
|
|
17906
|
-
}
|
|
17907
|
-
});
|
|
17908
17904
|
}
|
|
17909
17905
|
var background = new Konva.Group();
|
|
17910
17906
|
background.add(new Konva.Shape({
|
|
17911
17907
|
fill: this._source.backgroundColor,
|
|
17912
17908
|
sceneFunc: function (ctx, shape) {
|
|
17913
17909
|
self.drawSourceShape(ctx, shape, true);
|
|
17914
|
-
},
|
|
17915
|
-
draggable: this._source.draggable,
|
|
17916
|
-
dragBoundFunc: function () {
|
|
17917
|
-
return self._onSourceGroupDrag(this);
|
|
17918
17910
|
}
|
|
17919
17911
|
}));
|
|
17920
17912
|
wrap.add(background);
|
|
@@ -18151,9 +18143,9 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
|
|
|
18151
18143
|
return preview.type === 'audio';
|
|
18152
18144
|
});
|
|
18153
18145
|
};
|
|
18154
|
-
SourceGroup.prototype.
|
|
18146
|
+
SourceGroup.prototype._setSelected = function () {
|
|
18155
18147
|
if (this._border) {
|
|
18156
|
-
if (
|
|
18148
|
+
if (this._source._selected) {
|
|
18157
18149
|
this._border.fill(this._source.selectedColor);
|
|
18158
18150
|
this._borderWidth = this._peaks.options.sourceSelectedBorderWidth;
|
|
18159
18151
|
} else {
|
|
@@ -18166,7 +18158,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
|
|
|
18166
18158
|
return node.getClassName() === 'Shape';
|
|
18167
18159
|
});
|
|
18168
18160
|
if (unwrap_background) {
|
|
18169
|
-
if (
|
|
18161
|
+
if (this._source._selected) {
|
|
18170
18162
|
unwrap_background.stroke(this._source.selectedColor);
|
|
18171
18163
|
unwrap_background.strokeWidth(this._peaks.options.sourceSelectedBorderWidth);
|
|
18172
18164
|
} else {
|
|
@@ -18179,7 +18171,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
|
|
|
18179
18171
|
return node.getClassName() === 'Shape';
|
|
18180
18172
|
});
|
|
18181
18173
|
if (wrap_background) {
|
|
18182
|
-
if (
|
|
18174
|
+
if (this._source._selected) {
|
|
18183
18175
|
wrap_background.stroke(this._source.selectedColor);
|
|
18184
18176
|
wrap_background.strokeWidth(this._peaks.options.sourceSelectedBorderWidth);
|
|
18185
18177
|
} else {
|
|
@@ -18188,7 +18180,6 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
|
|
|
18188
18180
|
}
|
|
18189
18181
|
}
|
|
18190
18182
|
}
|
|
18191
|
-
this._view.drawSourcesLayer();
|
|
18192
18183
|
};
|
|
18193
18184
|
SourceGroup.prototype.updatePreviews = function () {
|
|
18194
18185
|
var self = this;
|
|
@@ -18286,9 +18277,6 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
|
|
|
18286
18277
|
SourceGroup.prototype.isVisible = function () {
|
|
18287
18278
|
return this._group.visible();
|
|
18288
18279
|
};
|
|
18289
|
-
SourceGroup.prototype.isDragged = function () {
|
|
18290
|
-
return this._dragged;
|
|
18291
|
-
};
|
|
18292
18280
|
SourceGroup.prototype.isCuttable = function () {
|
|
18293
18281
|
return this._source.cuttable;
|
|
18294
18282
|
};
|
|
@@ -18298,6 +18286,57 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
|
|
|
18298
18286
|
SourceGroup.prototype.destroy = function () {
|
|
18299
18287
|
this._group.destroy();
|
|
18300
18288
|
};
|
|
18289
|
+
SourceGroup.prototype.getLine = function () {
|
|
18290
|
+
return this._source.position;
|
|
18291
|
+
};
|
|
18292
|
+
SourceGroup.prototype.createIndicators = function () {
|
|
18293
|
+
var newIndicatorsColors = this._source.indicators;
|
|
18294
|
+
var oldIndicators = this._indicators;
|
|
18295
|
+
var newIndicators = {};
|
|
18296
|
+
if (newIndicatorsColors) {
|
|
18297
|
+
newIndicatorsColors.forEach(function (indicatorColor) {
|
|
18298
|
+
var oldIndicator = oldIndicators[indicatorColor];
|
|
18299
|
+
if (oldIndicator) {
|
|
18300
|
+
newIndicators[indicatorColor] = oldIndicator;
|
|
18301
|
+
delete oldIndicators[indicatorColor];
|
|
18302
|
+
} else {
|
|
18303
|
+
newIndicators[indicatorColor] = null;
|
|
18304
|
+
}
|
|
18305
|
+
});
|
|
18306
|
+
for (var color in oldIndicators) {
|
|
18307
|
+
if (Utils.objectHasProperty(oldIndicators, color)) {
|
|
18308
|
+
oldIndicators[color].destroy();
|
|
18309
|
+
}
|
|
18310
|
+
}
|
|
18311
|
+
}
|
|
18312
|
+
this._indicators = Object.keys(newIndicators).sort().reverse().reduce(function (objEntries, key) {
|
|
18313
|
+
objEntries[key] = newIndicators[key];
|
|
18314
|
+
return objEntries;
|
|
18315
|
+
}, {});
|
|
18316
|
+
this._createIndicators();
|
|
18317
|
+
};
|
|
18318
|
+
SourceGroup.prototype._createIndicators = function () {
|
|
18319
|
+
var currentX = 0;
|
|
18320
|
+
var zIndex = 0;
|
|
18321
|
+
for (var color in this._indicators) {
|
|
18322
|
+
if (Utils.objectHasProperty(this._indicators, color)) {
|
|
18323
|
+
if (!this._indicators[color]) {
|
|
18324
|
+
this._indicators[color] = new Konva.Circle({
|
|
18325
|
+
radius: INDICATOR_RADIUS,
|
|
18326
|
+
fill: color,
|
|
18327
|
+
strokeEnabled: false
|
|
18328
|
+
});
|
|
18329
|
+
this._indicatorsGroup.add(this._indicators[color]);
|
|
18330
|
+
}
|
|
18331
|
+
this._indicators[color].x(currentX);
|
|
18332
|
+
this._indicators[color].zIndex(zIndex);
|
|
18333
|
+
currentX -= INDICATOR_RADIUS;
|
|
18334
|
+
zIndex += 1;
|
|
18335
|
+
}
|
|
18336
|
+
}
|
|
18337
|
+
this._indicatorsGroup.offsetX(currentX - INDICATORS_MARGIN_LEFT);
|
|
18338
|
+
this._indicatorsGroup.offsetY(-INDICATORS_MARGIN_TOP);
|
|
18339
|
+
};
|
|
18301
18340
|
return SourceGroup;
|
|
18302
18341
|
}(_dereq_('./waveform-builder'), _dereq_('./waveform-shape'), _dereq_('./utils'), _dereq_('konva'));
|
|
18303
18342
|
},{"./utils":112,"./waveform-builder":113,"./waveform-shape":114,"konva":43}],105:[function(_dereq_,module,exports){
|
|
@@ -18468,8 +18507,11 @@ module.exports = function (Utils) {
|
|
|
18468
18507
|
} else if (options.wrapping === 'complete') {
|
|
18469
18508
|
options.wrapped = false;
|
|
18470
18509
|
}
|
|
18510
|
+
if (Utils.isNullOrUndefined(options.indicators)) {
|
|
18511
|
+
options.indicators = [];
|
|
18512
|
+
}
|
|
18471
18513
|
}
|
|
18472
|
-
function Source(peaks, id, originId, elementId, title, url, previewUrl, binaryUrl, kind, subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor, borderColor, selectedColor, textFont, textFontSize, textColor, textBackgroundColor, textPosition, borderWidth, borderRadius, wrapped, position, draggable, orderable, resizable, cuttable, deletable, wrapping, previewHeight, binaryHeight) {
|
|
18514
|
+
function Source(peaks, id, originId, elementId, title, url, previewUrl, binaryUrl, kind, subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor, borderColor, selectedColor, textFont, textFontSize, textColor, textBackgroundColor, textPosition, borderWidth, borderRadius, wrapped, position, draggable, orderable, resizable, cuttable, deletable, wrapping, previewHeight, binaryHeight, indicators) {
|
|
18473
18515
|
var opts = {
|
|
18474
18516
|
title: title,
|
|
18475
18517
|
url: url,
|
|
@@ -18502,7 +18544,8 @@ module.exports = function (Utils) {
|
|
|
18502
18544
|
deletable: deletable,
|
|
18503
18545
|
wrapping: wrapping,
|
|
18504
18546
|
previewHeight: previewHeight,
|
|
18505
|
-
binaryHeight: binaryHeight
|
|
18547
|
+
binaryHeight: binaryHeight,
|
|
18548
|
+
indicators: indicators
|
|
18506
18549
|
};
|
|
18507
18550
|
validateSource(peaks, opts, 'add()');
|
|
18508
18551
|
this._peaks = peaks;
|
|
@@ -18541,7 +18584,9 @@ module.exports = function (Utils) {
|
|
|
18541
18584
|
this._wrapping = opts.wrapping;
|
|
18542
18585
|
this._previewHeight = opts.previewHeight;
|
|
18543
18586
|
this._binaryHeight = opts.binaryHeight;
|
|
18587
|
+
this._indicators = opts.indicators;
|
|
18544
18588
|
this._minSize = peaks.options.minSourceSize;
|
|
18589
|
+
this._selected = false;
|
|
18545
18590
|
}
|
|
18546
18591
|
Object.defineProperties(Source.prototype, {
|
|
18547
18592
|
id: {
|
|
@@ -18823,6 +18868,12 @@ module.exports = function (Utils) {
|
|
|
18823
18868
|
this._binaryHeight = binaryHeight;
|
|
18824
18869
|
}
|
|
18825
18870
|
},
|
|
18871
|
+
indicators: {
|
|
18872
|
+
enumerable: true,
|
|
18873
|
+
get: function () {
|
|
18874
|
+
return this._indicators;
|
|
18875
|
+
}
|
|
18876
|
+
},
|
|
18826
18877
|
minSize: {
|
|
18827
18878
|
enumerable: true,
|
|
18828
18879
|
get: function () {
|
|
@@ -18947,7 +18998,8 @@ module.exports = function (Utils) {
|
|
|
18947
18998
|
deletable: this.deletable,
|
|
18948
18999
|
wrapping: this.wrapping,
|
|
18949
19000
|
previewHeight: this.previewHeight,
|
|
18950
|
-
binaryHeight: this.binaryHeight
|
|
19001
|
+
binaryHeight: this.binaryHeight,
|
|
19002
|
+
indicators: this.indicators
|
|
18951
19003
|
};
|
|
18952
19004
|
Utils.extend(opts, options);
|
|
18953
19005
|
validateSource(this._peaks, opts, 'update()');
|
|
@@ -18983,11 +19035,20 @@ module.exports = function (Utils) {
|
|
|
18983
19035
|
this._wrapping = opts.wrapping;
|
|
18984
19036
|
this._previewHeight = opts.previewHeight;
|
|
18985
19037
|
this._binaryHeight = opts.binaryHeight;
|
|
19038
|
+
this._indicators = opts.indicators;
|
|
19039
|
+
this._peaks.emit('source.update', this);
|
|
19040
|
+
};
|
|
19041
|
+
Source.prototype.setSelected = function (selected) {
|
|
19042
|
+
this._selected = selected;
|
|
18986
19043
|
this._peaks.emit('source.update', this);
|
|
18987
19044
|
};
|
|
18988
19045
|
Source.prototype.isVisible = function (startTime, endTime) {
|
|
18989
19046
|
return this._startTime < endTime && startTime < this._endTime;
|
|
18990
19047
|
};
|
|
19048
|
+
Source.prototype.setIndicators = function (newIndicators) {
|
|
19049
|
+
this._indicators = newIndicators;
|
|
19050
|
+
this._peaks.emit('source.setIndicators', this);
|
|
19051
|
+
};
|
|
18991
19052
|
return Source;
|
|
18992
19053
|
}(_dereq_('./utils'));
|
|
18993
19054
|
},{"./utils":112}],106:[function(_dereq_,module,exports){
|
|
@@ -19013,6 +19074,7 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
19013
19074
|
this._peaks.on('sources.refresh', this._onSourcesRefresh.bind(this));
|
|
19014
19075
|
this._peaks.on('segments.show', this._onSegmentsShow.bind(this));
|
|
19015
19076
|
this._peaks.on('options.set.line_height', this._onOptionsLineHeightChange.bind(this));
|
|
19077
|
+
this._peaks.on('source.setIndicators', this.setIndicators.bind(this));
|
|
19016
19078
|
}
|
|
19017
19079
|
SourcesLayer.prototype.fitToView = function () {
|
|
19018
19080
|
this._lines.fitToView();
|
|
@@ -19159,6 +19221,13 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
19159
19221
|
this._dataRetriever.retrieveData(source);
|
|
19160
19222
|
return sourceGroup;
|
|
19161
19223
|
};
|
|
19224
|
+
SourcesLayer.prototype.setIndicators = function (source) {
|
|
19225
|
+
var sourceGroup = this._sourcesGroup[source.id];
|
|
19226
|
+
if (sourceGroup) {
|
|
19227
|
+
sourceGroup.createIndicators();
|
|
19228
|
+
this._layer.draw();
|
|
19229
|
+
}
|
|
19230
|
+
};
|
|
19162
19231
|
SourcesLayer.prototype.updateSources = function (startTime, endTime) {
|
|
19163
19232
|
this._lines.updateSegments(startTime, endTime);
|
|
19164
19233
|
var sources = this.findSources(startTime, endTime);
|
|
@@ -19170,6 +19239,57 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
19170
19239
|
this._layer.draw();
|
|
19171
19240
|
}
|
|
19172
19241
|
};
|
|
19242
|
+
SourcesLayer.prototype.onSourcesGroupDragStart = function (element) {
|
|
19243
|
+
this._initialFrameOffset = this._view.getFrameOffset();
|
|
19244
|
+
this._mouseDownX = this._view.getPointerPosition().x;
|
|
19245
|
+
this._selectedElements = {};
|
|
19246
|
+
const draggedElementId = element.currentTarget.attrs.sourceId;
|
|
19247
|
+
const shouldDragSelectedElements = Object.keys(this._view.getSelectedElements()).includes(draggedElementId);
|
|
19248
|
+
this._nonSelectedElement = shouldDragSelectedElements ? null : [this._sourcesGroup[draggedElementId].getSource()];
|
|
19249
|
+
};
|
|
19250
|
+
SourcesLayer.prototype.onSourcesGroupDragEnd = function () {
|
|
19251
|
+
const updatedSources = (this._nonSelectedElement || Object.values(this._view.getSelectedElements())).map(function (source) {
|
|
19252
|
+
const sourceGroup = this._sourcesGroup[source.id];
|
|
19253
|
+
if (sourceGroup) {
|
|
19254
|
+
sourceGroup.prepareDragEnd();
|
|
19255
|
+
}
|
|
19256
|
+
return source;
|
|
19257
|
+
}.bind(this));
|
|
19258
|
+
this._view.drawSourcesLayer();
|
|
19259
|
+
this._view.updateTimelineLength();
|
|
19260
|
+
this._selectedElements = {};
|
|
19261
|
+
this._peaks.emit('sources.updated', updatedSources);
|
|
19262
|
+
};
|
|
19263
|
+
SourcesLayer.prototype.onSourcesGroupDrag = function (draggedElement) {
|
|
19264
|
+
this._view.updateWithAutoScroll(this._updateSourcesGroup.bind(this));
|
|
19265
|
+
return {
|
|
19266
|
+
x: draggedElement.absolutePosition().x,
|
|
19267
|
+
y: draggedElement.absolutePosition().y
|
|
19268
|
+
};
|
|
19269
|
+
};
|
|
19270
|
+
SourcesLayer.prototype._updateSourcesGroup = function () {
|
|
19271
|
+
var mousePos = Math.min(this._view.getWidth() - this._peaks.options.autoScrollThreshold * this._view.getWidth(), Math.max(0, this._view.getPointerPosition().x));
|
|
19272
|
+
const diff = mousePos - this._mouseDownX;
|
|
19273
|
+
const currentFrameOffset = this._view.getFrameOffset();
|
|
19274
|
+
const mousePosY = this._view.getPointerPosition().y;
|
|
19275
|
+
var newEnd = 0;
|
|
19276
|
+
var shouldRedraw = false;
|
|
19277
|
+
(this._nonSelectedElement || Object.values(this._view.getSelectedElements())).forEach(function (source) {
|
|
19278
|
+
if (!this._selectedElements[source.id]) {
|
|
19279
|
+
this._selectedElements[source.id] = {
|
|
19280
|
+
startX: this._view.timeToPixels(source.startTime),
|
|
19281
|
+
endX: this._view.timeToPixels(source.endTime)
|
|
19282
|
+
};
|
|
19283
|
+
}
|
|
19284
|
+
const {startX, endX} = this._selectedElements[source.id];
|
|
19285
|
+
newEnd = Math.max(newEnd, source.endTime);
|
|
19286
|
+
shouldRedraw = this.updateSource(source, startX + diff + (currentFrameOffset - this._initialFrameOffset), endX + diff + (currentFrameOffset - this._initialFrameOffset), mousePosY) || shouldRedraw;
|
|
19287
|
+
}.bind(this));
|
|
19288
|
+
if (shouldRedraw) {
|
|
19289
|
+
this.draw();
|
|
19290
|
+
}
|
|
19291
|
+
this._view.setTimelineLength(this._view.timeToPixels(newEnd) + this._view.getWidth());
|
|
19292
|
+
};
|
|
19173
19293
|
SourcesLayer.prototype.findSources = function (startTime, endTime) {
|
|
19174
19294
|
var sources = this._peaks.sources.find(startTime, endTime);
|
|
19175
19295
|
var positions = this._lines.getVisibleLines();
|
|
@@ -19191,8 +19311,9 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
19191
19311
|
source.updateTimes(newXs.startX !== null ? this._view.pixelsToTime(newXs.startX) : null, newXs.endX !== null ? this._view.pixelsToTime(newXs.endX) : null);
|
|
19192
19312
|
if (newXs) {
|
|
19193
19313
|
this._updateSource(source, newXs.updateWidth);
|
|
19194
|
-
|
|
19314
|
+
return true;
|
|
19195
19315
|
}
|
|
19316
|
+
return false;
|
|
19196
19317
|
};
|
|
19197
19318
|
SourcesLayer.prototype.manageVerticalPosition = function (source, newY) {
|
|
19198
19319
|
return this._lines.manageVerticalPosition(source, newY);
|
|
@@ -19219,7 +19340,7 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
19219
19340
|
for (var sourceId in this._sourcesGroup) {
|
|
19220
19341
|
if (Utils.objectHasProperty(this._sourcesGroup, sourceId)) {
|
|
19221
19342
|
var source = this._sourcesGroup[sourceId].getSource();
|
|
19222
|
-
if (!this._isSourceVisible(source, startTime, endTime)
|
|
19343
|
+
if (!this._isSourceVisible(source, startTime, endTime)) {
|
|
19223
19344
|
this._removeSource(source);
|
|
19224
19345
|
count++;
|
|
19225
19346
|
}
|
|
@@ -19286,6 +19407,9 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
19286
19407
|
SourcesLayer.prototype.getSourceGroupById = function (sourceId) {
|
|
19287
19408
|
return this._sourcesGroup[sourceId];
|
|
19288
19409
|
};
|
|
19410
|
+
SourcesLayer.prototype.getSourcesOnLineAfter = function (lineId, time) {
|
|
19411
|
+
return this._lines.getSourcesOnLineAfter(lineId, time);
|
|
19412
|
+
};
|
|
19289
19413
|
SourcesLayer.prototype._sourcesOverlapped = function (source1, source2) {
|
|
19290
19414
|
var endsLater = source1.startTime < source2.startTime && source1.endTime > source2.startTime;
|
|
19291
19415
|
var startsEarlier = source1.startTime > source2.startTime && source1.startTime < source2.endTime;
|
|
@@ -19327,9 +19451,12 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
19327
19451
|
this._peaks.off('sources.destroy', this._onSourcesDestroy);
|
|
19328
19452
|
this._peaks.off('sources.show', this._onSourcesShow);
|
|
19329
19453
|
this._peaks.off('sources.hide', this._onSourcesHide);
|
|
19454
|
+
this._peaks.off('source.update', this._onSourceUpdate);
|
|
19330
19455
|
this._peaks.off('data.retrieved', this._onDataRetrieved);
|
|
19331
19456
|
this._peaks.off('sources.refresh', this._onSourcesRefresh);
|
|
19332
19457
|
this._peaks.off('segments.show', this._onSegmentsShow);
|
|
19458
|
+
this._peaks.off('options.set.line_height', this._onOptionsLineHeightChange);
|
|
19459
|
+
this._peaks.off('source.setIndicators', this.setIndicators);
|
|
19333
19460
|
};
|
|
19334
19461
|
SourcesLayer.prototype.getHeight = function () {
|
|
19335
19462
|
return this._layer.getHeight();
|
|
@@ -19745,7 +19872,7 @@ module.exports = function (Source, Utils) {
|
|
|
19745
19872
|
if (!Utils.isObject(options)) {
|
|
19746
19873
|
throw new TypeError('peaks.sources.add(): expected a Source object parameter');
|
|
19747
19874
|
}
|
|
19748
|
-
var source = new Source(this._peaks, options.id || this._getNextSourceId(), options.originId, options.elementId, options.title, options.url, options.previewUrl, options.binaryUrl, options.kind, options.subkind, options.duration, options.startTime, options.endTime, options.mediaStartTime, options.mediaEndTime, options.color, options.backgroundColor, options.borderColor, options.selectedColor, options.textFont, options.textFontSize, options.textColor, options.textBackgroundColor, options.textPosition, options.borderWidth, options.borderRadius, options.wrapped, options.position, options.draggable, options.orderable, options.resizable, options.cuttable, options.deletable, options.wrapping, options.previewHeight, options.binaryHeight);
|
|
19875
|
+
var source = new Source(this._peaks, options.id || this._getNextSourceId(), options.originId, options.elementId, options.title, options.url, options.previewUrl, options.binaryUrl, options.kind, options.subkind, options.duration, options.startTime, options.endTime, options.mediaStartTime, options.mediaEndTime, options.color, options.backgroundColor, options.borderColor, options.selectedColor, options.textFont, options.textFontSize, options.textColor, options.textBackgroundColor, options.textPosition, options.borderWidth, options.borderRadius, options.wrapped, options.position, options.draggable, options.orderable, options.resizable, options.cuttable, options.deletable, options.wrapping, options.previewHeight, options.binaryHeight, options.indicators);
|
|
19749
19876
|
return source;
|
|
19750
19877
|
};
|
|
19751
19878
|
TimelineSources.prototype.getSources = function () {
|
|
@@ -19995,6 +20122,9 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
|
|
|
19995
20122
|
});
|
|
19996
20123
|
this._stage.on('wheel', function (e) {
|
|
19997
20124
|
e.evt.preventDefault();
|
|
20125
|
+
if (self._mouseDragHandler.isDragging()) {
|
|
20126
|
+
return;
|
|
20127
|
+
}
|
|
19998
20128
|
if (self._peaks.keyboardHandler.isCtrlCmdPressed()) {
|
|
19999
20129
|
if (e.evt.deltaY > 0) {
|
|
20000
20130
|
self.setZoom(self.getTimeToPixelsScale() + Math.floor(self.getTimeToPixelsScale() / 10) + 1);
|
|
@@ -20021,46 +20151,54 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
|
|
|
20021
20151
|
}
|
|
20022
20152
|
}
|
|
20023
20153
|
});
|
|
20154
|
+
window.addEventListener('mouseup', this._mouseUp.bind(this), false);
|
|
20155
|
+
window.addEventListener('touchend', this._mouseUp.bind(this), false);
|
|
20156
|
+
window.addEventListener('blur', this._mouseUp.bind(this), false);
|
|
20024
20157
|
}
|
|
20025
|
-
TimelineZoomView.prototype.
|
|
20158
|
+
TimelineZoomView.prototype._mouseUp = function () {
|
|
20159
|
+
this.clearScrollingInterval();
|
|
20160
|
+
};
|
|
20161
|
+
TimelineZoomView.prototype.getSelectedElements = function () {
|
|
20162
|
+
return this._modeLayer.getSelectedElements();
|
|
20163
|
+
};
|
|
20164
|
+
TimelineZoomView.prototype.updateWithAutoScroll = function (updateInInterval, updateOutInterval) {
|
|
20026
20165
|
var self = this;
|
|
20027
20166
|
var posX = this.getPointerPosition().x;
|
|
20028
20167
|
var threshold = Math.round(this._peaks.options.autoScrollThreshold * this.getWidth());
|
|
20029
|
-
|
|
20168
|
+
this._limited = 0;
|
|
20030
20169
|
if (posX < threshold) {
|
|
20031
|
-
|
|
20170
|
+
this._limited = Math.round(-30 * Math.min(1, (threshold - posX) / threshold));
|
|
20032
20171
|
} else if (posX > this.getWidth() - threshold) {
|
|
20033
|
-
|
|
20172
|
+
this._limited = Math.round(30 * Math.min(1, (posX - (this.getWidth() - threshold)) / threshold));
|
|
20034
20173
|
}
|
|
20035
|
-
if (
|
|
20036
|
-
if (!
|
|
20037
|
-
|
|
20038
|
-
var newOffset = self.getFrameOffset() +
|
|
20174
|
+
if (this._limited && self.getFrameOffset() > 0 || this._limited > 0) {
|
|
20175
|
+
if (!this._scrollingInterval) {
|
|
20176
|
+
this._scrollingInterval = setInterval(function () {
|
|
20177
|
+
var newOffset = self.getFrameOffset() + self._limited;
|
|
20039
20178
|
if (newOffset < 0) {
|
|
20040
20179
|
self.updateTimeline(0, null, false);
|
|
20041
|
-
clearInterval(
|
|
20042
|
-
|
|
20180
|
+
clearInterval(self._scrollingInterval);
|
|
20181
|
+
self._scrollingInterval = null;
|
|
20043
20182
|
} else {
|
|
20044
|
-
self.updateTimeline(self.getFrameOffset() +
|
|
20183
|
+
self.updateTimeline(self.getFrameOffset() + self._limited, null, false);
|
|
20045
20184
|
}
|
|
20046
20185
|
updateInInterval();
|
|
20047
20186
|
}, 10);
|
|
20048
20187
|
}
|
|
20049
20188
|
} else {
|
|
20050
|
-
|
|
20051
|
-
clearInterval(obj._scrollingInterval);
|
|
20052
|
-
obj._scrollingInterval = null;
|
|
20053
|
-
}
|
|
20189
|
+
this.clearScrollingInterval();
|
|
20054
20190
|
if (updateOutInterval) {
|
|
20055
20191
|
updateOutInterval();
|
|
20056
20192
|
} else {
|
|
20057
20193
|
updateInInterval();
|
|
20058
20194
|
}
|
|
20059
20195
|
}
|
|
20060
|
-
|
|
20061
|
-
|
|
20062
|
-
|
|
20063
|
-
|
|
20196
|
+
};
|
|
20197
|
+
TimelineZoomView.prototype.clearScrollingInterval = function () {
|
|
20198
|
+
if (this._scrollingInterval) {
|
|
20199
|
+
clearInterval(this._scrollingInterval);
|
|
20200
|
+
this._scrollingInterval = null;
|
|
20201
|
+
}
|
|
20064
20202
|
};
|
|
20065
20203
|
TimelineZoomView.prototype.getCurrentMode = function () {
|
|
20066
20204
|
return this._modeLayer.getCurrentMode();
|
|
@@ -20076,14 +20214,23 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
|
|
|
20076
20214
|
this._sourcesLayer.stopDrag();
|
|
20077
20215
|
this._sourcesLayer.draw();
|
|
20078
20216
|
};
|
|
20217
|
+
TimelineZoomView.prototype.getSelectedElements = function () {
|
|
20218
|
+
return this._modeLayer.getSelectedElements();
|
|
20219
|
+
};
|
|
20079
20220
|
TimelineZoomView.prototype.selectSourceById = function (sourceId) {
|
|
20080
|
-
|
|
20221
|
+
const sourceGroup = this._sourcesLayer.getSourceGroupById(sourceId);
|
|
20081
20222
|
if (sourceGroup) {
|
|
20082
|
-
this._modeLayer.
|
|
20223
|
+
this._modeLayer.selectElements([sourceGroup.getSource()], false);
|
|
20224
|
+
}
|
|
20225
|
+
};
|
|
20226
|
+
TimelineZoomView.prototype.selectSourcesOnLineAfter = function (lineId, time) {
|
|
20227
|
+
const sources = this._sourcesLayer.getSourcesOnLineAfter(lineId, time);
|
|
20228
|
+
if (sources) {
|
|
20229
|
+
this._modeLayer.selectElements(sources, false);
|
|
20083
20230
|
}
|
|
20084
20231
|
};
|
|
20085
|
-
TimelineZoomView.prototype.
|
|
20086
|
-
this._modeLayer.
|
|
20232
|
+
TimelineZoomView.prototype.deselectAll = function () {
|
|
20233
|
+
this._modeLayer.deselectAll(false);
|
|
20087
20234
|
};
|
|
20088
20235
|
TimelineZoomView.prototype.isListening = function () {
|
|
20089
20236
|
return this._stage.listening();
|