@checksub_team/peaks_timeline 1.4.27 → 1.4.30
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 +203 -87
- package/src/line.js +12 -0
- package/src/lines.js +59 -5
- package/src/main.js +13 -3
- package/src/mode-layer.js +32 -11
- 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/sources-layer.js +4 -8
- package/src/timeline-segments.js +12 -7
- package/src/timeline-zoomview.js +4 -4
package/package.json
CHANGED
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');
|
|
@@ -15604,7 +15655,7 @@ module.exports = function (Colors, EventEmitter, TimelineSegments, TimelineSourc
|
|
|
15604
15655
|
return this.view.selectSourceById(sourceId);
|
|
15605
15656
|
};
|
|
15606
15657
|
Peaks.prototype.deselectSource = function () {
|
|
15607
|
-
return this.view.
|
|
15658
|
+
return this.view.deselectElement();
|
|
15608
15659
|
};
|
|
15609
15660
|
Peaks.prototype._addWindowResizeHandler = function () {
|
|
15610
15661
|
this._onResize = this._onResize.bind(this);
|
|
@@ -15693,21 +15744,29 @@ module.exports = function (Utils, SourceGroup, Konva) {
|
|
|
15693
15744
|
ModeLayer.prototype.addToStage = function (stage) {
|
|
15694
15745
|
stage.add(this._layer);
|
|
15695
15746
|
};
|
|
15696
|
-
ModeLayer.prototype.
|
|
15697
|
-
this.
|
|
15698
|
-
if (
|
|
15699
|
-
this._selectedElement =
|
|
15747
|
+
ModeLayer.prototype.selectElement = function (element, notify) {
|
|
15748
|
+
this.deselectElement(notify);
|
|
15749
|
+
if (element) {
|
|
15750
|
+
this._selectedElement = element;
|
|
15700
15751
|
this._selectedElement.setSelected(true);
|
|
15701
15752
|
if (notify) {
|
|
15702
|
-
|
|
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
|
+
}
|
|
15703
15758
|
}
|
|
15704
15759
|
}
|
|
15705
15760
|
};
|
|
15706
|
-
ModeLayer.prototype.
|
|
15761
|
+
ModeLayer.prototype.deselectElement = function (notify) {
|
|
15707
15762
|
if (this._selectedElement) {
|
|
15708
15763
|
this._selectedElement.setSelected(false);
|
|
15709
15764
|
if (notify) {
|
|
15710
|
-
|
|
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
|
+
}
|
|
15711
15770
|
}
|
|
15712
15771
|
this._selectedElement = null;
|
|
15713
15772
|
}
|
|
@@ -15763,14 +15822,22 @@ module.exports = function (Utils, SourceGroup, Konva) {
|
|
|
15763
15822
|
ModeLayer.prototype._onMouseClickInDefaultMode = function () {
|
|
15764
15823
|
var hoveredElement = this._view.getHoveredElement();
|
|
15765
15824
|
if (hoveredElement) {
|
|
15766
|
-
this.
|
|
15825
|
+
this.selectElement(hoveredElement, true);
|
|
15767
15826
|
} else {
|
|
15768
|
-
this.
|
|
15827
|
+
this.deselectElement(true);
|
|
15769
15828
|
}
|
|
15770
15829
|
};
|
|
15771
15830
|
ModeLayer.prototype._onKeyboardDelete = function () {
|
|
15772
15831
|
if (this._selectedElement) {
|
|
15773
|
-
this.
|
|
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
|
+
}
|
|
15774
15841
|
}
|
|
15775
15842
|
};
|
|
15776
15843
|
ModeLayer.prototype._onMouseEnterInCutMode = function () {
|
|
@@ -15888,7 +15955,7 @@ module.exports = function (Utils, SourceGroup, Konva) {
|
|
|
15888
15955
|
this._peaks.off('keyboard.delete', this._onKeyboardDelete);
|
|
15889
15956
|
break;
|
|
15890
15957
|
}
|
|
15891
|
-
this.
|
|
15958
|
+
this.deselectElement(true);
|
|
15892
15959
|
switch (mode) {
|
|
15893
15960
|
case 'cut':
|
|
15894
15961
|
this._stage.on('mouseover', this._onMouseEnterInCutMode);
|
|
@@ -16110,18 +16177,18 @@ module.exports = function (Utils) {
|
|
|
16110
16177
|
module.exports = function (Utils, Konva) {
|
|
16111
16178
|
'use strict';
|
|
16112
16179
|
var HANDLE_RADIUS = 10;
|
|
16113
|
-
function PlayheadLayer(peaks, view,
|
|
16180
|
+
function PlayheadLayer(peaks, view, lines, showTime) {
|
|
16114
16181
|
this._peaks = peaks;
|
|
16115
16182
|
this._view = view;
|
|
16116
|
-
this.
|
|
16183
|
+
this._lines = lines;
|
|
16117
16184
|
this._playheadPixel = 0;
|
|
16118
16185
|
this._playheadLineAnimation = null;
|
|
16119
16186
|
this._playheadVisible = false;
|
|
16120
16187
|
this._playheadColor = peaks.options.playheadColor;
|
|
16121
16188
|
this._playheadTextColor = peaks.options.playheadTextColor;
|
|
16122
16189
|
this._playheadLayer = new Konva.Layer();
|
|
16123
|
-
this.
|
|
16124
|
-
this.
|
|
16190
|
+
this._activeSegments = {};
|
|
16191
|
+
this._lastActiveSegments = {};
|
|
16125
16192
|
this._createPlayhead(this._playheadColor);
|
|
16126
16193
|
if (showTime) {
|
|
16127
16194
|
this._createPlayheadText(this._playheadTextColor);
|
|
@@ -16132,20 +16199,20 @@ module.exports = function (Utils, Konva) {
|
|
|
16132
16199
|
this._peaks.on('segments.remove', this._onSegmentsRemove.bind(this));
|
|
16133
16200
|
}
|
|
16134
16201
|
PlayheadLayer.prototype._onSegmentsRemoveAll = function () {
|
|
16135
|
-
this.
|
|
16136
|
-
this.
|
|
16202
|
+
this._activeSegments = {};
|
|
16203
|
+
this._lastActiveSegments = {};
|
|
16137
16204
|
};
|
|
16138
16205
|
PlayheadLayer.prototype._onSegmentsRemove = function (segments) {
|
|
16139
|
-
if (this.
|
|
16140
|
-
var activeSegmentId = this._activeSegment ? this._activeSegment.id : null;
|
|
16141
|
-
var lastActiveSegmentId = this._lastActiveSegmentId ? this._lastActiveSegmentId.id : null;
|
|
16206
|
+
if (this._activeSegments || this._lastActiveSegments) {
|
|
16142
16207
|
for (var id in segments) {
|
|
16143
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;
|
|
16144
16211
|
if (segments[id].id === activeSegmentId) {
|
|
16145
|
-
this.
|
|
16212
|
+
delete this._activeSegments[segments[id].line];
|
|
16146
16213
|
}
|
|
16147
16214
|
if (segments[id].id === lastActiveSegmentId) {
|
|
16148
|
-
this.
|
|
16215
|
+
delete this._lastActiveSegments[segments[id].line];
|
|
16149
16216
|
}
|
|
16150
16217
|
}
|
|
16151
16218
|
}
|
|
@@ -16263,16 +16330,21 @@ module.exports = function (Utils, Konva) {
|
|
|
16263
16330
|
}
|
|
16264
16331
|
var playheadPositionDiff = this._playheadGroup.x() - playheadX;
|
|
16265
16332
|
if (playheadPositionDiff) {
|
|
16266
|
-
var
|
|
16267
|
-
|
|
16268
|
-
if (
|
|
16269
|
-
this.
|
|
16270
|
-
this.
|
|
16271
|
-
|
|
16272
|
-
|
|
16273
|
-
|
|
16274
|
-
|
|
16275
|
-
|
|
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
|
+
}
|
|
16276
16348
|
}
|
|
16277
16349
|
}
|
|
16278
16350
|
}
|
|
@@ -16446,6 +16518,7 @@ module.exports = function (Konva, SegmentMarker) {
|
|
|
16446
16518
|
this._startMarker = null;
|
|
16447
16519
|
this._endMarker = null;
|
|
16448
16520
|
this._rectangle = null;
|
|
16521
|
+
this._isSelected = false;
|
|
16449
16522
|
this._segmentHeight = this._peaks.options.segmentHeight;
|
|
16450
16523
|
this._rectangle = new Konva.Rect({
|
|
16451
16524
|
x: this._view.timeToPixels(this._segment.startTime),
|
|
@@ -16604,12 +16677,14 @@ module.exports = function (Konva, SegmentMarker) {
|
|
|
16604
16677
|
};
|
|
16605
16678
|
SegmentShape.prototype._onMouseEnter = function () {
|
|
16606
16679
|
this._view.setCursor('pointer');
|
|
16607
|
-
this.
|
|
16680
|
+
this._view.setHoveredElement(this);
|
|
16681
|
+
this._rectangle.fill(this._segment.activeColor + Math.round(this._segment.opacity * 255).toString(16));
|
|
16608
16682
|
this._view.drawSourcesLayer();
|
|
16609
16683
|
this._peaks.emit('segments.mouseenter', this._segment);
|
|
16610
16684
|
};
|
|
16611
16685
|
SegmentShape.prototype._onMouseLeave = function () {
|
|
16612
16686
|
this._view.setCursor('default');
|
|
16687
|
+
this._view.setHoveredElement(null);
|
|
16613
16688
|
this._rectangle.fill(this._segment.color + Math.round(this._segment.opacity * 255).toString(16));
|
|
16614
16689
|
this._view.drawSourcesLayer();
|
|
16615
16690
|
this._peaks.emit('segments.mouseleave', this._segment);
|
|
@@ -16641,6 +16716,9 @@ module.exports = function (Konva, SegmentMarker) {
|
|
|
16641
16716
|
var startMarker = segmentMarker.isStartMarker();
|
|
16642
16717
|
this._peaks.emit('segments.dragend', this._segment, startMarker);
|
|
16643
16718
|
};
|
|
16719
|
+
SegmentShape.prototype.setSelected = function (isSelected) {
|
|
16720
|
+
this._isSelected = isSelected;
|
|
16721
|
+
};
|
|
16644
16722
|
SegmentShape.prototype.fitToView = function () {
|
|
16645
16723
|
if (this._startMarker) {
|
|
16646
16724
|
this._startMarker.fitToView();
|
|
@@ -16693,8 +16771,11 @@ module.exports = function (Utils) {
|
|
|
16693
16771
|
} else if (!Utils.isString(options.labelText)) {
|
|
16694
16772
|
throw new TypeError('peaks.segments.' + context + ': labelText must be a string');
|
|
16695
16773
|
}
|
|
16774
|
+
if (!Utils.isInteger(options.line)) {
|
|
16775
|
+
throw new TypeError('peaks.segments.' + context + ': line must be an integer');
|
|
16776
|
+
}
|
|
16696
16777
|
}
|
|
16697
|
-
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) {
|
|
16698
16779
|
var opts = {
|
|
16699
16780
|
startTime: startTime,
|
|
16700
16781
|
endTime: endTime,
|
|
@@ -16703,7 +16784,9 @@ module.exports = function (Utils) {
|
|
|
16703
16784
|
textColor: textColor,
|
|
16704
16785
|
handleTextColor: handleTextColor,
|
|
16705
16786
|
opacity: opacity,
|
|
16706
|
-
editable: editable
|
|
16787
|
+
editable: editable,
|
|
16788
|
+
allowDeletion: allowDeletion,
|
|
16789
|
+
line: line
|
|
16707
16790
|
};
|
|
16708
16791
|
validateSegment(peaks, opts, 'add()');
|
|
16709
16792
|
this._peaks = peaks;
|
|
@@ -16712,11 +16795,13 @@ module.exports = function (Utils) {
|
|
|
16712
16795
|
this._endTime = opts.endTime;
|
|
16713
16796
|
this._labelText = opts.labelText;
|
|
16714
16797
|
this._color = opts.color;
|
|
16715
|
-
this.
|
|
16798
|
+
this._activeColor = Utils.shadeColor(color, 20);
|
|
16716
16799
|
this._textColor = opts.textColor;
|
|
16717
16800
|
this._handleTextColor = opts.handleTextColor;
|
|
16718
16801
|
this._opacity = opts.opacity;
|
|
16719
16802
|
this._editable = opts.editable;
|
|
16803
|
+
this._allowDeletion = opts.allowDeletion;
|
|
16804
|
+
this._line = opts.line;
|
|
16720
16805
|
this._minSize = peaks.options.minSegmentSize;
|
|
16721
16806
|
}
|
|
16722
16807
|
Object.defineProperties(Segment.prototype, {
|
|
@@ -16756,10 +16841,10 @@ module.exports = function (Utils) {
|
|
|
16756
16841
|
return this._color;
|
|
16757
16842
|
}
|
|
16758
16843
|
},
|
|
16759
|
-
|
|
16844
|
+
activeColor: {
|
|
16760
16845
|
enumerable: true,
|
|
16761
16846
|
get: function () {
|
|
16762
|
-
return this.
|
|
16847
|
+
return this._activeColor;
|
|
16763
16848
|
}
|
|
16764
16849
|
},
|
|
16765
16850
|
textColor: {
|
|
@@ -16786,6 +16871,18 @@ module.exports = function (Utils) {
|
|
|
16786
16871
|
return this._editable;
|
|
16787
16872
|
}
|
|
16788
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
|
+
},
|
|
16789
16886
|
minSize: {
|
|
16790
16887
|
enumerable: true,
|
|
16791
16888
|
get: function () {
|
|
@@ -16802,7 +16899,9 @@ module.exports = function (Utils) {
|
|
|
16802
16899
|
textColor: this.textColor,
|
|
16803
16900
|
handleTextColor: this.handleTextColor,
|
|
16804
16901
|
opacity: this.opacity,
|
|
16805
|
-
editable: this.editable
|
|
16902
|
+
editable: this.editable,
|
|
16903
|
+
allowDeletion: this.allowDeletion,
|
|
16904
|
+
line: this.line
|
|
16806
16905
|
};
|
|
16807
16906
|
Utils.extend(opts, options);
|
|
16808
16907
|
validateSegment(this._peaks, opts, 'update()');
|
|
@@ -16814,6 +16913,8 @@ module.exports = function (Utils) {
|
|
|
16814
16913
|
this._handleTextColor = opts.handleTextColor;
|
|
16815
16914
|
this._opacity = opts.opacity;
|
|
16816
16915
|
this._editable = opts.editable;
|
|
16916
|
+
this._allowDeletion = opts.allowDeletion;
|
|
16917
|
+
this._line = opts.line;
|
|
16817
16918
|
this._peaks.emit('segment.updated', this);
|
|
16818
16919
|
};
|
|
16819
16920
|
Segment.prototype.isVisible = function (startTime, endTime) {
|
|
@@ -16835,11 +16936,6 @@ module.exports = function (SegmentShape, Utils, Konva) {
|
|
|
16835
16936
|
this._group = new Konva.Group();
|
|
16836
16937
|
this._updatedSegments = [];
|
|
16837
16938
|
this._isMagnetized = false;
|
|
16838
|
-
this._peaks.on('segment.updated', this._onSegmentsUpdate.bind(this));
|
|
16839
|
-
this._peaks.on('segments.add', this._onSegmentsAdd.bind(this));
|
|
16840
|
-
this._peaks.on('segments.remove', this._onSegmentsRemove.bind(this));
|
|
16841
|
-
this._peaks.on('segments.remove_all', this._onSegmentsRemoveAll.bind(this));
|
|
16842
|
-
this._peaks.on('segments.dragend', this._onSegmentUpdated.bind(this));
|
|
16843
16939
|
this._peaks.on('segments.setMagnetizing', this.setMagnetizing.bind(this));
|
|
16844
16940
|
}
|
|
16845
16941
|
SegmentsGroup.prototype.addToGroup = function (group) {
|
|
@@ -16882,7 +16978,7 @@ module.exports = function (SegmentShape, Utils, Konva) {
|
|
|
16882
16978
|
} while (nextSegmentId);
|
|
16883
16979
|
return activeSegment;
|
|
16884
16980
|
};
|
|
16885
|
-
SegmentsGroup.prototype.
|
|
16981
|
+
SegmentsGroup.prototype.onSegmentsUpdate = function (segment) {
|
|
16886
16982
|
if (this._segments[segment.id]) {
|
|
16887
16983
|
var redraw = false;
|
|
16888
16984
|
var segmentShape = this._segmentShapes[segment.id];
|
|
@@ -16905,11 +17001,11 @@ module.exports = function (SegmentShape, Utils, Konva) {
|
|
|
16905
17001
|
}
|
|
16906
17002
|
}
|
|
16907
17003
|
};
|
|
16908
|
-
SegmentsGroup.prototype.
|
|
17004
|
+
SegmentsGroup.prototype.onSegmentUpdated = function () {
|
|
16909
17005
|
this._peaks.emit('segments.updated', this._updatedSegments);
|
|
16910
17006
|
this._updatedSegments = [];
|
|
16911
17007
|
};
|
|
16912
|
-
SegmentsGroup.prototype.
|
|
17008
|
+
SegmentsGroup.prototype.onSegmentsAdd = function (segments) {
|
|
16913
17009
|
var self = this;
|
|
16914
17010
|
var frameOffset = self._view.getFrameOffset();
|
|
16915
17011
|
var width = self._view.getWidth();
|
|
@@ -16920,7 +17016,7 @@ module.exports = function (SegmentShape, Utils, Konva) {
|
|
|
16920
17016
|
});
|
|
16921
17017
|
self.updateSegments(frameStartTime, frameEndTime);
|
|
16922
17018
|
};
|
|
16923
|
-
SegmentsGroup.prototype.
|
|
17019
|
+
SegmentsGroup.prototype.onSegmentsRemove = function (segments) {
|
|
16924
17020
|
var self = this;
|
|
16925
17021
|
segments.forEach(function (segment) {
|
|
16926
17022
|
var index = self._updatedSegments.indexOf(segment);
|
|
@@ -16932,7 +17028,7 @@ module.exports = function (SegmentShape, Utils, Konva) {
|
|
|
16932
17028
|
});
|
|
16933
17029
|
this._draw();
|
|
16934
17030
|
};
|
|
16935
|
-
SegmentsGroup.prototype.
|
|
17031
|
+
SegmentsGroup.prototype.onSegmentsRemoveAll = function () {
|
|
16936
17032
|
this._group.removeChildren();
|
|
16937
17033
|
this._firstSegmentId = null;
|
|
16938
17034
|
this._segments = {};
|
|
@@ -17013,7 +17109,7 @@ module.exports = function (SegmentShape, Utils, Konva) {
|
|
|
17013
17109
|
this._updateSegments(segment, marker);
|
|
17014
17110
|
};
|
|
17015
17111
|
SegmentsGroup.prototype.updateSegments = function (startTime, endTime) {
|
|
17016
|
-
var segments = this.
|
|
17112
|
+
var segments = this.find(startTime, endTime);
|
|
17017
17113
|
var count = segments.length;
|
|
17018
17114
|
segments.forEach(this._updateSegment.bind(this));
|
|
17019
17115
|
count += this._removeInvisibleSegments(startTime, endTime);
|
|
@@ -17021,6 +17117,25 @@ module.exports = function (SegmentShape, Utils, Konva) {
|
|
|
17021
17117
|
this._draw();
|
|
17022
17118
|
}
|
|
17023
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
|
+
};
|
|
17024
17139
|
SegmentsGroup.prototype._draw = function () {
|
|
17025
17140
|
this._view.drawSourcesLayer();
|
|
17026
17141
|
};
|
|
@@ -17036,8 +17151,12 @@ module.exports = function (SegmentShape, Utils, Konva) {
|
|
|
17036
17151
|
break;
|
|
17037
17152
|
}
|
|
17038
17153
|
}
|
|
17039
|
-
if (!currentHeight
|
|
17040
|
-
|
|
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
|
+
}
|
|
17041
17160
|
}
|
|
17042
17161
|
return currentHeight;
|
|
17043
17162
|
};
|
|
@@ -17265,11 +17384,7 @@ module.exports = function (SegmentShape, Utils, Konva) {
|
|
|
17265
17384
|
return endsLater || startsEarlier;
|
|
17266
17385
|
};
|
|
17267
17386
|
SegmentsGroup.prototype.destroy = function () {
|
|
17268
|
-
this._peaks.off('
|
|
17269
|
-
this._peaks.off('segments.add', this._onSegmentsAdd);
|
|
17270
|
-
this._peaks.off('segments.remove', this._onSegmentsRemove);
|
|
17271
|
-
this._peaks.off('segments.remove_all', this._onSegmentsRemoveAll);
|
|
17272
|
-
this._peaks.off('segments.dragged', this._onSegmentsDragged);
|
|
17387
|
+
this._peaks.off('segments.setMagnetizing', this.setMagnetizing);
|
|
17273
17388
|
};
|
|
17274
17389
|
SegmentsGroup.prototype.fitToView = function () {
|
|
17275
17390
|
for (var segmentId in this._segmentShapes) {
|
|
@@ -18552,7 +18667,7 @@ module.exports = function (Utils) {
|
|
|
18552
18667
|
return Source;
|
|
18553
18668
|
}(_dereq_('./utils'));
|
|
18554
18669
|
},{"./utils":110}],105:[function(_dereq_,module,exports){
|
|
18555
|
-
module.exports = function (SourceGroup,
|
|
18670
|
+
module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Konva) {
|
|
18556
18671
|
'use strict';
|
|
18557
18672
|
function SourcesLayer(peaks, view, allowEditing) {
|
|
18558
18673
|
this._peaks = peaks;
|
|
@@ -18563,7 +18678,6 @@ module.exports = function (SourceGroup, SegmentsGroup, Lines, DataRetriever, Uti
|
|
|
18563
18678
|
this._dataRetriever = new DataRetriever(peaks);
|
|
18564
18679
|
this._lines = new Lines(peaks, view, this);
|
|
18565
18680
|
this._lines.addToLayer(this);
|
|
18566
|
-
this._segmentsGroup = new SegmentsGroup(peaks, view, true);
|
|
18567
18681
|
this._loadedData = {};
|
|
18568
18682
|
this._debouncedRescale = new Invoker().debounce(this._rescale, 150);
|
|
18569
18683
|
this._peaks.on('sources.add', this._onSourcesAdd.bind(this));
|
|
@@ -18582,8 +18696,8 @@ module.exports = function (SourceGroup, SegmentsGroup, Lines, DataRetriever, Uti
|
|
|
18582
18696
|
SourcesLayer.prototype.setLoadedData = function (id, data) {
|
|
18583
18697
|
this._loadedData[id] = data;
|
|
18584
18698
|
};
|
|
18585
|
-
SourcesLayer.prototype.
|
|
18586
|
-
return this.
|
|
18699
|
+
SourcesLayer.prototype.getSegmentsGroups = function () {
|
|
18700
|
+
return this._lines.getSegmentsGroups();
|
|
18587
18701
|
};
|
|
18588
18702
|
SourcesLayer.prototype.add = function (element) {
|
|
18589
18703
|
this._layer.add(element);
|
|
@@ -18703,8 +18817,8 @@ module.exports = function (SourceGroup, SegmentsGroup, Lines, DataRetriever, Uti
|
|
|
18703
18817
|
SourcesLayer.prototype._onSourcesRefresh = function () {
|
|
18704
18818
|
this._layer.draw();
|
|
18705
18819
|
};
|
|
18706
|
-
SourcesLayer.prototype._onSegmentsShow = function (position) {
|
|
18707
|
-
this._lines.addSegments(
|
|
18820
|
+
SourcesLayer.prototype._onSegmentsShow = function (lineId, position) {
|
|
18821
|
+
this._lines.addSegments(lineId, position);
|
|
18708
18822
|
this._view.updateTimelineLength();
|
|
18709
18823
|
this._layer.draw();
|
|
18710
18824
|
};
|
|
@@ -18898,8 +19012,8 @@ module.exports = function (SourceGroup, SegmentsGroup, Lines, DataRetriever, Uti
|
|
|
18898
19012
|
return this._lines.linesLength();
|
|
18899
19013
|
};
|
|
18900
19014
|
return SourcesLayer;
|
|
18901
|
-
}(_dereq_('./source-group'), _dereq_('./
|
|
18902
|
-
},{"./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){
|
|
18903
19017
|
module.exports = function (Utils, Konva) {
|
|
18904
19018
|
'use strict';
|
|
18905
19019
|
var LEFT_PADDING = 4;
|
|
@@ -19083,14 +19197,14 @@ module.exports = function (Colors, Segment, Utils) {
|
|
|
19083
19197
|
if (!Utils.isObject(options)) {
|
|
19084
19198
|
throw new TypeError('peaks.segments.add(): expected a Segment object parameter');
|
|
19085
19199
|
}
|
|
19086
|
-
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);
|
|
19087
19201
|
return segment;
|
|
19088
19202
|
};
|
|
19089
19203
|
TimelineSegments.prototype.getSegments = function () {
|
|
19090
19204
|
return this._segments;
|
|
19091
19205
|
};
|
|
19092
|
-
TimelineSegments.prototype.addSegmentsToPosition = function (position) {
|
|
19093
|
-
this._peaks.emit('segments.show', position);
|
|
19206
|
+
TimelineSegments.prototype.addSegmentsToPosition = function (lineId, position) {
|
|
19207
|
+
this._peaks.emit('segments.show', lineId, position);
|
|
19094
19208
|
};
|
|
19095
19209
|
TimelineSegments.prototype.getSegment = function (id) {
|
|
19096
19210
|
return this._segmentsById[id] || null;
|
|
@@ -19181,10 +19295,12 @@ module.exports = function (Colors, Segment, Utils) {
|
|
|
19181
19295
|
}
|
|
19182
19296
|
return this._removeSegments(fnFilter);
|
|
19183
19297
|
};
|
|
19184
|
-
TimelineSegments.prototype.removeAll = function () {
|
|
19185
|
-
this.
|
|
19186
|
-
|
|
19187
|
-
|
|
19298
|
+
TimelineSegments.prototype.removeAll = function (lineId) {
|
|
19299
|
+
var indexes = this._findSegment(function (segment) {
|
|
19300
|
+
return segment.line === lineId;
|
|
19301
|
+
});
|
|
19302
|
+
this._removeIndexes(indexes);
|
|
19303
|
+
this._peaks.emit('segments.remove_all', lineId);
|
|
19188
19304
|
};
|
|
19189
19305
|
return TimelineSegments;
|
|
19190
19306
|
}(_dereq_('colors.css'), _dereq_('./segment'), _dereq_('./utils'));
|
|
@@ -19428,7 +19544,7 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
|
|
|
19428
19544
|
self._sourcesLayer = new SourcesLayer(peaks, self, true);
|
|
19429
19545
|
self._sourcesLayer.addToStage(self._stage);
|
|
19430
19546
|
self._axis.addFrontToStage(self._stage);
|
|
19431
|
-
self._playheadLayer = new PlayheadLayer(peaks, self, self._sourcesLayer
|
|
19547
|
+
self._playheadLayer = new PlayheadLayer(peaks, self, self._sourcesLayer, self._options.showPlayheadTime);
|
|
19432
19548
|
self._playheadLayer.addToStage(self._stage);
|
|
19433
19549
|
var time = self._peaks.player.getCurrentTime();
|
|
19434
19550
|
self._syncPlayhead(time);
|
|
@@ -19576,11 +19692,11 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
|
|
|
19576
19692
|
TimelineZoomView.prototype.selectSourceById = function (sourceId) {
|
|
19577
19693
|
var sourceGroup = this._sourcesLayer.getSourceGroupById(sourceId);
|
|
19578
19694
|
if (sourceGroup) {
|
|
19579
|
-
this._modeLayer.
|
|
19695
|
+
this._modeLayer.selectElement(sourceGroup, false);
|
|
19580
19696
|
}
|
|
19581
19697
|
};
|
|
19582
|
-
TimelineZoomView.prototype.
|
|
19583
|
-
this._modeLayer.
|
|
19698
|
+
TimelineZoomView.prototype.deselectElement = function () {
|
|
19699
|
+
this._modeLayer.deselectElement(false);
|
|
19584
19700
|
};
|
|
19585
19701
|
TimelineZoomView.prototype.isListening = function () {
|
|
19586
19702
|
return this._stage.listening();
|
package/src/line.js
CHANGED
|
@@ -279,6 +279,18 @@ define([
|
|
|
279
279
|
segmentsGroup.addToGroup(this._group);
|
|
280
280
|
};
|
|
281
281
|
|
|
282
|
+
Line.prototype.refreshSegmentsHeight = function() {
|
|
283
|
+
if (this.isSegmentsLine) {
|
|
284
|
+
var oldHeight = this._height;
|
|
285
|
+
|
|
286
|
+
this._height = this._segmentsGroup.getCurrentHeight();
|
|
287
|
+
|
|
288
|
+
if (this._height !== oldHeight) {
|
|
289
|
+
this._peaks.emit('line.heightChanged', this._position);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
|
|
282
294
|
Line.prototype._canBePlacedBetween = function(startTime, endTime, startLimit, endLimit) {
|
|
283
295
|
var timeWidth = endTime - startTime;
|
|
284
296
|
var newTimes = null;
|