@checksub_team/peaks_timeline 1.15.5 → 1.15.6
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 +44 -143
- package/src/line-indicator.js +1 -158
- package/src/line.js +10 -11
- package/src/main.js +0 -6
- package/src/source-group.js +28 -9
- package/src/sources-layer.js +10 -8
- package/src/timeline-zoomview.js +1 -1
package/package.json
CHANGED
package/peaks.js
CHANGED
|
@@ -14776,9 +14776,6 @@ module.exports = function (Konva, Utils, SVGs) {
|
|
|
14776
14776
|
});
|
|
14777
14777
|
this._layer.add(this._separatingLine);
|
|
14778
14778
|
this._layer.draw();
|
|
14779
|
-
if (this._peaks.options.enableLineIndicatorContextMenu) {
|
|
14780
|
-
this._createContextMenu();
|
|
14781
|
-
}
|
|
14782
14779
|
this._peaks.on('lineIndicator.setType', this._onSetType.bind(this));
|
|
14783
14780
|
this._peaks.on('lineIndicator.setText', this._onSetText.bind(this));
|
|
14784
14781
|
}
|
|
@@ -14924,8 +14921,7 @@ module.exports = function (Konva, Utils, SVGs) {
|
|
|
14924
14921
|
if (this._indicators[lineId]) {
|
|
14925
14922
|
var y = this._indicators[lineId].line.getY();
|
|
14926
14923
|
var isVisible = y + this._indicators[lineId].line.lineHeight() + this._yPadding > 0 && y - this._yPadding < this._height;
|
|
14927
|
-
|
|
14928
|
-
if (isLineNotEmpty && isVisible) {
|
|
14924
|
+
if (isVisible) {
|
|
14929
14925
|
if (!this._indicators[lineId].indicator) {
|
|
14930
14926
|
this._indicators[lineId].indicator = this._createIndicator(this._indicators[lineId].line, this._indicators[lineId].type, this._indicators[lineId].text);
|
|
14931
14927
|
this._layer.add(this._indicators[lineId].indicator);
|
|
@@ -14947,118 +14943,6 @@ module.exports = function (Konva, Utils, SVGs) {
|
|
|
14947
14943
|
LineIndicator.prototype.draw = function () {
|
|
14948
14944
|
this._layer.draw();
|
|
14949
14945
|
};
|
|
14950
|
-
LineIndicator.prototype._createContextMenu = function () {
|
|
14951
|
-
var menu = document.createElement('div');
|
|
14952
|
-
var addLine = document.createElement('button');
|
|
14953
|
-
var addLineAbove = document.createElement('button');
|
|
14954
|
-
var addLineBelow = document.createElement('button');
|
|
14955
|
-
var deleteLine = document.createElement('button');
|
|
14956
|
-
var currentIndicator = null;
|
|
14957
|
-
var self = this;
|
|
14958
|
-
menu.style.display = 'none';
|
|
14959
|
-
menu.style.position = 'absolute';
|
|
14960
|
-
menu.style.backgroundColor = 'white';
|
|
14961
|
-
menu.style.boxShadow = '0 0 5px grey';
|
|
14962
|
-
menu.style.borderRadius = '3px';
|
|
14963
|
-
menu.style.zIndex = 2;
|
|
14964
|
-
addLine.style.display = 'none';
|
|
14965
|
-
addLine.style.border = 'none';
|
|
14966
|
-
addLine.style.margin = '0';
|
|
14967
|
-
addLine.style.width = '100%';
|
|
14968
|
-
addLine.style.backgroundColor = 'white';
|
|
14969
|
-
addLine.style.padding = '10px';
|
|
14970
|
-
addLine.textContent = 'Add first line';
|
|
14971
|
-
addLine.onmouseover = function () {
|
|
14972
|
-
this.style.backgroundColor = 'lightgray';
|
|
14973
|
-
};
|
|
14974
|
-
addLine.onmouseout = function () {
|
|
14975
|
-
this.style.backgroundColor = 'white';
|
|
14976
|
-
};
|
|
14977
|
-
addLineAbove.style.display = 'none';
|
|
14978
|
-
addLineAbove.style.border = 'none';
|
|
14979
|
-
addLineAbove.style.margin = '0';
|
|
14980
|
-
addLineAbove.style.width = '100%';
|
|
14981
|
-
addLineAbove.style.backgroundColor = 'white';
|
|
14982
|
-
addLineAbove.style.padding = '10px';
|
|
14983
|
-
addLineAbove.textContent = 'Add line above';
|
|
14984
|
-
addLineAbove.onmouseover = function () {
|
|
14985
|
-
this.style.backgroundColor = 'lightgray';
|
|
14986
|
-
};
|
|
14987
|
-
addLineAbove.onmouseout = function () {
|
|
14988
|
-
this.style.backgroundColor = 'white';
|
|
14989
|
-
};
|
|
14990
|
-
addLineBelow.style.display = 'none';
|
|
14991
|
-
addLineBelow.style.border = 'none';
|
|
14992
|
-
addLineBelow.style.margin = '0';
|
|
14993
|
-
addLineBelow.style.width = '100%';
|
|
14994
|
-
addLineBelow.style.backgroundColor = 'white';
|
|
14995
|
-
addLineBelow.style.padding = '10px';
|
|
14996
|
-
addLineBelow.textContent = 'Add line below';
|
|
14997
|
-
addLineBelow.onmouseover = function () {
|
|
14998
|
-
this.style.backgroundColor = 'lightgray';
|
|
14999
|
-
};
|
|
15000
|
-
addLineBelow.onmouseout = function () {
|
|
15001
|
-
this.style.backgroundColor = 'white';
|
|
15002
|
-
};
|
|
15003
|
-
deleteLine.style.display = 'none';
|
|
15004
|
-
deleteLine.style.border = 'none';
|
|
15005
|
-
deleteLine.style.margin = '0';
|
|
15006
|
-
deleteLine.style.width = '100%';
|
|
15007
|
-
deleteLine.style.backgroundColor = 'white';
|
|
15008
|
-
deleteLine.style.padding = '10px';
|
|
15009
|
-
deleteLine.textContent = 'Delete line';
|
|
15010
|
-
deleteLine.onmouseover = function () {
|
|
15011
|
-
this.style.backgroundColor = 'lightgray';
|
|
15012
|
-
};
|
|
15013
|
-
deleteLine.onmouseout = function () {
|
|
15014
|
-
this.style.backgroundColor = 'white';
|
|
15015
|
-
};
|
|
15016
|
-
menu.appendChild(addLine);
|
|
15017
|
-
menu.appendChild(addLineAbove);
|
|
15018
|
-
menu.appendChild(addLineBelow);
|
|
15019
|
-
menu.appendChild(deleteLine);
|
|
15020
|
-
this._container.appendChild(menu);
|
|
15021
|
-
addLine.addEventListener('click', function () {
|
|
15022
|
-
self._peaks.emit('line.add', 0);
|
|
15023
|
-
self.draw();
|
|
15024
|
-
});
|
|
15025
|
-
addLineAbove.addEventListener('click', function () {
|
|
15026
|
-
var line = self._indicators[currentIndicator.getAttr('lineId')].line;
|
|
15027
|
-
self._peaks.emit('line.add', Number(line.getPosition()));
|
|
15028
|
-
self.draw();
|
|
15029
|
-
});
|
|
15030
|
-
addLineBelow.addEventListener('click', function () {
|
|
15031
|
-
var line = self._indicators[currentIndicator.getAttr('lineId')].line;
|
|
15032
|
-
self._peaks.emit('line.add', Number(line.getPosition()) + 1);
|
|
15033
|
-
self.draw();
|
|
15034
|
-
});
|
|
15035
|
-
deleteLine.addEventListener('click', function () {
|
|
15036
|
-
var line = self._indicators[currentIndicator.getAttr('lineId')].line;
|
|
15037
|
-
self._peaks.emit('line.remove', Number(line.getPosition()));
|
|
15038
|
-
self.draw();
|
|
15039
|
-
});
|
|
15040
|
-
window.addEventListener('click', function () {
|
|
15041
|
-
menu.style.display = 'none';
|
|
15042
|
-
});
|
|
15043
|
-
this._stage.on('contextmenu', function (e) {
|
|
15044
|
-
e.evt.preventDefault();
|
|
15045
|
-
if (e.target === self._stage && Object.keys(self._indicators).length === 0) {
|
|
15046
|
-
addLine.style.display = 'block';
|
|
15047
|
-
addLineAbove.style.display = 'none';
|
|
15048
|
-
addLineBelow.style.display = 'none';
|
|
15049
|
-
deleteLine.style.display = 'none';
|
|
15050
|
-
self._showMenu(menu);
|
|
15051
|
-
} else if (e.target !== self._stage) {
|
|
15052
|
-
currentIndicator = e.target;
|
|
15053
|
-
addLine.style.display = 'none';
|
|
15054
|
-
addLineAbove.style.display = 'block';
|
|
15055
|
-
addLineBelow.style.display = 'block';
|
|
15056
|
-
deleteLine.style.display = 'block';
|
|
15057
|
-
deleteLine.disabled = !self._indicators[currentIndicator.getAttr('lineId')].line.isEmpty();
|
|
15058
|
-
self._showMenu(menu);
|
|
15059
|
-
}
|
|
15060
|
-
});
|
|
15061
|
-
};
|
|
15062
14946
|
return LineIndicator;
|
|
15063
14947
|
}(_dereq_('konva'), _dereq_('./utils'), _dereq_('./svgs'));
|
|
15064
14948
|
},{"./svgs":108,"./utils":113,"konva":43}],92:[function(_dereq_,module,exports){
|
|
@@ -15425,19 +15309,20 @@ module.exports = function (Konva, Utils) {
|
|
|
15425
15309
|
this._sources[source.id] = sourceObj;
|
|
15426
15310
|
};
|
|
15427
15311
|
Line.prototype.manageCollision = function (source, newStartX, newEndX) {
|
|
15312
|
+
var originalStartTime = null;
|
|
15313
|
+
var originalEndTime = null;
|
|
15428
15314
|
var newStartTime = null;
|
|
15429
15315
|
var newEndTime = null;
|
|
15430
15316
|
var startLimited = false;
|
|
15431
15317
|
var endLimited = false;
|
|
15432
|
-
var timeWidth = this._view.pixelsToTime(newEndX - newStartX);
|
|
15433
15318
|
var newXs = {
|
|
15434
15319
|
startX: newStartX,
|
|
15435
15320
|
endX: newEndX,
|
|
15436
|
-
updateWidth: false,
|
|
15437
15321
|
updateTimelineLength: false
|
|
15438
15322
|
};
|
|
15439
15323
|
if (newStartX !== null) {
|
|
15440
|
-
|
|
15324
|
+
originalStartTime = this._view.pixelsToTime(newStartX);
|
|
15325
|
+
newStartTime = originalStartTime;
|
|
15441
15326
|
if (source.startTime > newStartTime) {
|
|
15442
15327
|
if (this._sources[source.id].prevSourceId) {
|
|
15443
15328
|
var previousSource = this._sources[this._sources[source.id].prevSourceId].source;
|
|
@@ -15454,7 +15339,8 @@ module.exports = function (Konva, Utils) {
|
|
|
15454
15339
|
}
|
|
15455
15340
|
}
|
|
15456
15341
|
if (newEndX !== null) {
|
|
15457
|
-
|
|
15342
|
+
originalEndTime = this._view.pixelsToTime(newEndX);
|
|
15343
|
+
newEndTime = originalEndTime;
|
|
15458
15344
|
if (source.endTime < newEndTime) {
|
|
15459
15345
|
if (this._sources[source.id].nextSourceId) {
|
|
15460
15346
|
var nextSource = this._sources[this._sources[source.id].nextSourceId].source;
|
|
@@ -15466,6 +15352,7 @@ module.exports = function (Konva, Utils) {
|
|
|
15466
15352
|
}
|
|
15467
15353
|
}
|
|
15468
15354
|
if (newStartTime !== null && newEndTime !== null) {
|
|
15355
|
+
var timeWidth = Utils.roundTime(originalEndTime - originalStartTime);
|
|
15469
15356
|
if (startLimited) {
|
|
15470
15357
|
newEndTime = newStartTime + timeWidth;
|
|
15471
15358
|
}
|
|
@@ -15491,18 +15378,15 @@ module.exports = function (Konva, Utils) {
|
|
|
15491
15378
|
}
|
|
15492
15379
|
}
|
|
15493
15380
|
}
|
|
15494
|
-
if (newStartTime !== null) {
|
|
15381
|
+
if (newStartTime !== null && newStartTime !== originalStartTime) {
|
|
15495
15382
|
newXs.startX = this._view.timeToPixels(newStartTime);
|
|
15496
15383
|
}
|
|
15497
|
-
if (newEndTime !== null) {
|
|
15384
|
+
if (newEndTime !== null && newEndTime !== originalEndTime) {
|
|
15498
15385
|
newXs.endX = this._view.timeToPixels(newEndTime);
|
|
15499
15386
|
if (this._sources[source.id].nextSourceId === null) {
|
|
15500
15387
|
newXs.updateTimelineLength = true;
|
|
15501
15388
|
}
|
|
15502
15389
|
}
|
|
15503
|
-
if (newXs.startX !== null && newXs.endX === null || newXs.startX === null && newXs.endX !== null) {
|
|
15504
|
-
newXs.updateWidth = true;
|
|
15505
|
-
}
|
|
15506
15390
|
return newXs;
|
|
15507
15391
|
};
|
|
15508
15392
|
Line.prototype.getSourcesAfter = function (time) {
|
|
@@ -15970,7 +15854,6 @@ module.exports = function (Colors, EventEmitter, TimelineSegments, TimelineSourc
|
|
|
15970
15854
|
sourceButtonsXOffset: 8,
|
|
15971
15855
|
sourceButtonsYOffset: 0,
|
|
15972
15856
|
autoScrollThreshold: 0.05,
|
|
15973
|
-
enableLineIndicatorContextMenu: true,
|
|
15974
15857
|
minSourceSize: 0.05,
|
|
15975
15858
|
minSegmentSize: 0.2,
|
|
15976
15859
|
canMoveSourcesBetweenLines: true
|
|
@@ -18186,13 +18069,16 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Loader, Konva)
|
|
|
18186
18069
|
this._indicators = {};
|
|
18187
18070
|
var self = this;
|
|
18188
18071
|
this._x = this._view.timeToPixels(source.startTime);
|
|
18072
|
+
this._roundedX = Math.round(this._x);
|
|
18189
18073
|
this._width = this._view.timeToPixels(source.endTime - source.startTime);
|
|
18074
|
+
this._roundedWidth = Math.round(this._width);
|
|
18190
18075
|
this._unwrappedHeight = source.binaryHeight && source.previewHeight ? source.binaryHeight + source.previewHeight : this._peaks.options.lineHeight;
|
|
18191
18076
|
this._wrappedHeight = this._peaks.options.wrappedLineHeight;
|
|
18192
18077
|
this._borderWidth = this._source.borderWidth || 0;
|
|
18193
18078
|
this._height = this._unwrappedHeight;
|
|
18194
18079
|
this._currentTimeToPixelsScaleUsed = this._view.getTimeToPixelsScale();
|
|
18195
18080
|
this._selected = this._source.selected;
|
|
18081
|
+
this._isDragged = false;
|
|
18196
18082
|
this._previewList = [];
|
|
18197
18083
|
this._markersGroup = this._createMarkers();
|
|
18198
18084
|
this._group = new Konva.Group({
|
|
@@ -18206,8 +18092,8 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Loader, Konva)
|
|
|
18206
18092
|
self.drawSourceShape(ctx, null);
|
|
18207
18093
|
}
|
|
18208
18094
|
});
|
|
18209
|
-
this._group.on('dragstart', this.
|
|
18210
|
-
this._group.on('dragend', this.
|
|
18095
|
+
this._group.on('dragstart', this._onDragStart.bind(this));
|
|
18096
|
+
this._group.on('dragend', this._onDragEnd.bind(this));
|
|
18211
18097
|
this._cursor = null;
|
|
18212
18098
|
this._group.on('mouseenter', function () {
|
|
18213
18099
|
self._view.setHoveredElement(self);
|
|
@@ -18253,6 +18139,17 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Loader, Konva)
|
|
|
18253
18139
|
this.createIndicators();
|
|
18254
18140
|
this.setLoadingState(this._source.loading);
|
|
18255
18141
|
}
|
|
18142
|
+
SourceGroup.prototype._onDragStart = function (element) {
|
|
18143
|
+
this._isDragged = true;
|
|
18144
|
+
this._layer.onSourcesGroupDragStart(element);
|
|
18145
|
+
};
|
|
18146
|
+
SourceGroup.prototype._onDragEnd = function (element) {
|
|
18147
|
+
this._isDragged = false;
|
|
18148
|
+
this._layer.onSourcesGroupDragEnd(element);
|
|
18149
|
+
};
|
|
18150
|
+
SourceGroup.prototype.isActive = function () {
|
|
18151
|
+
return this._isDragged;
|
|
18152
|
+
};
|
|
18256
18153
|
SourceGroup.prototype.addToContent = function (newChild) {
|
|
18257
18154
|
if (this._source.wrapped) {
|
|
18258
18155
|
this._wrap.add(newChild);
|
|
@@ -18285,9 +18182,11 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Loader, Konva)
|
|
|
18285
18182
|
const newTimeToPixelsScale = this._view.getTimeToPixelsScale();
|
|
18286
18183
|
this._group.x(startPixel - frameOffset);
|
|
18287
18184
|
this._x = startPixel;
|
|
18185
|
+
this._roundedX = Math.round(this._x);
|
|
18288
18186
|
const newWidth = endPixel - startPixel;
|
|
18289
18187
|
if (newWidth !== this._width) {
|
|
18290
18188
|
this._width = newWidth;
|
|
18189
|
+
this._roundedWidth = Math.round(this._width);
|
|
18291
18190
|
if (newTimeToPixelsScale !== this._currentTimeToPixelsScaleUsed) {
|
|
18292
18191
|
this._currentTimeToPixelsScaleUsed = newTimeToPixelsScale;
|
|
18293
18192
|
this._updateMarkers();
|
|
@@ -18418,9 +18317,9 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Loader, Konva)
|
|
|
18418
18317
|
};
|
|
18419
18318
|
SourceGroup.prototype.drawSourceShape = function (ctx, shape, addBorderWidth, fill) {
|
|
18420
18319
|
var offset = addBorderWidth ? this._borderWidth : 0;
|
|
18421
|
-
var radius = this._source.borderRadius !== undefined && this._source.borderRadius !== null ? this._source.borderRadius : Math.max(1, Math.min(this.
|
|
18422
|
-
var x = Math.max(0, this._view.getFrameOffset() - this.
|
|
18423
|
-
var width = Math.min(this.
|
|
18320
|
+
var radius = this._source.borderRadius !== undefined && this._source.borderRadius !== null ? this._source.borderRadius : Math.max(1, Math.min(this._roundedWidth / 2, Math.min(CORNER_RADIUS, this._height / 2)));
|
|
18321
|
+
var x = Math.max(0, this._view.getFrameOffset() - this._roundedX - radius);
|
|
18322
|
+
var width = Math.min(this._roundedWidth - x, this._view.getWidth() + radius - Math.max(0, this._roundedX - this._view.getFrameOffset()));
|
|
18424
18323
|
var xWidth = x + width;
|
|
18425
18324
|
ctx.beginPath();
|
|
18426
18325
|
ctx.moveTo(x + radius, offset);
|
|
@@ -18435,14 +18334,14 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Loader, Konva)
|
|
|
18435
18334
|
ctx.closePath();
|
|
18436
18335
|
if (fill) {
|
|
18437
18336
|
if (this._source.shouldShowWarning()) {
|
|
18438
|
-
var gradient = ctx.createLinearGradient(0, 0, this.
|
|
18337
|
+
var gradient = ctx.createLinearGradient(0, 0, this._roundedWidth, 0);
|
|
18439
18338
|
if (this._source.mediaEndTime < this._source.duration) {
|
|
18440
|
-
var rightStopPosition = Math.max(1 - this._source.warningWidth / this.
|
|
18339
|
+
var rightStopPosition = Math.max(1 - this._source.warningWidth / this._roundedWidth, 0.5);
|
|
18441
18340
|
gradient.addColorStop(rightStopPosition, this._source.backgroundColor);
|
|
18442
18341
|
gradient.addColorStop(1, this._source.warningColor);
|
|
18443
18342
|
}
|
|
18444
18343
|
if (this._source.mediaStartTime > 0) {
|
|
18445
|
-
var leftStopPosition = Math.min(this._source.warningWidth / this.
|
|
18344
|
+
var leftStopPosition = Math.min(this._source.warningWidth / this._roundedWidth, 0.5);
|
|
18446
18345
|
gradient.addColorStop(0, this._source.warningColor);
|
|
18447
18346
|
gradient.addColorStop(leftStopPosition, this._source.backgroundColor);
|
|
18448
18347
|
}
|
|
@@ -20595,8 +20494,7 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
20595
20494
|
SourcesLayer.prototype.updateSource = function (source, newStartX, newEndX, newY) {
|
|
20596
20495
|
var newXs = {
|
|
20597
20496
|
startX: newStartX,
|
|
20598
|
-
endX: newEndX
|
|
20599
|
-
updateWidth: false
|
|
20497
|
+
endX: newEndX
|
|
20600
20498
|
};
|
|
20601
20499
|
if (this._peaks.options.canMoveSourcesBetweenLines) {
|
|
20602
20500
|
this.manageVerticalPosition(source, newY);
|
|
@@ -20605,7 +20503,7 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
20605
20503
|
newXs = this.manageCollision(source, newXs.startX, newXs.endX);
|
|
20606
20504
|
source.updateTimes(newXs.startX !== null ? this._view.pixelsToTime(newXs.startX) : null, newXs.endX !== null ? this._view.pixelsToTime(newXs.endX) : null);
|
|
20607
20505
|
if (newXs) {
|
|
20608
|
-
this._updateSource(source
|
|
20506
|
+
this._updateSource(source);
|
|
20609
20507
|
return true;
|
|
20610
20508
|
}
|
|
20611
20509
|
return false;
|
|
@@ -20634,10 +20532,13 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
20634
20532
|
var count = 0;
|
|
20635
20533
|
for (var sourceId in this._sourcesGroup) {
|
|
20636
20534
|
if (Utils.objectHasProperty(this._sourcesGroup, sourceId)) {
|
|
20637
|
-
var
|
|
20638
|
-
if (!
|
|
20639
|
-
this.
|
|
20640
|
-
|
|
20535
|
+
var sourceGroup = this._sourcesGroup[sourceId];
|
|
20536
|
+
if (!sourceGroup.isActive()) {
|
|
20537
|
+
var source = this._sourcesGroup[sourceId].getSource();
|
|
20538
|
+
if (!this._isSourceVisible(source, startTime, endTime)) {
|
|
20539
|
+
this._removeSource(source);
|
|
20540
|
+
count++;
|
|
20541
|
+
}
|
|
20641
20542
|
}
|
|
20642
20543
|
}
|
|
20643
20544
|
}
|
|
@@ -21754,7 +21655,7 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
|
|
|
21754
21655
|
this.updateTimeline(this.timeToPixels(time));
|
|
21755
21656
|
};
|
|
21756
21657
|
TimelineZoomView.prototype.timeToPixels = function (time) {
|
|
21757
|
-
return
|
|
21658
|
+
return Utils.roundTime(time) * this._timeToPixelsScale;
|
|
21758
21659
|
};
|
|
21759
21660
|
TimelineZoomView.prototype.pixelsToTime = function (pixels) {
|
|
21760
21661
|
return Utils.roundTime(pixels / this._timeToPixelsScale);
|
package/src/line-indicator.js
CHANGED
|
@@ -70,10 +70,6 @@ define([
|
|
|
70
70
|
|
|
71
71
|
this._layer.draw();
|
|
72
72
|
|
|
73
|
-
if (this._peaks.options.enableLineIndicatorContextMenu) {
|
|
74
|
-
this._createContextMenu();
|
|
75
|
-
}
|
|
76
|
-
|
|
77
73
|
this._peaks.on('lineIndicator.setType', this._onSetType.bind(this));
|
|
78
74
|
this._peaks.on('lineIndicator.setText', this._onSetText.bind(this));
|
|
79
75
|
}
|
|
@@ -268,9 +264,8 @@ define([
|
|
|
268
264
|
var y = this._indicators[lineId].line.getY();
|
|
269
265
|
var isVisible = y + this._indicators[lineId].line.lineHeight() + this._yPadding > 0
|
|
270
266
|
&& y - this._yPadding < this._height;
|
|
271
|
-
var isLineNotEmpty = !this._indicators[lineId].line.isEmpty();
|
|
272
267
|
|
|
273
|
-
if (
|
|
268
|
+
if (isVisible) {
|
|
274
269
|
if (!this._indicators[lineId].indicator) {
|
|
275
270
|
this._indicators[lineId].indicator = this._createIndicator(
|
|
276
271
|
this._indicators[lineId].line,
|
|
@@ -304,157 +299,5 @@ define([
|
|
|
304
299
|
this._layer.draw();
|
|
305
300
|
};
|
|
306
301
|
|
|
307
|
-
LineIndicator.prototype._createContextMenu = function() {
|
|
308
|
-
var menu = document.createElement('div');
|
|
309
|
-
var addLine = document.createElement('button');
|
|
310
|
-
var addLineAbove = document.createElement('button');
|
|
311
|
-
var addLineBelow = document.createElement('button');
|
|
312
|
-
var deleteLine = document.createElement('button');
|
|
313
|
-
var currentIndicator = null;
|
|
314
|
-
var self = this;
|
|
315
|
-
|
|
316
|
-
menu.style.display = 'none';
|
|
317
|
-
menu.style.position = 'absolute';
|
|
318
|
-
menu.style.backgroundColor = 'white';
|
|
319
|
-
menu.style.boxShadow = '0 0 5px grey';
|
|
320
|
-
menu.style.borderRadius = '3px';
|
|
321
|
-
menu.style.zIndex = 2;
|
|
322
|
-
|
|
323
|
-
addLine.style.display = 'none';
|
|
324
|
-
addLine.style.border = 'none';
|
|
325
|
-
addLine.style.margin = '0';
|
|
326
|
-
addLine.style.width = '100%';
|
|
327
|
-
addLine.style.backgroundColor = 'white';
|
|
328
|
-
addLine.style.padding = '10px';
|
|
329
|
-
|
|
330
|
-
addLine.textContent = 'Add first line';
|
|
331
|
-
|
|
332
|
-
addLine.onmouseover = function() {
|
|
333
|
-
this.style.backgroundColor = 'lightgray';
|
|
334
|
-
};
|
|
335
|
-
|
|
336
|
-
addLine.onmouseout = function() {
|
|
337
|
-
this.style.backgroundColor = 'white';
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
addLineAbove.style.display = 'none';
|
|
341
|
-
addLineAbove.style.border = 'none';
|
|
342
|
-
addLineAbove.style.margin = '0';
|
|
343
|
-
addLineAbove.style.width = '100%';
|
|
344
|
-
addLineAbove.style.backgroundColor = 'white';
|
|
345
|
-
addLineAbove.style.padding = '10px';
|
|
346
|
-
|
|
347
|
-
addLineAbove.textContent = 'Add line above';
|
|
348
|
-
|
|
349
|
-
addLineAbove.onmouseover = function() {
|
|
350
|
-
this.style.backgroundColor = 'lightgray';
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
addLineAbove.onmouseout = function() {
|
|
354
|
-
this.style.backgroundColor = 'white';
|
|
355
|
-
};
|
|
356
|
-
|
|
357
|
-
addLineBelow.style.display = 'none';
|
|
358
|
-
addLineBelow.style.border = 'none';
|
|
359
|
-
addLineBelow.style.margin = '0';
|
|
360
|
-
addLineBelow.style.width = '100%';
|
|
361
|
-
addLineBelow.style.backgroundColor = 'white';
|
|
362
|
-
addLineBelow.style.padding = '10px';
|
|
363
|
-
|
|
364
|
-
addLineBelow.textContent = 'Add line below';
|
|
365
|
-
|
|
366
|
-
addLineBelow.onmouseover = function() {
|
|
367
|
-
this.style.backgroundColor = 'lightgray';
|
|
368
|
-
};
|
|
369
|
-
|
|
370
|
-
addLineBelow.onmouseout = function() {
|
|
371
|
-
this.style.backgroundColor = 'white';
|
|
372
|
-
};
|
|
373
|
-
|
|
374
|
-
deleteLine.style.display = 'none';
|
|
375
|
-
deleteLine.style.border = 'none';
|
|
376
|
-
deleteLine.style.margin = '0';
|
|
377
|
-
deleteLine.style.width = '100%';
|
|
378
|
-
deleteLine.style.backgroundColor = 'white';
|
|
379
|
-
deleteLine.style.padding = '10px';
|
|
380
|
-
|
|
381
|
-
deleteLine.textContent = 'Delete line';
|
|
382
|
-
|
|
383
|
-
deleteLine.onmouseover = function() {
|
|
384
|
-
this.style.backgroundColor = 'lightgray';
|
|
385
|
-
};
|
|
386
|
-
|
|
387
|
-
deleteLine.onmouseout = function() {
|
|
388
|
-
this.style.backgroundColor = 'white';
|
|
389
|
-
};
|
|
390
|
-
|
|
391
|
-
menu.appendChild(addLine);
|
|
392
|
-
menu.appendChild(addLineAbove);
|
|
393
|
-
menu.appendChild(addLineBelow);
|
|
394
|
-
menu.appendChild(deleteLine);
|
|
395
|
-
this._container.appendChild(menu);
|
|
396
|
-
|
|
397
|
-
addLine.addEventListener('click', function() {
|
|
398
|
-
self._peaks.emit('line.add', 0);
|
|
399
|
-
self.draw();
|
|
400
|
-
});
|
|
401
|
-
|
|
402
|
-
addLineAbove.addEventListener('click', function() {
|
|
403
|
-
var line = self._indicators[currentIndicator.getAttr('lineId')].line;
|
|
404
|
-
|
|
405
|
-
self._peaks.emit('line.add', Number(line.getPosition()));
|
|
406
|
-
self.draw();
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
addLineBelow.addEventListener('click', function() {
|
|
410
|
-
var line = self._indicators[currentIndicator.getAttr('lineId')].line;
|
|
411
|
-
|
|
412
|
-
self._peaks.emit('line.add', Number(line.getPosition()) + 1);
|
|
413
|
-
self.draw();
|
|
414
|
-
});
|
|
415
|
-
|
|
416
|
-
deleteLine.addEventListener('click', function() {
|
|
417
|
-
var line = self._indicators[currentIndicator.getAttr('lineId')].line;
|
|
418
|
-
|
|
419
|
-
self._peaks.emit('line.remove', Number(line.getPosition()));
|
|
420
|
-
self.draw();
|
|
421
|
-
});
|
|
422
|
-
|
|
423
|
-
window.addEventListener('click', function() {
|
|
424
|
-
// hide menu
|
|
425
|
-
menu.style.display = 'none';
|
|
426
|
-
});
|
|
427
|
-
|
|
428
|
-
this._stage.on('contextmenu', function(e) {
|
|
429
|
-
// prevent default behavior
|
|
430
|
-
e.evt.preventDefault();
|
|
431
|
-
|
|
432
|
-
if (e.target === self._stage && Object.keys(self._indicators).length === 0) {
|
|
433
|
-
// if we are on empty place of the stage
|
|
434
|
-
// we will show the possibility to add a first line
|
|
435
|
-
addLine.style.display = 'block';
|
|
436
|
-
addLineAbove.style.display = 'none';
|
|
437
|
-
addLineBelow.style.display = 'none';
|
|
438
|
-
deleteLine.style.display = 'none';
|
|
439
|
-
|
|
440
|
-
// show menu
|
|
441
|
-
self._showMenu(menu);
|
|
442
|
-
}
|
|
443
|
-
else if (e.target !== self._stage) {
|
|
444
|
-
currentIndicator = e.target;
|
|
445
|
-
|
|
446
|
-
addLine.style.display = 'none';
|
|
447
|
-
addLineAbove.style.display = 'block';
|
|
448
|
-
addLineBelow.style.display = 'block';
|
|
449
|
-
deleteLine.style.display = 'block';
|
|
450
|
-
|
|
451
|
-
deleteLine.disabled = !self._indicators[currentIndicator.getAttr('lineId')].line.isEmpty();
|
|
452
|
-
|
|
453
|
-
// show menu
|
|
454
|
-
self._showMenu(menu);
|
|
455
|
-
}
|
|
456
|
-
});
|
|
457
|
-
};
|
|
458
|
-
|
|
459
302
|
return LineIndicator;
|
|
460
303
|
});
|
package/src/line.js
CHANGED
|
@@ -535,22 +535,23 @@ define([
|
|
|
535
535
|
};
|
|
536
536
|
|
|
537
537
|
Line.prototype.manageCollision = function(source, newStartX, newEndX) {
|
|
538
|
+
var originalStartTime = null;
|
|
539
|
+
var originalEndTime = null;
|
|
538
540
|
var newStartTime = null;
|
|
539
541
|
var newEndTime = null;
|
|
540
542
|
var startLimited = false;
|
|
541
543
|
var endLimited = false;
|
|
542
|
-
var timeWidth = this._view.pixelsToTime(newEndX - newStartX);
|
|
543
544
|
|
|
544
545
|
var newXs = {
|
|
545
546
|
startX: newStartX,
|
|
546
547
|
endX: newEndX,
|
|
547
|
-
updateWidth: false,
|
|
548
548
|
updateTimelineLength: false
|
|
549
549
|
};
|
|
550
550
|
|
|
551
551
|
if (newStartX !== null) {
|
|
552
552
|
// startMarker changed
|
|
553
|
-
|
|
553
|
+
originalStartTime = this._view.pixelsToTime(newStartX);
|
|
554
|
+
newStartTime = originalStartTime;
|
|
554
555
|
|
|
555
556
|
if (source.startTime > newStartTime) {
|
|
556
557
|
// startMarker moved to the left
|
|
@@ -576,7 +577,8 @@ define([
|
|
|
576
577
|
|
|
577
578
|
if (newEndX !== null) {
|
|
578
579
|
// endMarker changed
|
|
579
|
-
|
|
580
|
+
originalEndTime = this._view.pixelsToTime(newEndX);
|
|
581
|
+
newEndTime = originalEndTime;
|
|
580
582
|
|
|
581
583
|
if (source.endTime < newEndTime) {
|
|
582
584
|
// endMarker moved to the right
|
|
@@ -596,6 +598,8 @@ define([
|
|
|
596
598
|
|
|
597
599
|
// Update the other edge if dragging and collision
|
|
598
600
|
if (newStartTime !== null && newEndTime !== null) {
|
|
601
|
+
var timeWidth = Utils.roundTime(originalEndTime - originalStartTime);
|
|
602
|
+
|
|
599
603
|
if (startLimited) {
|
|
600
604
|
newEndTime = newStartTime + timeWidth;
|
|
601
605
|
}
|
|
@@ -627,11 +631,11 @@ define([
|
|
|
627
631
|
}
|
|
628
632
|
}
|
|
629
633
|
|
|
630
|
-
if (newStartTime !== null) {
|
|
634
|
+
if (newStartTime !== null && newStartTime !== originalStartTime) {
|
|
631
635
|
newXs.startX = this._view.timeToPixels(newStartTime);
|
|
632
636
|
}
|
|
633
637
|
|
|
634
|
-
if (newEndTime !== null) {
|
|
638
|
+
if (newEndTime !== null && newEndTime !== originalEndTime) {
|
|
635
639
|
newXs.endX = this._view.timeToPixels(newEndTime);
|
|
636
640
|
|
|
637
641
|
if (this._sources[source.id].nextSourceId === null) {
|
|
@@ -639,11 +643,6 @@ define([
|
|
|
639
643
|
}
|
|
640
644
|
}
|
|
641
645
|
|
|
642
|
-
if ((newXs.startX !== null && newXs.endX === null)
|
|
643
|
-
|| (newXs.startX === null && newXs.endX !== null)) {
|
|
644
|
-
newXs.updateWidth = true;
|
|
645
|
-
}
|
|
646
|
-
|
|
647
646
|
return newXs;
|
|
648
647
|
};
|
|
649
648
|
|
package/src/main.js
CHANGED
|
@@ -395,12 +395,6 @@ define([
|
|
|
395
395
|
*/
|
|
396
396
|
autoScrollThreshold: 0.05,
|
|
397
397
|
|
|
398
|
-
/**
|
|
399
|
-
* Indicates whether or not the context menu should be displayed
|
|
400
|
-
* on right click in the line indicator.
|
|
401
|
-
*/
|
|
402
|
-
enableLineIndicatorContextMenu: true,
|
|
403
|
-
|
|
404
398
|
/**
|
|
405
399
|
* The minimal size of a source, in seconds
|
|
406
400
|
*/
|
package/src/source-group.js
CHANGED
|
@@ -47,7 +47,9 @@ define([
|
|
|
47
47
|
var self = this;
|
|
48
48
|
|
|
49
49
|
this._x = this._view.timeToPixels(source.startTime);
|
|
50
|
+
this._roundedX = Math.round(this._x);
|
|
50
51
|
this._width = this._view.timeToPixels(source.endTime - source.startTime);
|
|
52
|
+
this._roundedWidth = Math.round(this._width);
|
|
51
53
|
this._unwrappedHeight = source.binaryHeight && source.previewHeight ?
|
|
52
54
|
source.binaryHeight + source.previewHeight :
|
|
53
55
|
this._peaks.options.lineHeight;
|
|
@@ -56,6 +58,7 @@ define([
|
|
|
56
58
|
this._height = this._unwrappedHeight;
|
|
57
59
|
this._currentTimeToPixelsScaleUsed = this._view.getTimeToPixelsScale();
|
|
58
60
|
this._selected = this._source.selected;
|
|
61
|
+
this._isDragged = false;
|
|
59
62
|
|
|
60
63
|
this._previewList = [];
|
|
61
64
|
|
|
@@ -73,8 +76,8 @@ define([
|
|
|
73
76
|
}
|
|
74
77
|
});
|
|
75
78
|
|
|
76
|
-
this._group.on('dragstart', this.
|
|
77
|
-
this._group.on('dragend', this.
|
|
79
|
+
this._group.on('dragstart', this._onDragStart.bind(this));
|
|
80
|
+
this._group.on('dragend', this._onDragEnd.bind(this));
|
|
78
81
|
|
|
79
82
|
this._cursor = null;
|
|
80
83
|
this._group.on('mouseenter', function() {
|
|
@@ -132,6 +135,20 @@ define([
|
|
|
132
135
|
this.setLoadingState(this._source.loading);
|
|
133
136
|
}
|
|
134
137
|
|
|
138
|
+
SourceGroup.prototype._onDragStart = function(element) {
|
|
139
|
+
this._isDragged = true;
|
|
140
|
+
this._layer.onSourcesGroupDragStart(element);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
SourceGroup.prototype._onDragEnd = function(element) {
|
|
144
|
+
this._isDragged = false;
|
|
145
|
+
this._layer.onSourcesGroupDragEnd(element);
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
SourceGroup.prototype.isActive = function() {
|
|
149
|
+
return this._isDragged;
|
|
150
|
+
};
|
|
151
|
+
|
|
135
152
|
SourceGroup.prototype.addToContent = function(newChild) {
|
|
136
153
|
if (this._source.wrapped) {
|
|
137
154
|
this._wrap.add(newChild);
|
|
@@ -181,11 +198,13 @@ define([
|
|
|
181
198
|
this._group.x(startPixel - frameOffset);
|
|
182
199
|
|
|
183
200
|
this._x = startPixel;
|
|
201
|
+
this._roundedX = Math.round(this._x);
|
|
184
202
|
|
|
185
203
|
const newWidth = endPixel - startPixel;
|
|
186
204
|
|
|
187
205
|
if (newWidth !== this._width) {
|
|
188
206
|
this._width = newWidth;
|
|
207
|
+
this._roundedWidth = Math.round(this._width);
|
|
189
208
|
|
|
190
209
|
// the zoom was changed
|
|
191
210
|
if (newTimeToPixelsScale !== this._currentTimeToPixelsScaleUsed) {
|
|
@@ -355,7 +374,7 @@ define([
|
|
|
355
374
|
Math.max(
|
|
356
375
|
1,
|
|
357
376
|
Math.min(
|
|
358
|
-
this.
|
|
377
|
+
this._roundedWidth / 2,
|
|
359
378
|
Math.min(
|
|
360
379
|
CORNER_RADIUS,
|
|
361
380
|
this._height / 2
|
|
@@ -364,13 +383,13 @@ define([
|
|
|
364
383
|
);
|
|
365
384
|
var x = Math.max(
|
|
366
385
|
0,
|
|
367
|
-
this._view.getFrameOffset() - this.
|
|
386
|
+
this._view.getFrameOffset() - this._roundedX - radius
|
|
368
387
|
);
|
|
369
388
|
var width = Math.min(
|
|
370
|
-
this.
|
|
389
|
+
this._roundedWidth - x,
|
|
371
390
|
this._view.getWidth() + radius - Math.max(
|
|
372
391
|
0,
|
|
373
|
-
this.
|
|
392
|
+
this._roundedX - this._view.getFrameOffset()
|
|
374
393
|
)
|
|
375
394
|
);
|
|
376
395
|
var xWidth = x + width;
|
|
@@ -394,17 +413,17 @@ define([
|
|
|
394
413
|
|
|
395
414
|
if (fill) {
|
|
396
415
|
if (this._source.shouldShowWarning()) {
|
|
397
|
-
var gradient = ctx.createLinearGradient(0, 0, this.
|
|
416
|
+
var gradient = ctx.createLinearGradient(0, 0, this._roundedWidth, 0);
|
|
398
417
|
|
|
399
418
|
if (this._source.mediaEndTime < this._source.duration) {
|
|
400
|
-
var rightStopPosition = Math.max(1 - (this._source.warningWidth / this.
|
|
419
|
+
var rightStopPosition = Math.max(1 - (this._source.warningWidth / this._roundedWidth), 0.5);
|
|
401
420
|
|
|
402
421
|
gradient.addColorStop(rightStopPosition, this._source.backgroundColor);
|
|
403
422
|
gradient.addColorStop(1, this._source.warningColor);
|
|
404
423
|
}
|
|
405
424
|
|
|
406
425
|
if (this._source.mediaStartTime > 0) {
|
|
407
|
-
var leftStopPosition = Math.min(this._source.warningWidth / this.
|
|
426
|
+
var leftStopPosition = Math.min(this._source.warningWidth / this._roundedWidth, 0.5);
|
|
408
427
|
|
|
409
428
|
gradient.addColorStop(0, this._source.warningColor);
|
|
410
429
|
gradient.addColorStop(leftStopPosition, this._source.backgroundColor);
|
package/src/sources-layer.js
CHANGED
|
@@ -438,8 +438,7 @@ define([
|
|
|
438
438
|
SourcesLayer.prototype.updateSource = function(source, newStartX, newEndX, newY) {
|
|
439
439
|
var newXs = {
|
|
440
440
|
startX: newStartX,
|
|
441
|
-
endX: newEndX
|
|
442
|
-
updateWidth: false
|
|
441
|
+
endX: newEndX
|
|
443
442
|
};
|
|
444
443
|
|
|
445
444
|
if (this._peaks.options.canMoveSourcesBetweenLines) {
|
|
@@ -457,8 +456,7 @@ define([
|
|
|
457
456
|
|
|
458
457
|
if (newXs) {
|
|
459
458
|
this._updateSource(
|
|
460
|
-
source
|
|
461
|
-
newXs.updateWidth
|
|
459
|
+
source
|
|
462
460
|
);
|
|
463
461
|
|
|
464
462
|
return true;
|
|
@@ -513,11 +511,15 @@ define([
|
|
|
513
511
|
|
|
514
512
|
for (var sourceId in this._sourcesGroup) {
|
|
515
513
|
if (Utils.objectHasProperty(this._sourcesGroup, sourceId)) {
|
|
516
|
-
var
|
|
514
|
+
var sourceGroup = this._sourcesGroup[sourceId];
|
|
517
515
|
|
|
518
|
-
if (!
|
|
519
|
-
this.
|
|
520
|
-
|
|
516
|
+
if (!sourceGroup.isActive()) {
|
|
517
|
+
var source = this._sourcesGroup[sourceId].getSource();
|
|
518
|
+
|
|
519
|
+
if (!this._isSourceVisible(source, startTime, endTime)) {
|
|
520
|
+
this._removeSource(source);
|
|
521
|
+
count++;
|
|
522
|
+
}
|
|
521
523
|
}
|
|
522
524
|
}
|
|
523
525
|
}
|
package/src/timeline-zoomview.js
CHANGED