@checksub_team/peaks_timeline 1.4.26 → 1.4.29
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 +227 -89
- package/src/line.js +12 -0
- package/src/lines.js +59 -5
- package/src/main.js +22 -2
- package/src/mode-layer.js +47 -21
- package/src/playhead-layer.js +36 -26
- package/src/segment-shape.js +10 -1
- package/src/segment.js +30 -6
- package/src/segments-group.js +39 -18
- package/src/source.js +1 -1
- package/src/sources-layer.js +8 -8
- package/src/timeline-segments.js +7 -5
- package/src/timeline-zoomview.js +13 -1
package/peaks.js
CHANGED
|
@@ -14889,6 +14889,15 @@ module.exports = function (Konva, Utils) {
|
|
|
14889
14889
|
this._height = this._segmentsGroup.getCurrentHeight();
|
|
14890
14890
|
segmentsGroup.addToGroup(this._group);
|
|
14891
14891
|
};
|
|
14892
|
+
Line.prototype.refreshSegmentsHeight = function () {
|
|
14893
|
+
if (this.isSegmentsLine) {
|
|
14894
|
+
var oldHeight = this._height;
|
|
14895
|
+
this._height = this._segmentsGroup.getCurrentHeight();
|
|
14896
|
+
if (this._height !== oldHeight) {
|
|
14897
|
+
this._peaks.emit('line.heightChanged', this._position);
|
|
14898
|
+
}
|
|
14899
|
+
}
|
|
14900
|
+
};
|
|
14892
14901
|
Line.prototype._canBePlacedBetween = function (startTime, endTime, startLimit, endLimit) {
|
|
14893
14902
|
var timeWidth = endTime - startTime;
|
|
14894
14903
|
var newTimes = null;
|
|
@@ -15146,7 +15155,7 @@ module.exports = function (Konva, Utils) {
|
|
|
15146
15155
|
return Line;
|
|
15147
15156
|
}(_dereq_('konva'), _dereq_('./utils'));
|
|
15148
15157
|
},{"./utils":110,"konva":43}],92:[function(_dereq_,module,exports){
|
|
15149
|
-
module.exports = function (Line, LineIndicator, Utils) {
|
|
15158
|
+
module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
|
|
15150
15159
|
'use strict';
|
|
15151
15160
|
function Lines(peaks, view, layer) {
|
|
15152
15161
|
this._peaks = peaks;
|
|
@@ -15157,12 +15166,46 @@ module.exports = function (Line, LineIndicator, Utils) {
|
|
|
15157
15166
|
this._autoAddToLayer = false;
|
|
15158
15167
|
this._areSourceInteractionsAllowed = true;
|
|
15159
15168
|
this._areSegmentInteractionsAllowed = true;
|
|
15169
|
+
this._segmentsGroups = {};
|
|
15170
|
+
this._segmentsGroupToLine = {};
|
|
15160
15171
|
this._lineId = 0;
|
|
15161
15172
|
this._lineIndicator = new LineIndicator(peaks, view, document.getElementById('line-indicator-container'));
|
|
15162
15173
|
this._peaks.on('line.heightChanged', this._onLineHeightChanged.bind(this));
|
|
15163
15174
|
this._peaks.on('line.add', this._onLineAdd.bind(this));
|
|
15164
15175
|
this._peaks.on('line.remove', this._onLineRemove.bind(this));
|
|
15176
|
+
this._peaks.on('segment.updated', this._onSegmentsUpdate.bind(this));
|
|
15177
|
+
this._peaks.on('segments.add', this._onSegmentsAdd.bind(this));
|
|
15178
|
+
this._peaks.on('segments.remove', this._onSegmentsRemove.bind(this));
|
|
15179
|
+
this._peaks.on('segments.remove_all', this._onSegmentsRemoveAll.bind(this));
|
|
15180
|
+
this._peaks.on('segments.dragend', this._onSegmentUpdated.bind(this));
|
|
15165
15181
|
}
|
|
15182
|
+
Lines.prototype._onSegmentsAdd = function (segments) {
|
|
15183
|
+
var self = this;
|
|
15184
|
+
segments.forEach(function (segment) {
|
|
15185
|
+
if (!self._segmentsGroups[segment.line]) {
|
|
15186
|
+
self._segmentsGroups[segment.line] = new SegmentsGroup(self._peaks, self._view, true);
|
|
15187
|
+
}
|
|
15188
|
+
self._segmentsGroups[segment.line].onSegmentsAdd([segment]);
|
|
15189
|
+
});
|
|
15190
|
+
};
|
|
15191
|
+
Lines.prototype._onSegmentsUpdate = function (segment) {
|
|
15192
|
+
this._segmentsGroups[segment.line].onSegmentsUpdate(segment);
|
|
15193
|
+
};
|
|
15194
|
+
Lines.prototype._onSegmentUpdated = function (segment) {
|
|
15195
|
+
this._segmentsGroups[segment.line].onSegmentUpdated();
|
|
15196
|
+
};
|
|
15197
|
+
Lines.prototype._onSegmentsRemove = function (segments) {
|
|
15198
|
+
var self = this;
|
|
15199
|
+
segments.forEach(function (segment) {
|
|
15200
|
+
self._segmentsGroups[segment.line].onSegmentsRemove([segment]);
|
|
15201
|
+
});
|
|
15202
|
+
};
|
|
15203
|
+
Lines.prototype._onSegmentsRemoveAll = function (lineId) {
|
|
15204
|
+
this._segmentsGroups[lineId].onSegmentsRemoveAll();
|
|
15205
|
+
if (Utils.objectHasProperty(this._segmentsGroupToLine, lineId)) {
|
|
15206
|
+
this._segmentsGroupToLine[lineId].refreshSegmentsHeight();
|
|
15207
|
+
}
|
|
15208
|
+
};
|
|
15166
15209
|
Lines.prototype._onLineHeightChanged = function (position) {
|
|
15167
15210
|
this._updateLinesPosition(position);
|
|
15168
15211
|
this._view.updateTimeline();
|
|
@@ -15195,11 +15238,11 @@ module.exports = function (Line, LineIndicator, Utils) {
|
|
|
15195
15238
|
this._linesByPosition[position].addSourceGroup(sourceGroup);
|
|
15196
15239
|
this._linesBySourceId[sourceGroup.getSource().id] = this._linesByPosition[position];
|
|
15197
15240
|
};
|
|
15198
|
-
Lines.prototype.addSegments = function (
|
|
15241
|
+
Lines.prototype.addSegments = function (lineId, position) {
|
|
15199
15242
|
this._createLine(position);
|
|
15200
15243
|
this._linesByPosition[position].allowInteractions(this._areSegmentInteractionsAllowed);
|
|
15201
|
-
this._linesByPosition[position].addSegments(
|
|
15202
|
-
this.
|
|
15244
|
+
this._linesByPosition[position].addSegments(this._segmentsGroups[lineId]);
|
|
15245
|
+
this._segmentsGroupToLine[lineId] = this._linesByPosition[position];
|
|
15203
15246
|
this._setInteractions(position);
|
|
15204
15247
|
this._updateLinesPosition(position);
|
|
15205
15248
|
};
|
|
@@ -15232,6 +15275,9 @@ module.exports = function (Line, LineIndicator, Utils) {
|
|
|
15232
15275
|
}
|
|
15233
15276
|
return positions;
|
|
15234
15277
|
};
|
|
15278
|
+
Lines.prototype.getSegmentsGroups = function () {
|
|
15279
|
+
return this._segmentsGroups;
|
|
15280
|
+
};
|
|
15235
15281
|
Lines.prototype.addToLayer = function (layer) {
|
|
15236
15282
|
for (var position in this._linesByPosition) {
|
|
15237
15283
|
if (Utils.objectHasProperty(this._linesByPosition, position)) {
|
|
@@ -15364,8 +15410,10 @@ module.exports = function (Line, LineIndicator, Utils) {
|
|
|
15364
15410
|
this._linesByPosition = newLinesByPosition;
|
|
15365
15411
|
};
|
|
15366
15412
|
Lines.prototype.updateSegments = function (frameStartTime, frameEndTime) {
|
|
15367
|
-
|
|
15368
|
-
this.
|
|
15413
|
+
for (var lineId in this._segmentsGroups) {
|
|
15414
|
+
if (Utils.objectHasProperty(this._segmentsGroups, lineId)) {
|
|
15415
|
+
this._segmentsGroups[lineId].updateSegments(frameStartTime, frameEndTime);
|
|
15416
|
+
}
|
|
15369
15417
|
}
|
|
15370
15418
|
};
|
|
15371
15419
|
Lines.prototype.manageCollision = function (source, newStartX, newEndX) {
|
|
@@ -15401,8 +15449,8 @@ module.exports = function (Line, LineIndicator, Utils) {
|
|
|
15401
15449
|
}
|
|
15402
15450
|
};
|
|
15403
15451
|
return Lines;
|
|
15404
|
-
}(_dereq_('./line'), _dereq_('./line-indicator'), _dereq_('./utils'));
|
|
15405
|
-
},{"./line":91,"./line-indicator":90,"./utils":110}],93:[function(_dereq_,module,exports){
|
|
15452
|
+
}(_dereq_('./segments-group'), _dereq_('./line'), _dereq_('./line-indicator'), _dereq_('./utils'));
|
|
15453
|
+
},{"./line":91,"./line-indicator":90,"./segments-group":102,"./utils":110}],93:[function(_dereq_,module,exports){
|
|
15406
15454
|
module.exports = function (Colors, EventEmitter, TimelineSegments, TimelineSources, KeyboardHandler, Player, MarkerFactories, TimelineZoomView, Utils) {
|
|
15407
15455
|
'use strict';
|
|
15408
15456
|
function Peaks() {
|
|
@@ -15579,8 +15627,11 @@ module.exports = function (Colors, EventEmitter, TimelineSegments, TimelineSourc
|
|
|
15579
15627
|
Peaks.prototype.hideSource = function (sourceId) {
|
|
15580
15628
|
this.sources.hideById(sourceId);
|
|
15581
15629
|
};
|
|
15582
|
-
Peaks.prototype.showSegments = function (position) {
|
|
15583
|
-
this.segments.addSegmentsToPosition(position);
|
|
15630
|
+
Peaks.prototype.showSegments = function (lineId, position) {
|
|
15631
|
+
this.segments.addSegmentsToPosition(lineId, position);
|
|
15632
|
+
};
|
|
15633
|
+
Peaks.prototype.destroySegment = function (segmentId) {
|
|
15634
|
+
this.segments.removeById(segmentId);
|
|
15584
15635
|
};
|
|
15585
15636
|
Peaks.prototype.setDefaultMode = function () {
|
|
15586
15637
|
this.emit('default_mode');
|
|
@@ -15600,6 +15651,12 @@ module.exports = function (Colors, EventEmitter, TimelineSegments, TimelineSourc
|
|
|
15600
15651
|
Peaks.prototype.allowInteractions = function (forSources, forSegments) {
|
|
15601
15652
|
return this.view.allowInteractions(forSources, forSegments);
|
|
15602
15653
|
};
|
|
15654
|
+
Peaks.prototype.selectSourceById = function (sourceId) {
|
|
15655
|
+
return this.view.selectSourceById(sourceId);
|
|
15656
|
+
};
|
|
15657
|
+
Peaks.prototype.deselectSource = function () {
|
|
15658
|
+
return this.view.deselectElement();
|
|
15659
|
+
};
|
|
15603
15660
|
Peaks.prototype._addWindowResizeHandler = function () {
|
|
15604
15661
|
this._onResize = this._onResize.bind(this);
|
|
15605
15662
|
window.addEventListener('resize', this._onResize);
|
|
@@ -15687,6 +15744,33 @@ module.exports = function (Utils, SourceGroup, Konva) {
|
|
|
15687
15744
|
ModeLayer.prototype.addToStage = function (stage) {
|
|
15688
15745
|
stage.add(this._layer);
|
|
15689
15746
|
};
|
|
15747
|
+
ModeLayer.prototype.selectElement = function (element, notify) {
|
|
15748
|
+
this.deselectElement(notify);
|
|
15749
|
+
if (element) {
|
|
15750
|
+
this._selectedElement = element;
|
|
15751
|
+
this._selectedElement.setSelected(true);
|
|
15752
|
+
if (notify) {
|
|
15753
|
+
if (element instanceof SourceGroup) {
|
|
15754
|
+
this._peaks.emit('source.selected', this._selectedElement.getSource());
|
|
15755
|
+
} else {
|
|
15756
|
+
this._peaks.emit('segment.selected', this._selectedElement.getSegment());
|
|
15757
|
+
}
|
|
15758
|
+
}
|
|
15759
|
+
}
|
|
15760
|
+
};
|
|
15761
|
+
ModeLayer.prototype.deselectElement = function (notify) {
|
|
15762
|
+
if (this._selectedElement) {
|
|
15763
|
+
this._selectedElement.setSelected(false);
|
|
15764
|
+
if (notify) {
|
|
15765
|
+
if (this._selectedElement instanceof SourceGroup) {
|
|
15766
|
+
this._peaks.emit('source.deselected', this._selectedElement.getSource());
|
|
15767
|
+
} else {
|
|
15768
|
+
this._peaks.emit('segment.deselected', this._selectedElement.getSegment());
|
|
15769
|
+
}
|
|
15770
|
+
}
|
|
15771
|
+
this._selectedElement = null;
|
|
15772
|
+
}
|
|
15773
|
+
};
|
|
15690
15774
|
ModeLayer.prototype._prepareDefaultMode = function () {
|
|
15691
15775
|
this._selectedElement = null;
|
|
15692
15776
|
};
|
|
@@ -15738,24 +15822,22 @@ module.exports = function (Utils, SourceGroup, Konva) {
|
|
|
15738
15822
|
ModeLayer.prototype._onMouseClickInDefaultMode = function () {
|
|
15739
15823
|
var hoveredElement = this._view.getHoveredElement();
|
|
15740
15824
|
if (hoveredElement) {
|
|
15741
|
-
|
|
15742
|
-
this._selectedElement.setSelected(false);
|
|
15743
|
-
this._peaks.emit('source.deselected', this._selectedElement.getSource());
|
|
15744
|
-
}
|
|
15745
|
-
this._selectedElement = hoveredElement;
|
|
15746
|
-
this._selectedElement.setSelected(true);
|
|
15747
|
-
this._peaks.emit('source.selected', this._selectedElement.getSource());
|
|
15825
|
+
this.selectElement(hoveredElement, true);
|
|
15748
15826
|
} else {
|
|
15749
|
-
|
|
15750
|
-
this._selectedElement.setSelected(false);
|
|
15751
|
-
this._peaks.emit('source.deselected', this._selectedElement.getSource());
|
|
15752
|
-
this._selectedElement = null;
|
|
15753
|
-
}
|
|
15827
|
+
this.deselectElement(true);
|
|
15754
15828
|
}
|
|
15755
15829
|
};
|
|
15756
15830
|
ModeLayer.prototype._onKeyboardDelete = function () {
|
|
15757
|
-
if (this._selectedElement
|
|
15758
|
-
this.
|
|
15831
|
+
if (this._selectedElement) {
|
|
15832
|
+
var selectedElement = this._selectedElement;
|
|
15833
|
+
this.deselectElement(true);
|
|
15834
|
+
if (selectedElement instanceof SourceGroup) {
|
|
15835
|
+
this._peaks.destroySource(selectedElement.getSource().id);
|
|
15836
|
+
} else {
|
|
15837
|
+
if (selectedElement.getSegment().allowDeletion) {
|
|
15838
|
+
this._peaks.destroySegment(selectedElement.getSegment().id);
|
|
15839
|
+
}
|
|
15840
|
+
}
|
|
15759
15841
|
}
|
|
15760
15842
|
};
|
|
15761
15843
|
ModeLayer.prototype._onMouseEnterInCutMode = function () {
|
|
@@ -15871,12 +15953,9 @@ module.exports = function (Utils, SourceGroup, Konva) {
|
|
|
15871
15953
|
case 'default':
|
|
15872
15954
|
this._stage.off('click', this._onMouseClickInDefaultMode);
|
|
15873
15955
|
this._peaks.off('keyboard.delete', this._onKeyboardDelete);
|
|
15874
|
-
if (this._selectedElement) {
|
|
15875
|
-
this._selectedElement.setSelected(false);
|
|
15876
|
-
}
|
|
15877
15956
|
break;
|
|
15878
15957
|
}
|
|
15879
|
-
this.
|
|
15958
|
+
this.deselectElement(true);
|
|
15880
15959
|
switch (mode) {
|
|
15881
15960
|
case 'cut':
|
|
15882
15961
|
this._stage.on('mouseover', this._onMouseEnterInCutMode);
|
|
@@ -16098,18 +16177,18 @@ module.exports = function (Utils) {
|
|
|
16098
16177
|
module.exports = function (Utils, Konva) {
|
|
16099
16178
|
'use strict';
|
|
16100
16179
|
var HANDLE_RADIUS = 10;
|
|
16101
|
-
function PlayheadLayer(peaks, view,
|
|
16180
|
+
function PlayheadLayer(peaks, view, lines, showTime) {
|
|
16102
16181
|
this._peaks = peaks;
|
|
16103
16182
|
this._view = view;
|
|
16104
|
-
this.
|
|
16183
|
+
this._lines = lines;
|
|
16105
16184
|
this._playheadPixel = 0;
|
|
16106
16185
|
this._playheadLineAnimation = null;
|
|
16107
16186
|
this._playheadVisible = false;
|
|
16108
16187
|
this._playheadColor = peaks.options.playheadColor;
|
|
16109
16188
|
this._playheadTextColor = peaks.options.playheadTextColor;
|
|
16110
16189
|
this._playheadLayer = new Konva.Layer();
|
|
16111
|
-
this.
|
|
16112
|
-
this.
|
|
16190
|
+
this._activeSegments = {};
|
|
16191
|
+
this._lastActiveSegments = {};
|
|
16113
16192
|
this._createPlayhead(this._playheadColor);
|
|
16114
16193
|
if (showTime) {
|
|
16115
16194
|
this._createPlayheadText(this._playheadTextColor);
|
|
@@ -16120,20 +16199,20 @@ module.exports = function (Utils, Konva) {
|
|
|
16120
16199
|
this._peaks.on('segments.remove', this._onSegmentsRemove.bind(this));
|
|
16121
16200
|
}
|
|
16122
16201
|
PlayheadLayer.prototype._onSegmentsRemoveAll = function () {
|
|
16123
|
-
this.
|
|
16124
|
-
this.
|
|
16202
|
+
this._activeSegments = {};
|
|
16203
|
+
this._lastActiveSegments = {};
|
|
16125
16204
|
};
|
|
16126
16205
|
PlayheadLayer.prototype._onSegmentsRemove = function (segments) {
|
|
16127
|
-
if (this.
|
|
16128
|
-
var activeSegmentId = this._activeSegment ? this._activeSegment.id : null;
|
|
16129
|
-
var lastActiveSegmentId = this._lastActiveSegmentId ? this._lastActiveSegmentId.id : null;
|
|
16206
|
+
if (this._activeSegments || this._lastActiveSegments) {
|
|
16130
16207
|
for (var id in segments) {
|
|
16131
16208
|
if (Utils.objectHasProperty(segments, id)) {
|
|
16209
|
+
var activeSegmentId = this._activeSegments[segments[id].line] ? this._activeSegments[segments[id].line].id : null;
|
|
16210
|
+
var lastActiveSegmentId = this._lastActiveSegments[segments[id].line] ? this._lastActiveSegments[segments[id].line].id : null;
|
|
16132
16211
|
if (segments[id].id === activeSegmentId) {
|
|
16133
|
-
this.
|
|
16212
|
+
delete this._activeSegments[segments[id].line];
|
|
16134
16213
|
}
|
|
16135
16214
|
if (segments[id].id === lastActiveSegmentId) {
|
|
16136
|
-
this.
|
|
16215
|
+
delete this._lastActiveSegments[segments[id].line];
|
|
16137
16216
|
}
|
|
16138
16217
|
}
|
|
16139
16218
|
}
|
|
@@ -16251,16 +16330,21 @@ module.exports = function (Utils, Konva) {
|
|
|
16251
16330
|
}
|
|
16252
16331
|
var playheadPositionDiff = this._playheadGroup.x() - playheadX;
|
|
16253
16332
|
if (playheadPositionDiff) {
|
|
16254
|
-
var
|
|
16255
|
-
|
|
16256
|
-
if (
|
|
16257
|
-
this.
|
|
16258
|
-
this.
|
|
16259
|
-
|
|
16260
|
-
|
|
16261
|
-
|
|
16262
|
-
|
|
16263
|
-
|
|
16333
|
+
var segmentsGroup = this._lines.getSegmentsGroups();
|
|
16334
|
+
for (var lineId in segmentsGroup) {
|
|
16335
|
+
if (Utils.objectHasProperty(segmentsGroup, lineId)) {
|
|
16336
|
+
var newActiveSegment = segmentsGroup[lineId].getActiveSegment(this._view.pixelsToTime(playheadX + frameOffset), null, true);
|
|
16337
|
+
if (newActiveSegment !== this._activeSegments[lineId]) {
|
|
16338
|
+
if (this._activeSegments[lineId]) {
|
|
16339
|
+
this._peaks.emit('segments.exit', this._activeSegments[lineId]);
|
|
16340
|
+
delete this._activeSegments[lineId];
|
|
16341
|
+
}
|
|
16342
|
+
if (newActiveSegment) {
|
|
16343
|
+
this._peaks.emit('segments.enter', newActiveSegment);
|
|
16344
|
+
this._activeSegments[lineId] = newActiveSegment;
|
|
16345
|
+
this._lastActiveSegments[lineId] = this._activeSegments[lineId];
|
|
16346
|
+
}
|
|
16347
|
+
}
|
|
16264
16348
|
}
|
|
16265
16349
|
}
|
|
16266
16350
|
}
|
|
@@ -16434,6 +16518,7 @@ module.exports = function (Konva, SegmentMarker) {
|
|
|
16434
16518
|
this._startMarker = null;
|
|
16435
16519
|
this._endMarker = null;
|
|
16436
16520
|
this._rectangle = null;
|
|
16521
|
+
this._isSelected = false;
|
|
16437
16522
|
this._segmentHeight = this._peaks.options.segmentHeight;
|
|
16438
16523
|
this._rectangle = new Konva.Rect({
|
|
16439
16524
|
x: this._view.timeToPixels(this._segment.startTime),
|
|
@@ -16592,12 +16677,14 @@ module.exports = function (Konva, SegmentMarker) {
|
|
|
16592
16677
|
};
|
|
16593
16678
|
SegmentShape.prototype._onMouseEnter = function () {
|
|
16594
16679
|
this._view.setCursor('pointer');
|
|
16595
|
-
this.
|
|
16680
|
+
this._view.setHoveredElement(this);
|
|
16681
|
+
this._rectangle.fill(this._segment.activeColor + Math.round(this._segment.opacity * 255).toString(16));
|
|
16596
16682
|
this._view.drawSourcesLayer();
|
|
16597
16683
|
this._peaks.emit('segments.mouseenter', this._segment);
|
|
16598
16684
|
};
|
|
16599
16685
|
SegmentShape.prototype._onMouseLeave = function () {
|
|
16600
16686
|
this._view.setCursor('default');
|
|
16687
|
+
this._view.setHoveredElement(null);
|
|
16601
16688
|
this._rectangle.fill(this._segment.color + Math.round(this._segment.opacity * 255).toString(16));
|
|
16602
16689
|
this._view.drawSourcesLayer();
|
|
16603
16690
|
this._peaks.emit('segments.mouseleave', this._segment);
|
|
@@ -16629,6 +16716,9 @@ module.exports = function (Konva, SegmentMarker) {
|
|
|
16629
16716
|
var startMarker = segmentMarker.isStartMarker();
|
|
16630
16717
|
this._peaks.emit('segments.dragend', this._segment, startMarker);
|
|
16631
16718
|
};
|
|
16719
|
+
SegmentShape.prototype.setSelected = function (isSelected) {
|
|
16720
|
+
this._isSelected = isSelected;
|
|
16721
|
+
};
|
|
16632
16722
|
SegmentShape.prototype.fitToView = function () {
|
|
16633
16723
|
if (this._startMarker) {
|
|
16634
16724
|
this._startMarker.fitToView();
|
|
@@ -16681,8 +16771,11 @@ module.exports = function (Utils) {
|
|
|
16681
16771
|
} else if (!Utils.isString(options.labelText)) {
|
|
16682
16772
|
throw new TypeError('peaks.segments.' + context + ': labelText must be a string');
|
|
16683
16773
|
}
|
|
16774
|
+
if (!Utils.isInteger(options.line)) {
|
|
16775
|
+
throw new TypeError('peaks.segments.' + context + ': line must be an integer');
|
|
16776
|
+
}
|
|
16684
16777
|
}
|
|
16685
|
-
function Segment(peaks, id, startTime, endTime, labelText, color, textColor, handleTextColor, opacity, editable) {
|
|
16778
|
+
function Segment(peaks, id, startTime, endTime, labelText, color, textColor, handleTextColor, opacity, editable, allowDeletion, line) {
|
|
16686
16779
|
var opts = {
|
|
16687
16780
|
startTime: startTime,
|
|
16688
16781
|
endTime: endTime,
|
|
@@ -16691,7 +16784,9 @@ module.exports = function (Utils) {
|
|
|
16691
16784
|
textColor: textColor,
|
|
16692
16785
|
handleTextColor: handleTextColor,
|
|
16693
16786
|
opacity: opacity,
|
|
16694
|
-
editable: editable
|
|
16787
|
+
editable: editable,
|
|
16788
|
+
allowDeletion: allowDeletion,
|
|
16789
|
+
line: line
|
|
16695
16790
|
};
|
|
16696
16791
|
validateSegment(peaks, opts, 'add()');
|
|
16697
16792
|
this._peaks = peaks;
|
|
@@ -16700,11 +16795,13 @@ module.exports = function (Utils) {
|
|
|
16700
16795
|
this._endTime = opts.endTime;
|
|
16701
16796
|
this._labelText = opts.labelText;
|
|
16702
16797
|
this._color = opts.color;
|
|
16703
|
-
this.
|
|
16798
|
+
this._activeColor = Utils.shadeColor(color, 20);
|
|
16704
16799
|
this._textColor = opts.textColor;
|
|
16705
16800
|
this._handleTextColor = opts.handleTextColor;
|
|
16706
16801
|
this._opacity = opts.opacity;
|
|
16707
16802
|
this._editable = opts.editable;
|
|
16803
|
+
this._allowDeletion = opts.allowDeletion;
|
|
16804
|
+
this._line = opts.line;
|
|
16708
16805
|
this._minSize = peaks.options.minSegmentSize;
|
|
16709
16806
|
}
|
|
16710
16807
|
Object.defineProperties(Segment.prototype, {
|
|
@@ -16744,10 +16841,10 @@ module.exports = function (Utils) {
|
|
|
16744
16841
|
return this._color;
|
|
16745
16842
|
}
|
|
16746
16843
|
},
|
|
16747
|
-
|
|
16844
|
+
activeColor: {
|
|
16748
16845
|
enumerable: true,
|
|
16749
16846
|
get: function () {
|
|
16750
|
-
return this.
|
|
16847
|
+
return this._activeColor;
|
|
16751
16848
|
}
|
|
16752
16849
|
},
|
|
16753
16850
|
textColor: {
|
|
@@ -16774,6 +16871,18 @@ module.exports = function (Utils) {
|
|
|
16774
16871
|
return this._editable;
|
|
16775
16872
|
}
|
|
16776
16873
|
},
|
|
16874
|
+
allowDeletion: {
|
|
16875
|
+
enumerable: true,
|
|
16876
|
+
get: function () {
|
|
16877
|
+
return this._allowDeletion;
|
|
16878
|
+
}
|
|
16879
|
+
},
|
|
16880
|
+
line: {
|
|
16881
|
+
enumerable: true,
|
|
16882
|
+
get: function () {
|
|
16883
|
+
return this._line;
|
|
16884
|
+
}
|
|
16885
|
+
},
|
|
16777
16886
|
minSize: {
|
|
16778
16887
|
enumerable: true,
|
|
16779
16888
|
get: function () {
|
|
@@ -16790,7 +16899,9 @@ module.exports = function (Utils) {
|
|
|
16790
16899
|
textColor: this.textColor,
|
|
16791
16900
|
handleTextColor: this.handleTextColor,
|
|
16792
16901
|
opacity: this.opacity,
|
|
16793
|
-
editable: this.editable
|
|
16902
|
+
editable: this.editable,
|
|
16903
|
+
allowDeletion: this.allowDeletion,
|
|
16904
|
+
line: this.line
|
|
16794
16905
|
};
|
|
16795
16906
|
Utils.extend(opts, options);
|
|
16796
16907
|
validateSegment(this._peaks, opts, 'update()');
|
|
@@ -16802,6 +16913,8 @@ module.exports = function (Utils) {
|
|
|
16802
16913
|
this._handleTextColor = opts.handleTextColor;
|
|
16803
16914
|
this._opacity = opts.opacity;
|
|
16804
16915
|
this._editable = opts.editable;
|
|
16916
|
+
this._allowDeletion = opts.allowDeletion;
|
|
16917
|
+
this._line = opts.line;
|
|
16805
16918
|
this._peaks.emit('segment.updated', this);
|
|
16806
16919
|
};
|
|
16807
16920
|
Segment.prototype.isVisible = function (startTime, endTime) {
|
|
@@ -16823,11 +16936,6 @@ module.exports = function (SegmentShape, Utils, Konva) {
|
|
|
16823
16936
|
this._group = new Konva.Group();
|
|
16824
16937
|
this._updatedSegments = [];
|
|
16825
16938
|
this._isMagnetized = false;
|
|
16826
|
-
this._peaks.on('segment.updated', this._onSegmentsUpdate.bind(this));
|
|
16827
|
-
this._peaks.on('segments.add', this._onSegmentsAdd.bind(this));
|
|
16828
|
-
this._peaks.on('segments.remove', this._onSegmentsRemove.bind(this));
|
|
16829
|
-
this._peaks.on('segments.remove_all', this._onSegmentsRemoveAll.bind(this));
|
|
16830
|
-
this._peaks.on('segments.dragend', this._onSegmentUpdated.bind(this));
|
|
16831
16939
|
this._peaks.on('segments.setMagnetizing', this.setMagnetizing.bind(this));
|
|
16832
16940
|
}
|
|
16833
16941
|
SegmentsGroup.prototype.addToGroup = function (group) {
|
|
@@ -16870,7 +16978,7 @@ module.exports = function (SegmentShape, Utils, Konva) {
|
|
|
16870
16978
|
} while (nextSegmentId);
|
|
16871
16979
|
return activeSegment;
|
|
16872
16980
|
};
|
|
16873
|
-
SegmentsGroup.prototype.
|
|
16981
|
+
SegmentsGroup.prototype.onSegmentsUpdate = function (segment) {
|
|
16874
16982
|
if (this._segments[segment.id]) {
|
|
16875
16983
|
var redraw = false;
|
|
16876
16984
|
var segmentShape = this._segmentShapes[segment.id];
|
|
@@ -16893,11 +17001,11 @@ module.exports = function (SegmentShape, Utils, Konva) {
|
|
|
16893
17001
|
}
|
|
16894
17002
|
}
|
|
16895
17003
|
};
|
|
16896
|
-
SegmentsGroup.prototype.
|
|
17004
|
+
SegmentsGroup.prototype.onSegmentUpdated = function () {
|
|
16897
17005
|
this._peaks.emit('segments.updated', this._updatedSegments);
|
|
16898
17006
|
this._updatedSegments = [];
|
|
16899
17007
|
};
|
|
16900
|
-
SegmentsGroup.prototype.
|
|
17008
|
+
SegmentsGroup.prototype.onSegmentsAdd = function (segments) {
|
|
16901
17009
|
var self = this;
|
|
16902
17010
|
var frameOffset = self._view.getFrameOffset();
|
|
16903
17011
|
var width = self._view.getWidth();
|
|
@@ -16908,7 +17016,7 @@ module.exports = function (SegmentShape, Utils, Konva) {
|
|
|
16908
17016
|
});
|
|
16909
17017
|
self.updateSegments(frameStartTime, frameEndTime);
|
|
16910
17018
|
};
|
|
16911
|
-
SegmentsGroup.prototype.
|
|
17019
|
+
SegmentsGroup.prototype.onSegmentsRemove = function (segments) {
|
|
16912
17020
|
var self = this;
|
|
16913
17021
|
segments.forEach(function (segment) {
|
|
16914
17022
|
var index = self._updatedSegments.indexOf(segment);
|
|
@@ -16920,7 +17028,7 @@ module.exports = function (SegmentShape, Utils, Konva) {
|
|
|
16920
17028
|
});
|
|
16921
17029
|
this._draw();
|
|
16922
17030
|
};
|
|
16923
|
-
SegmentsGroup.prototype.
|
|
17031
|
+
SegmentsGroup.prototype.onSegmentsRemoveAll = function () {
|
|
16924
17032
|
this._group.removeChildren();
|
|
16925
17033
|
this._firstSegmentId = null;
|
|
16926
17034
|
this._segments = {};
|
|
@@ -17001,7 +17109,7 @@ module.exports = function (SegmentShape, Utils, Konva) {
|
|
|
17001
17109
|
this._updateSegments(segment, marker);
|
|
17002
17110
|
};
|
|
17003
17111
|
SegmentsGroup.prototype.updateSegments = function (startTime, endTime) {
|
|
17004
|
-
var segments = this.
|
|
17112
|
+
var segments = this.find(startTime, endTime);
|
|
17005
17113
|
var count = segments.length;
|
|
17006
17114
|
segments.forEach(this._updateSegment.bind(this));
|
|
17007
17115
|
count += this._removeInvisibleSegments(startTime, endTime);
|
|
@@ -17009,6 +17117,25 @@ module.exports = function (SegmentShape, Utils, Konva) {
|
|
|
17009
17117
|
this._draw();
|
|
17010
17118
|
}
|
|
17011
17119
|
};
|
|
17120
|
+
SegmentsGroup.prototype.find = function (startTime, endTime) {
|
|
17121
|
+
var currentSegment = null;
|
|
17122
|
+
var visibleSegments = [];
|
|
17123
|
+
if (this._firstSegmentId) {
|
|
17124
|
+
do {
|
|
17125
|
+
if (!currentSegment) {
|
|
17126
|
+
currentSegment = this._segments[this._firstSegmentId];
|
|
17127
|
+
} else {
|
|
17128
|
+
currentSegment = this._segments[currentSegment.nextSegmentId];
|
|
17129
|
+
}
|
|
17130
|
+
if (currentSegment.segment.isVisible(startTime, endTime)) {
|
|
17131
|
+
visibleSegments.push(currentSegment.segment);
|
|
17132
|
+
} else if (visibleSegments.length) {
|
|
17133
|
+
break;
|
|
17134
|
+
}
|
|
17135
|
+
} while (currentSegment.nextSegmentId);
|
|
17136
|
+
}
|
|
17137
|
+
return visibleSegments;
|
|
17138
|
+
};
|
|
17012
17139
|
SegmentsGroup.prototype._draw = function () {
|
|
17013
17140
|
this._view.drawSourcesLayer();
|
|
17014
17141
|
};
|
|
@@ -17024,8 +17151,12 @@ module.exports = function (SegmentShape, Utils, Konva) {
|
|
|
17024
17151
|
break;
|
|
17025
17152
|
}
|
|
17026
17153
|
}
|
|
17027
|
-
if (!currentHeight
|
|
17028
|
-
|
|
17154
|
+
if (!currentHeight) {
|
|
17155
|
+
if (Object.keys(this._segments).length > 0) {
|
|
17156
|
+
currentHeight = this._peaks.options.segmentHeight;
|
|
17157
|
+
} else {
|
|
17158
|
+
currentHeight = this._peaks.options.emptyLineHeight;
|
|
17159
|
+
}
|
|
17029
17160
|
}
|
|
17030
17161
|
return currentHeight;
|
|
17031
17162
|
};
|
|
@@ -17253,11 +17384,7 @@ module.exports = function (SegmentShape, Utils, Konva) {
|
|
|
17253
17384
|
return endsLater || startsEarlier;
|
|
17254
17385
|
};
|
|
17255
17386
|
SegmentsGroup.prototype.destroy = function () {
|
|
17256
|
-
this._peaks.off('
|
|
17257
|
-
this._peaks.off('segments.add', this._onSegmentsAdd);
|
|
17258
|
-
this._peaks.off('segments.remove', this._onSegmentsRemove);
|
|
17259
|
-
this._peaks.off('segments.remove_all', this._onSegmentsRemoveAll);
|
|
17260
|
-
this._peaks.off('segments.dragged', this._onSegmentsDragged);
|
|
17387
|
+
this._peaks.off('segments.setMagnetizing', this.setMagnetizing);
|
|
17261
17388
|
};
|
|
17262
17389
|
SegmentsGroup.prototype.fitToView = function () {
|
|
17263
17390
|
for (var segmentId in this._segmentShapes) {
|
|
@@ -18505,7 +18632,7 @@ module.exports = function (Utils) {
|
|
|
18505
18632
|
wrapping: this.wrapping,
|
|
18506
18633
|
previewHeight: this.previewHeight,
|
|
18507
18634
|
binaryHeight: this.binaryHeight,
|
|
18508
|
-
tts: this.
|
|
18635
|
+
tts: this.tts
|
|
18509
18636
|
};
|
|
18510
18637
|
Utils.extend(opts, options);
|
|
18511
18638
|
validateSource(this._peaks, opts, 'update()');
|
|
@@ -18540,7 +18667,7 @@ module.exports = function (Utils) {
|
|
|
18540
18667
|
return Source;
|
|
18541
18668
|
}(_dereq_('./utils'));
|
|
18542
18669
|
},{"./utils":110}],105:[function(_dereq_,module,exports){
|
|
18543
|
-
module.exports = function (SourceGroup,
|
|
18670
|
+
module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Konva) {
|
|
18544
18671
|
'use strict';
|
|
18545
18672
|
function SourcesLayer(peaks, view, allowEditing) {
|
|
18546
18673
|
this._peaks = peaks;
|
|
@@ -18551,7 +18678,6 @@ module.exports = function (SourceGroup, SegmentsGroup, Lines, DataRetriever, Uti
|
|
|
18551
18678
|
this._dataRetriever = new DataRetriever(peaks);
|
|
18552
18679
|
this._lines = new Lines(peaks, view, this);
|
|
18553
18680
|
this._lines.addToLayer(this);
|
|
18554
|
-
this._segmentsGroup = new SegmentsGroup(peaks, view, true);
|
|
18555
18681
|
this._loadedData = {};
|
|
18556
18682
|
this._debouncedRescale = new Invoker().debounce(this._rescale, 150);
|
|
18557
18683
|
this._peaks.on('sources.add', this._onSourcesAdd.bind(this));
|
|
@@ -18570,8 +18696,8 @@ module.exports = function (SourceGroup, SegmentsGroup, Lines, DataRetriever, Uti
|
|
|
18570
18696
|
SourcesLayer.prototype.setLoadedData = function (id, data) {
|
|
18571
18697
|
this._loadedData[id] = data;
|
|
18572
18698
|
};
|
|
18573
|
-
SourcesLayer.prototype.
|
|
18574
|
-
return this.
|
|
18699
|
+
SourcesLayer.prototype.getSegmentsGroups = function () {
|
|
18700
|
+
return this._lines.getSegmentsGroups();
|
|
18575
18701
|
};
|
|
18576
18702
|
SourcesLayer.prototype.add = function (element) {
|
|
18577
18703
|
this._layer.add(element);
|
|
@@ -18691,8 +18817,8 @@ module.exports = function (SourceGroup, SegmentsGroup, Lines, DataRetriever, Uti
|
|
|
18691
18817
|
SourcesLayer.prototype._onSourcesRefresh = function () {
|
|
18692
18818
|
this._layer.draw();
|
|
18693
18819
|
};
|
|
18694
|
-
SourcesLayer.prototype._onSegmentsShow = function (position) {
|
|
18695
|
-
this._lines.addSegments(
|
|
18820
|
+
SourcesLayer.prototype._onSegmentsShow = function (lineId, position) {
|
|
18821
|
+
this._lines.addSegments(lineId, position);
|
|
18696
18822
|
this._view.updateTimelineLength();
|
|
18697
18823
|
this._layer.draw();
|
|
18698
18824
|
};
|
|
@@ -18830,6 +18956,9 @@ module.exports = function (SourceGroup, SegmentsGroup, Lines, DataRetriever, Uti
|
|
|
18830
18956
|
SourcesLayer.prototype.stopDrag = function () {
|
|
18831
18957
|
this._layer.stopDrag();
|
|
18832
18958
|
};
|
|
18959
|
+
SourcesLayer.prototype.getSourceGroupById = function (sourceId) {
|
|
18960
|
+
return this._sourcesGroup[sourceId];
|
|
18961
|
+
};
|
|
18833
18962
|
SourcesLayer.prototype._sourcesOverlapped = function (source1, source2) {
|
|
18834
18963
|
var endsLater = source1.startTime < source2.startTime && source1.endTime > source2.startTime;
|
|
18835
18964
|
var startsEarlier = source1.startTime > source2.startTime && source1.startTime < source2.endTime;
|
|
@@ -18883,8 +19012,8 @@ module.exports = function (SourceGroup, SegmentsGroup, Lines, DataRetriever, Uti
|
|
|
18883
19012
|
return this._lines.linesLength();
|
|
18884
19013
|
};
|
|
18885
19014
|
return SourcesLayer;
|
|
18886
|
-
}(_dereq_('./source-group'), _dereq_('./
|
|
18887
|
-
},{"./data-retriever":85,"./invoker":88,"./lines":92,"./
|
|
19015
|
+
}(_dereq_('./source-group'), _dereq_('./lines'), _dereq_('./data-retriever'), _dereq_('./utils'), _dereq_('./invoker'), _dereq_('konva'));
|
|
19016
|
+
},{"./data-retriever":85,"./invoker":88,"./lines":92,"./source-group":103,"./utils":110,"konva":43}],106:[function(_dereq_,module,exports){
|
|
18888
19017
|
module.exports = function (Utils, Konva) {
|
|
18889
19018
|
'use strict';
|
|
18890
19019
|
var LEFT_PADDING = 4;
|
|
@@ -19068,14 +19197,14 @@ module.exports = function (Colors, Segment, Utils) {
|
|
|
19068
19197
|
if (!Utils.isObject(options)) {
|
|
19069
19198
|
throw new TypeError('peaks.segments.add(): expected a Segment object parameter');
|
|
19070
19199
|
}
|
|
19071
|
-
var segment = new Segment(this._peaks, Utils.isNullOrUndefined(options.id) ? this._getNextSegmentId() : options.id, options.startTime, options.endTime, options.labelText, options.color || this._getSegmentColor(), options.textColor || '#000000', options.handleTextColor || '#000000', options.opacity || 1, true);
|
|
19200
|
+
var segment = new Segment(this._peaks, Utils.isNullOrUndefined(options.id) ? this._getNextSegmentId() : options.id, options.startTime, options.endTime, options.labelText, options.color || this._getSegmentColor(), options.textColor || '#000000', options.handleTextColor || '#000000', options.opacity || 1, true, options.allowDeletion || false, options.line);
|
|
19072
19201
|
return segment;
|
|
19073
19202
|
};
|
|
19074
19203
|
TimelineSegments.prototype.getSegments = function () {
|
|
19075
19204
|
return this._segments;
|
|
19076
19205
|
};
|
|
19077
|
-
TimelineSegments.prototype.addSegmentsToPosition = function (position) {
|
|
19078
|
-
this._peaks.emit('segments.show', position);
|
|
19206
|
+
TimelineSegments.prototype.addSegmentsToPosition = function (lineId, position) {
|
|
19207
|
+
this._peaks.emit('segments.show', lineId, position);
|
|
19079
19208
|
};
|
|
19080
19209
|
TimelineSegments.prototype.getSegment = function (id) {
|
|
19081
19210
|
return this._segmentsById[id] || null;
|
|
@@ -19166,10 +19295,10 @@ module.exports = function (Colors, Segment, Utils) {
|
|
|
19166
19295
|
}
|
|
19167
19296
|
return this._removeSegments(fnFilter);
|
|
19168
19297
|
};
|
|
19169
|
-
TimelineSegments.prototype.removeAll = function () {
|
|
19298
|
+
TimelineSegments.prototype.removeAll = function (lineId) {
|
|
19170
19299
|
this._segments = [];
|
|
19171
19300
|
this._segmentsById = {};
|
|
19172
|
-
this._peaks.emit('segments.remove_all');
|
|
19301
|
+
this._peaks.emit('segments.remove_all', lineId);
|
|
19173
19302
|
};
|
|
19174
19303
|
return TimelineSegments;
|
|
19175
19304
|
}(_dereq_('colors.css'), _dereq_('./segment'), _dereq_('./utils'));
|
|
@@ -19413,7 +19542,7 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
|
|
|
19413
19542
|
self._sourcesLayer = new SourcesLayer(peaks, self, true);
|
|
19414
19543
|
self._sourcesLayer.addToStage(self._stage);
|
|
19415
19544
|
self._axis.addFrontToStage(self._stage);
|
|
19416
|
-
self._playheadLayer = new PlayheadLayer(peaks, self, self._sourcesLayer
|
|
19545
|
+
self._playheadLayer = new PlayheadLayer(peaks, self, self._sourcesLayer, self._options.showPlayheadTime);
|
|
19417
19546
|
self._playheadLayer.addToStage(self._stage);
|
|
19418
19547
|
var time = self._peaks.player.getCurrentTime();
|
|
19419
19548
|
self._syncPlayhead(time);
|
|
@@ -19558,6 +19687,15 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
|
|
|
19558
19687
|
this._sourcesLayer.stopDrag();
|
|
19559
19688
|
this._sourcesLayer.draw();
|
|
19560
19689
|
};
|
|
19690
|
+
TimelineZoomView.prototype.selectSourceById = function (sourceId) {
|
|
19691
|
+
var sourceGroup = this._sourcesLayer.getSourceGroupById(sourceId);
|
|
19692
|
+
if (sourceGroup) {
|
|
19693
|
+
this._modeLayer.selectElement(sourceGroup, false);
|
|
19694
|
+
}
|
|
19695
|
+
};
|
|
19696
|
+
TimelineZoomView.prototype.deselectElement = function () {
|
|
19697
|
+
this._modeLayer.deselectElement(false);
|
|
19698
|
+
};
|
|
19561
19699
|
TimelineZoomView.prototype.isListening = function () {
|
|
19562
19700
|
return this._stage.listening();
|
|
19563
19701
|
};
|