@checksub_team/peaks_timeline 1.16.0-alpha.1 → 1.16.0-alpha.2
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 +70 -132
- package/src/line-indicator.js +0 -10
- package/src/line.js +23 -55
- package/src/lines.js +2 -19
- package/src/main.js +0 -7
- package/src/source-group.js +47 -51
- package/src/sources-layer.js +14 -35
package/package.json
CHANGED
package/peaks.js
CHANGED
|
@@ -14809,12 +14809,6 @@ module.exports = function (Konva, Utils, SVGs) {
|
|
|
14809
14809
|
this._indicators[lineId].text = text;
|
|
14810
14810
|
this.draw();
|
|
14811
14811
|
};
|
|
14812
|
-
LineIndicator.prototype._showMenu = function (menu) {
|
|
14813
|
-
menu.style.display = 'block';
|
|
14814
|
-
var containerRect = this._stage.container().getBoundingClientRect();
|
|
14815
|
-
menu.style.top = containerRect.top + this._stage.getPointerPosition().y - menu.offsetHeight + 'px';
|
|
14816
|
-
menu.style.left = containerRect.left + this._stage.getPointerPosition().x + 6 + 'px';
|
|
14817
|
-
};
|
|
14818
14812
|
LineIndicator.prototype._createIndicator = function (line, type, text) {
|
|
14819
14813
|
var indicator = new Konva.Group();
|
|
14820
14814
|
var indicatorHeight = 0;
|
|
@@ -14982,9 +14976,6 @@ module.exports = function (SourceGroup, Konva, Utils) {
|
|
|
14982
14976
|
Line.prototype.getId = function () {
|
|
14983
14977
|
return this._id;
|
|
14984
14978
|
};
|
|
14985
|
-
Line.prototype.isEmpty = function () {
|
|
14986
|
-
return this.isSegmentsLine() ? this._segmentsGroup.isEmpty() : Object.keys(this._sources).length === 0;
|
|
14987
|
-
};
|
|
14988
14979
|
Line.prototype.countRemainingElements = function () {
|
|
14989
14980
|
return this.isSegmentsLine() ? this._segmentsGroup.countRemainingElements() : Object.keys(this._sources).length;
|
|
14990
14981
|
};
|
|
@@ -15014,35 +15005,6 @@ module.exports = function (SourceGroup, Konva, Utils) {
|
|
|
15014
15005
|
Line.prototype.lineHeight = function () {
|
|
15015
15006
|
return this._height;
|
|
15016
15007
|
};
|
|
15017
|
-
Line.prototype.changeHeight = function (from, to) {
|
|
15018
|
-
if (this._sourceHeights[from]) {
|
|
15019
|
-
var oldHeight = this._height;
|
|
15020
|
-
if (this._sourceHeights[to]) {
|
|
15021
|
-
this._sourceHeights[to] += this._sourceHeights[from];
|
|
15022
|
-
} else {
|
|
15023
|
-
this._sourceHeights[to] = this._sourceHeights[from];
|
|
15024
|
-
}
|
|
15025
|
-
if (to > this._height) {
|
|
15026
|
-
this._height = to;
|
|
15027
|
-
} else if (from === this._height) {
|
|
15028
|
-
this._height = 0;
|
|
15029
|
-
for (var height in this._sourceHeights) {
|
|
15030
|
-
if (Utils.objectHasProperty(this._sourceHeights, height)) {
|
|
15031
|
-
var parsedHeight = parseInt(height, 10);
|
|
15032
|
-
if (parsedHeight !== from) {
|
|
15033
|
-
if (parsedHeight > this._height) {
|
|
15034
|
-
this._height = parsedHeight;
|
|
15035
|
-
}
|
|
15036
|
-
}
|
|
15037
|
-
}
|
|
15038
|
-
}
|
|
15039
|
-
}
|
|
15040
|
-
if (this._height !== oldHeight) {
|
|
15041
|
-
this._peaks.emit('line.heightChanged', this._position);
|
|
15042
|
-
}
|
|
15043
|
-
delete this._sourceHeights[from];
|
|
15044
|
-
}
|
|
15045
|
-
};
|
|
15046
15008
|
Line.prototype._addHeight = function (height) {
|
|
15047
15009
|
if (this._sourceHeights[height]) {
|
|
15048
15010
|
this._sourceHeights[height]++;
|
|
@@ -15240,18 +15202,27 @@ module.exports = function (SourceGroup, Konva, Utils) {
|
|
|
15240
15202
|
const cursorTime = this._view.pixelsToTime(this._view.getPointerPosition().x);
|
|
15241
15203
|
var newStartTime = startTime;
|
|
15242
15204
|
var newEndTime = endTime;
|
|
15243
|
-
var
|
|
15244
|
-
|
|
15205
|
+
var tmpTimes;
|
|
15206
|
+
var sourceDuration = Utils.roundTime(endTime - startTime);
|
|
15207
|
+
if (typeof newStartTime === 'number' && typeof newEndTime === 'number') {
|
|
15245
15208
|
if (this._sources[firstSource.id].prevSourceId) {
|
|
15246
15209
|
var previousStartTime = this._sources[this._sources[firstSource.id].prevSourceId].source.startTime;
|
|
15247
|
-
if (cursorTime + this._view.getTimeOffset() < previousStartTime) {
|
|
15248
|
-
|
|
15210
|
+
if (Utils.roundTime(cursorTime + this._view.getTimeOffset()) < previousStartTime) {
|
|
15211
|
+
tmpTimes = this._changeSourcesPosition(sources, sourceDuration, cursorTime + this._view.getTimeOffset());
|
|
15212
|
+
if (typeof tmpTimes.newStartTime === 'number' && typeof tmpTimes.newEndTime === 'number') {
|
|
15213
|
+
newStartTime = tmpTimes.newStartTime;
|
|
15214
|
+
newEndTime = tmpTimes.newEndTime;
|
|
15215
|
+
}
|
|
15249
15216
|
}
|
|
15250
15217
|
}
|
|
15251
15218
|
if (this._sources[lastSource.id].nextSourceId) {
|
|
15252
15219
|
var nextEndTime = this._sources[this._sources[lastSource.id].nextSourceId].source.endTime;
|
|
15253
|
-
if (cursorTime + this._view.getTimeOffset() > nextEndTime) {
|
|
15254
|
-
|
|
15220
|
+
if (Utils.roundTime(cursorTime + this._view.getTimeOffset()) > nextEndTime) {
|
|
15221
|
+
tmpTimes = this._changeSourcesPosition(sources, sourceDuration, cursorTime + this._view.getTimeOffset());
|
|
15222
|
+
if (typeof tmpTimes.newStartTime === 'number' && typeof tmpTimes.newEndTime === 'number') {
|
|
15223
|
+
newStartTime = tmpTimes.newStartTime;
|
|
15224
|
+
newEndTime = tmpTimes.newEndTime;
|
|
15225
|
+
}
|
|
15255
15226
|
}
|
|
15256
15227
|
}
|
|
15257
15228
|
}
|
|
@@ -15287,7 +15258,7 @@ module.exports = function (SourceGroup, Konva, Utils) {
|
|
|
15287
15258
|
}
|
|
15288
15259
|
if (time > startLimit && (endLimit === null || time < endLimit)) {
|
|
15289
15260
|
({newStartTime, newEndTime} = this._canBePlacedBetween(time, time + sourceDuration, startLimit, endLimit));
|
|
15290
|
-
if (newStartTime
|
|
15261
|
+
if (typeof newStartTime === 'number' && typeof newEndTime === 'number') {
|
|
15291
15262
|
let prevSourceId = currentRange.start ? currentRange.start.source.id : null;
|
|
15292
15263
|
sources.forEach(function (source) {
|
|
15293
15264
|
this._moveSource(this._sources[source.id].source, prevSourceId);
|
|
@@ -15365,7 +15336,7 @@ module.exports = function (SourceGroup, Konva, Utils) {
|
|
|
15365
15336
|
}
|
|
15366
15337
|
}
|
|
15367
15338
|
}
|
|
15368
|
-
if (newStartTime
|
|
15339
|
+
if (typeof newStartTime === 'number' && typeof newEndTime === 'number') {
|
|
15369
15340
|
var timeWidth = originalEndTime - originalStartTime;
|
|
15370
15341
|
if (startLimited) {
|
|
15371
15342
|
newEndTime = Utils.roundTime(newStartTime + timeWidth);
|
|
@@ -15374,11 +15345,11 @@ module.exports = function (SourceGroup, Konva, Utils) {
|
|
|
15374
15345
|
newStartTime = Utils.roundTime(newEndTime - timeWidth);
|
|
15375
15346
|
}
|
|
15376
15347
|
}
|
|
15377
|
-
if (newStartTime
|
|
15348
|
+
if (typeof newStartTime === 'number' && typeof newEndTime !== 'number') {
|
|
15378
15349
|
if (Utils.roundTime(sources[0].endTime - newStartTime) < sources[0].minSize) {
|
|
15379
15350
|
newStartTime = Utils.roundTime(sources[0].endTime - sources[0].minSize);
|
|
15380
15351
|
}
|
|
15381
|
-
} else if (newEndTime
|
|
15352
|
+
} else if (typeof newEndTime === 'number' && typeof newStartTime !== 'number') {
|
|
15382
15353
|
if (Utils.roundTime(newEndTime - sources[0].startTime) < sources[0].minSize) {
|
|
15383
15354
|
newEndTime = Utils.roundTime(sources[0].startTime + sources[0].minSize);
|
|
15384
15355
|
}
|
|
@@ -15480,7 +15451,6 @@ module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
|
|
|
15480
15451
|
this._lineId = 0;
|
|
15481
15452
|
this._lineIndicator = new LineIndicator(peaks, view, document.getElementById('line-indicator-container'));
|
|
15482
15453
|
this._peaks.on('line.heightChanged', this._onLineHeightChanged.bind(this));
|
|
15483
|
-
this._peaks.on('line.add', this._onLineAdd.bind(this));
|
|
15484
15454
|
this._peaks.on('line.remove', this._onLineRemove.bind(this));
|
|
15485
15455
|
this._peaks.on('sources.show', this._onSourcesWrappingChanged.bind(this));
|
|
15486
15456
|
this._peaks.on('sources.hide', this._onSourcesWrappingChanged.bind(this));
|
|
@@ -15527,13 +15497,8 @@ module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
|
|
|
15527
15497
|
this._updateLinesPosition(position);
|
|
15528
15498
|
this._view.updateTimeline();
|
|
15529
15499
|
};
|
|
15530
|
-
Lines.prototype._onLineAdd = function (position) {
|
|
15531
|
-
this._createLine(position);
|
|
15532
|
-
this._setInteractions(position);
|
|
15533
|
-
this._updateLinesPosition(position);
|
|
15534
|
-
};
|
|
15535
15500
|
Lines.prototype._onLineRemove = function (position) {
|
|
15536
|
-
this.
|
|
15501
|
+
this._removeLine(position);
|
|
15537
15502
|
this._updateLinesPosition(position);
|
|
15538
15503
|
};
|
|
15539
15504
|
Lines.prototype._onSourcesWrappingChanged = function (sources) {
|
|
@@ -15543,15 +15508,6 @@ module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
|
|
|
15543
15508
|
}
|
|
15544
15509
|
}.bind(this));
|
|
15545
15510
|
};
|
|
15546
|
-
Lines.prototype.changeLineHeight = function (from, to) {
|
|
15547
|
-
for (var position in this._linesByPosition) {
|
|
15548
|
-
if (Utils.objectHasProperty(this._linesByPosition, position)) {
|
|
15549
|
-
if (!this._linesByPosition[position].isSegmentsLine()) {
|
|
15550
|
-
this._linesByPosition[position].changeHeight(from, to);
|
|
15551
|
-
}
|
|
15552
|
-
}
|
|
15553
|
-
}
|
|
15554
|
-
};
|
|
15555
15511
|
Lines.prototype.addSourceGroup = function (source, sourceGroup, position) {
|
|
15556
15512
|
if (!this._linesByPosition[position] || this._linesByPosition[position].isSegmentsLine()) {
|
|
15557
15513
|
this._createLine(position);
|
|
@@ -15578,7 +15534,7 @@ module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
|
|
|
15578
15534
|
}
|
|
15579
15535
|
return sourceGroup;
|
|
15580
15536
|
};
|
|
15581
|
-
Lines.prototype.
|
|
15537
|
+
Lines.prototype._removeLine = function (pos) {
|
|
15582
15538
|
var oldLine = this._linesByPosition[pos];
|
|
15583
15539
|
var lineId = oldLine.getId();
|
|
15584
15540
|
if (this._automaticallyCreatedLineId === lineId) {
|
|
@@ -16159,11 +16115,6 @@ module.exports = function (Colors, EventEmitter, TimelineSegments, TimelineSourc
|
|
|
16159
16115
|
Peaks.prototype._removeWindowResizeHandler = function () {
|
|
16160
16116
|
window.removeEventListener('resize', this._onResize);
|
|
16161
16117
|
};
|
|
16162
|
-
Peaks.prototype.setLineHeight = function (newLineHeight) {
|
|
16163
|
-
var oldHeight = this.options.lineHeight;
|
|
16164
|
-
this.options.lineHeight = newLineHeight;
|
|
16165
|
-
this.emit('options.set.line_height', oldHeight);
|
|
16166
|
-
};
|
|
16167
16118
|
Peaks.prototype.zoomIn = function () {
|
|
16168
16119
|
this.view.setZoom(this.view.getTimeToPixelsScale() + Math.floor(this.view.getTimeToPixelsScale() / 10) + 1);
|
|
16169
16120
|
};
|
|
@@ -18197,9 +18148,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Loader, Konva)
|
|
|
18197
18148
|
this._indicators = {};
|
|
18198
18149
|
var self = this;
|
|
18199
18150
|
this._x = this._view.timeToPixels(source.startTime);
|
|
18200
|
-
this._roundedX = Math.round(this._x);
|
|
18201
18151
|
this._width = this._view.timeToPixels(source.endTime - source.startTime);
|
|
18202
|
-
this._roundedWidth = Math.round(this._width);
|
|
18203
18152
|
var heights = SourceGroup.getHeights(source, peaks);
|
|
18204
18153
|
this._unwrappedHeight = heights.unwrapped;
|
|
18205
18154
|
this._wrappedHeight = heights.wrapped;
|
|
@@ -18301,7 +18250,6 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Loader, Konva)
|
|
|
18301
18250
|
this._layer.draw();
|
|
18302
18251
|
}
|
|
18303
18252
|
}.bind(this));
|
|
18304
|
-
this._view.setTimelineLength(this._view.timeToPixels(this._source.endTime) + this._view.getWidth());
|
|
18305
18253
|
return {
|
|
18306
18254
|
x: draggedElement.absolutePosition().x,
|
|
18307
18255
|
y: draggedElement.absolutePosition().y
|
|
@@ -18314,11 +18262,9 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Loader, Konva)
|
|
|
18314
18262
|
const newTimeToPixelsScale = this._view.getTimeToPixelsScale();
|
|
18315
18263
|
this._group.x(startPixel - frameOffset);
|
|
18316
18264
|
this._x = startPixel;
|
|
18317
|
-
this._roundedX = Math.round(this._x);
|
|
18318
18265
|
const newWidth = endPixel - startPixel;
|
|
18319
18266
|
if (newWidth !== this._width) {
|
|
18320
18267
|
this._width = newWidth;
|
|
18321
|
-
this._roundedWidth = Math.round(this._width);
|
|
18322
18268
|
if (newTimeToPixelsScale !== this._currentTimeToPixelsScaleUsed) {
|
|
18323
18269
|
this._currentTimeToPixelsScaleUsed = newTimeToPixelsScale;
|
|
18324
18270
|
this._updateMarkers();
|
|
@@ -18369,9 +18315,11 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Loader, Konva)
|
|
|
18369
18315
|
start: this._source.startTime,
|
|
18370
18316
|
end: this._source.endTime
|
|
18371
18317
|
};
|
|
18318
|
+
this._isDragged = true;
|
|
18372
18319
|
this._hideButtons();
|
|
18373
18320
|
};
|
|
18374
18321
|
SourceGroup.prototype._onHandleDragEnd = function () {
|
|
18322
|
+
this._isDragged = false;
|
|
18375
18323
|
this._showButtons();
|
|
18376
18324
|
};
|
|
18377
18325
|
SourceGroup.prototype._addHandles = function (forceCreate) {
|
|
@@ -18453,43 +18401,45 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Loader, Konva)
|
|
|
18453
18401
|
};
|
|
18454
18402
|
SourceGroup.prototype.drawSourceShape = function (ctx, shape, addBorderWidth, fill) {
|
|
18455
18403
|
var offset = addBorderWidth ? this._borderWidth : 0;
|
|
18456
|
-
var radius = this._source.borderRadius !== undefined && this._source.borderRadius !== null ? this._source.borderRadius : Math.max(1, Math.min(this.
|
|
18457
|
-
var x = Math.max(0, this._view.getFrameOffset() - this.
|
|
18458
|
-
var width = Math.min(this.
|
|
18404
|
+
var radius = this._source.borderRadius !== undefined && this._source.borderRadius !== null ? this._source.borderRadius : Math.max(1, Math.min(this._width / 2, Math.min(CORNER_RADIUS, this._height / 2)));
|
|
18405
|
+
var x = Math.max(0, this._view.getFrameOffset() - this._x - 2 * radius);
|
|
18406
|
+
var width = Math.min(this._width - x, this._view.getWidth() + 4 * radius - Math.max(0, this._x - this._view.getFrameOffset()));
|
|
18459
18407
|
var xWidth = x + width;
|
|
18460
|
-
|
|
18461
|
-
|
|
18462
|
-
|
|
18463
|
-
|
|
18464
|
-
|
|
18465
|
-
|
|
18466
|
-
|
|
18467
|
-
|
|
18468
|
-
|
|
18469
|
-
|
|
18470
|
-
|
|
18471
|
-
|
|
18472
|
-
if (
|
|
18473
|
-
|
|
18474
|
-
|
|
18475
|
-
|
|
18476
|
-
|
|
18477
|
-
|
|
18478
|
-
|
|
18479
|
-
|
|
18480
|
-
|
|
18481
|
-
|
|
18482
|
-
|
|
18408
|
+
if (width > 0) {
|
|
18409
|
+
ctx.beginPath();
|
|
18410
|
+
ctx.moveTo(x + radius, offset);
|
|
18411
|
+
ctx.lineTo(xWidth - radius, offset);
|
|
18412
|
+
ctx.quadraticCurveTo(xWidth - offset, offset, xWidth - offset, radius);
|
|
18413
|
+
ctx.lineTo(xWidth - offset, this._height - radius);
|
|
18414
|
+
ctx.quadraticCurveTo(xWidth - offset, this._height - offset, xWidth - radius, this._height - offset);
|
|
18415
|
+
ctx.lineTo(x + radius, this._height - offset);
|
|
18416
|
+
ctx.quadraticCurveTo(x + offset, this._height - offset, x + offset, this._height - radius);
|
|
18417
|
+
ctx.lineTo(x + offset, radius);
|
|
18418
|
+
ctx.quadraticCurveTo(x + offset, offset, x + radius, offset);
|
|
18419
|
+
ctx.closePath();
|
|
18420
|
+
if (fill) {
|
|
18421
|
+
if (this._source.shouldShowWarning()) {
|
|
18422
|
+
var gradient = ctx.createLinearGradient(0, 0, this._width, 0);
|
|
18423
|
+
if (this._source.mediaEndTime < this._source.duration) {
|
|
18424
|
+
var rightStopPosition = Math.max(1 - this._source.warningWidth / this._width, 0.5);
|
|
18425
|
+
gradient.addColorStop(rightStopPosition, this._source.backgroundColor);
|
|
18426
|
+
gradient.addColorStop(1, this._source.warningColor);
|
|
18427
|
+
}
|
|
18428
|
+
if (this._source.mediaStartTime > 0) {
|
|
18429
|
+
var leftStopPosition = Math.min(this._source.warningWidth / this._width, 0.5);
|
|
18430
|
+
gradient.addColorStop(0, this._source.warningColor);
|
|
18431
|
+
gradient.addColorStop(leftStopPosition, this._source.backgroundColor);
|
|
18432
|
+
}
|
|
18433
|
+
ctx.fillStyle = gradient;
|
|
18434
|
+
ctx.fill();
|
|
18435
|
+
} else {
|
|
18436
|
+
ctx.fillStyle = this._source.backgroundColor;
|
|
18437
|
+
ctx.fill();
|
|
18483
18438
|
}
|
|
18484
|
-
ctx.fillStyle = gradient;
|
|
18485
|
-
ctx.fill();
|
|
18486
|
-
} else {
|
|
18487
|
-
ctx.fillStyle = this._source.backgroundColor;
|
|
18488
|
-
ctx.fill();
|
|
18489
18439
|
}
|
|
18490
|
-
|
|
18491
|
-
|
|
18492
|
-
|
|
18440
|
+
if (shape) {
|
|
18441
|
+
ctx.fillStrokeShape(shape);
|
|
18442
|
+
}
|
|
18493
18443
|
}
|
|
18494
18444
|
};
|
|
18495
18445
|
SourceGroup.prototype._addUnwrap = function (forceCreate) {
|
|
@@ -20408,7 +20358,6 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
20408
20358
|
this._peaks.on('source.update', this._onSourceUpdate.bind(this));
|
|
20409
20359
|
this._peaks.on('data.retrieved', this._onDataRetrieved.bind(this));
|
|
20410
20360
|
this._peaks.on('segments.show', this._onSegmentsShow.bind(this));
|
|
20411
|
-
this._peaks.on('options.set.line_height', this._onOptionsLineHeightChange.bind(this));
|
|
20412
20361
|
this._peaks.on('source.setIndicators', this.setIndicators.bind(this));
|
|
20413
20362
|
}
|
|
20414
20363
|
SourcesLayer.prototype.fitToView = function () {
|
|
@@ -20435,23 +20384,6 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
20435
20384
|
SourcesLayer.prototype.isEditingEnabled = function () {
|
|
20436
20385
|
return this._allowEditing;
|
|
20437
20386
|
};
|
|
20438
|
-
SourcesLayer.prototype._onOptionsLineHeightChange = function (oldHeight) {
|
|
20439
|
-
var positions = [];
|
|
20440
|
-
for (var sourceId in this._sourcesGroup) {
|
|
20441
|
-
if (Utils.objectHasProperty(this._sourcesGroup, sourceId)) {
|
|
20442
|
-
var source = this._sourcesGroup[sourceId].getSource();
|
|
20443
|
-
if (!positions.includes(source.position)) {
|
|
20444
|
-
this._lines.changeLineHeight(oldHeight, this._peaks.options.lineHeight);
|
|
20445
|
-
positions.push(source.position);
|
|
20446
|
-
}
|
|
20447
|
-
this._removeSource(source);
|
|
20448
|
-
this._addSourceGroup(source);
|
|
20449
|
-
}
|
|
20450
|
-
}
|
|
20451
|
-
if (positions) {
|
|
20452
|
-
this.refresh();
|
|
20453
|
-
}
|
|
20454
|
-
};
|
|
20455
20387
|
SourcesLayer.prototype.refresh = function () {
|
|
20456
20388
|
var frameOffset = this._view.getFrameOffset();
|
|
20457
20389
|
var width = this._view.getWidth();
|
|
@@ -20584,7 +20516,12 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
20584
20516
|
const draggedElementId = element.currentTarget.attrs.sourceId;
|
|
20585
20517
|
var selectedElements = this._view.getSelectedElements();
|
|
20586
20518
|
const shouldDragSelectedElements = Object.keys(selectedElements).includes(draggedElementId);
|
|
20587
|
-
|
|
20519
|
+
if (shouldDragSelectedElements) {
|
|
20520
|
+
this._draggedElements = Object.values(selectedElements).sort((a, b) => a.startTime - b.startTime);
|
|
20521
|
+
} else {
|
|
20522
|
+
this._draggedElements = [this._sourcesGroup[draggedElementId].getSource()];
|
|
20523
|
+
this._view.deselectAll();
|
|
20524
|
+
}
|
|
20588
20525
|
this._draggedElementsData = this._draggedElements.reduce(function (bounds, source) {
|
|
20589
20526
|
bounds.initialStartTime = Math.min(source.startTime, bounds.initialStartTime);
|
|
20590
20527
|
bounds.initialEndTime = Math.max(source.endTime, bounds.initialEndTime);
|
|
@@ -20617,12 +20554,12 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
20617
20554
|
};
|
|
20618
20555
|
SourcesLayer.prototype._dragSourcesGroup = function () {
|
|
20619
20556
|
var mousePos = Math.min(this._view.getWidth() - this._peaks.options.autoScrollThreshold * this._view.getWidth(), Math.max(0, this._view.getPointerPosition().x));
|
|
20620
|
-
const
|
|
20557
|
+
const timeDiff = this._view.pixelsToTime(mousePos - this._mouseDownX);
|
|
20621
20558
|
const timeOffsetDiff = this._view.getTimeOffset() - this._initialTimeOffset;
|
|
20622
20559
|
const mousePosX = this._view.getPointerPosition().x;
|
|
20623
20560
|
const mousePosY = this._view.getPointerPosition().y;
|
|
20624
20561
|
const {initialStartTime, initialEndTime, orderable} = this._draggedElementsData;
|
|
20625
|
-
const shouldRedraw = this.manageSourceMovements(this._draggedElements, initialStartTime + timeOffsetDiff +
|
|
20562
|
+
const shouldRedraw = this.manageSourceMovements(this._draggedElements, initialStartTime + timeOffsetDiff + timeDiff, initialEndTime + timeOffsetDiff + timeDiff, orderable, mousePosX, mousePosY);
|
|
20626
20563
|
if (shouldRedraw) {
|
|
20627
20564
|
this.draw();
|
|
20628
20565
|
}
|
|
@@ -20648,6 +20585,8 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
20648
20585
|
this.refresh();
|
|
20649
20586
|
};
|
|
20650
20587
|
SourcesLayer.prototype.manageSourceMovements = function (sources, newStartTime, newEndTime, orderable, mouseX, mouseY) {
|
|
20588
|
+
newStartTime = typeof newStartTime === 'number' ? Utils.roundTime(newStartTime) : newStartTime;
|
|
20589
|
+
newEndTime = typeof newEndTime === 'number' ? Utils.roundTime(newEndTime) : newEndTime;
|
|
20651
20590
|
if (this._peaks.options.canMoveSourcesBetweenLines && typeof mouseY === 'number') {
|
|
20652
20591
|
this.manageVerticalPosition(sources, newStartTime, newEndTime, mouseX, mouseY);
|
|
20653
20592
|
}
|
|
@@ -20656,7 +20595,7 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
20656
20595
|
}
|
|
20657
20596
|
({newStartTime, newEndTime} = this.manageCollision(sources, newStartTime, newEndTime));
|
|
20658
20597
|
this._applyTimeChangesToSources(sources, sources[0].startTime, newStartTime, newEndTime);
|
|
20659
|
-
this._view.setTimelineLength(this._view.timeToPixels(
|
|
20598
|
+
this._view.setTimelineLength(this._view.timeToPixels(sources[sources.length - 1].endTime) + this._view.getWidth());
|
|
20660
20599
|
return true;
|
|
20661
20600
|
};
|
|
20662
20601
|
SourcesLayer.prototype.manageVerticalPosition = function (sources, startTime, endTime, mouseX, mouseY) {
|
|
@@ -20801,7 +20740,6 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
20801
20740
|
this._peaks.off('source.update', this._onSourceUpdate);
|
|
20802
20741
|
this._peaks.off('data.retrieved', this._onDataRetrieved);
|
|
20803
20742
|
this._peaks.off('segments.show', this._onSegmentsShow);
|
|
20804
|
-
this._peaks.off('options.set.line_height', this._onOptionsLineHeightChange);
|
|
20805
20743
|
this._peaks.off('source.setIndicators', this.setIndicators);
|
|
20806
20744
|
};
|
|
20807
20745
|
SourcesLayer.prototype.getHeight = function () {
|
package/src/line-indicator.js
CHANGED
|
@@ -118,16 +118,6 @@ define([
|
|
|
118
118
|
this.draw();
|
|
119
119
|
};
|
|
120
120
|
|
|
121
|
-
LineIndicator.prototype._showMenu = function(menu) {
|
|
122
|
-
menu.style.display = 'block';
|
|
123
|
-
var containerRect = this._stage.container().getBoundingClientRect();
|
|
124
|
-
|
|
125
|
-
menu.style.top = containerRect.top
|
|
126
|
-
+ this._stage.getPointerPosition().y
|
|
127
|
-
- menu.offsetHeight + 'px';
|
|
128
|
-
menu.style.left = containerRect.left + this._stage.getPointerPosition().x + 6 + 'px';
|
|
129
|
-
};
|
|
130
|
-
|
|
131
121
|
LineIndicator.prototype._createIndicator = function(line, type, text) {
|
|
132
122
|
var indicator = new Konva.Group();
|
|
133
123
|
var indicatorHeight = 0;
|
package/src/line.js
CHANGED
|
@@ -52,12 +52,6 @@ define([
|
|
|
52
52
|
return this._id;
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
Line.prototype.isEmpty = function() {
|
|
56
|
-
return this.isSegmentsLine() ?
|
|
57
|
-
this._segmentsGroup.isEmpty() :
|
|
58
|
-
Object.keys(this._sources).length === 0;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
55
|
Line.prototype.countRemainingElements = function() {
|
|
62
56
|
return this.isSegmentsLine() ?
|
|
63
57
|
this._segmentsGroup.countRemainingElements() :
|
|
@@ -100,43 +94,6 @@ define([
|
|
|
100
94
|
return this._height;
|
|
101
95
|
};
|
|
102
96
|
|
|
103
|
-
Line.prototype.changeHeight = function(from, to) {
|
|
104
|
-
if (this._sourceHeights[from]) {
|
|
105
|
-
var oldHeight = this._height;
|
|
106
|
-
|
|
107
|
-
if (this._sourceHeights[to]) {
|
|
108
|
-
this._sourceHeights[to] += this._sourceHeights[from];
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
this._sourceHeights[to] = this._sourceHeights[from];
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (to > this._height) {
|
|
115
|
-
this._height = to;
|
|
116
|
-
}
|
|
117
|
-
else if (from === this._height) {
|
|
118
|
-
this._height = 0;
|
|
119
|
-
for (var height in this._sourceHeights) {
|
|
120
|
-
if (Utils.objectHasProperty(this._sourceHeights, height)) {
|
|
121
|
-
var parsedHeight = parseInt(height, 10);
|
|
122
|
-
|
|
123
|
-
if (parsedHeight !== from) {
|
|
124
|
-
if (parsedHeight > this._height) {
|
|
125
|
-
this._height = parsedHeight;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (this._height !== oldHeight) {
|
|
133
|
-
this._peaks.emit('line.heightChanged', this._position);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
delete this._sourceHeights[from];
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
|
|
140
97
|
Line.prototype._addHeight = function(height) {
|
|
141
98
|
if (this._sourceHeights[height]) {
|
|
142
99
|
this._sourceHeights[height]++;
|
|
@@ -418,21 +375,27 @@ define([
|
|
|
418
375
|
const cursorTime = this._view.pixelsToTime(this._view.getPointerPosition().x);
|
|
419
376
|
var newStartTime = startTime;
|
|
420
377
|
var newEndTime = endTime;
|
|
378
|
+
var tmpTimes;
|
|
421
379
|
|
|
422
|
-
var sourceDuration = endTime - startTime;
|
|
380
|
+
var sourceDuration = Utils.roundTime(endTime - startTime);
|
|
423
381
|
|
|
424
|
-
if (newStartTime
|
|
382
|
+
if (typeof newStartTime === 'number' && typeof newEndTime === 'number') {
|
|
425
383
|
if (this._sources[firstSource.id].prevSourceId) {
|
|
426
384
|
// there is another source to the left
|
|
427
385
|
var previousStartTime = this._sources[this._sources[firstSource.id].prevSourceId].source.startTime;
|
|
428
386
|
|
|
429
|
-
if (cursorTime + this._view.getTimeOffset() < previousStartTime) {
|
|
387
|
+
if (Utils.roundTime(cursorTime + this._view.getTimeOffset()) < previousStartTime) {
|
|
430
388
|
// we want to change order
|
|
431
|
-
|
|
389
|
+
tmpTimes = this._changeSourcesPosition(
|
|
432
390
|
sources,
|
|
433
391
|
sourceDuration,
|
|
434
392
|
cursorTime + this._view.getTimeOffset()
|
|
435
|
-
)
|
|
393
|
+
);
|
|
394
|
+
|
|
395
|
+
if (typeof tmpTimes.newStartTime === 'number' && typeof tmpTimes.newEndTime === 'number') {
|
|
396
|
+
newStartTime = tmpTimes.newStartTime;
|
|
397
|
+
newEndTime = tmpTimes.newEndTime;
|
|
398
|
+
}
|
|
436
399
|
}
|
|
437
400
|
}
|
|
438
401
|
|
|
@@ -440,13 +403,18 @@ define([
|
|
|
440
403
|
// there is another source to the right
|
|
441
404
|
var nextEndTime = this._sources[this._sources[lastSource.id].nextSourceId].source.endTime;
|
|
442
405
|
|
|
443
|
-
if (cursorTime + this._view.getTimeOffset() > nextEndTime) {
|
|
406
|
+
if (Utils.roundTime(cursorTime + this._view.getTimeOffset()) > nextEndTime) {
|
|
444
407
|
// we want to change order
|
|
445
|
-
|
|
408
|
+
tmpTimes = this._changeSourcesPosition(
|
|
446
409
|
sources,
|
|
447
410
|
sourceDuration,
|
|
448
411
|
cursorTime + this._view.getTimeOffset()
|
|
449
|
-
)
|
|
412
|
+
);
|
|
413
|
+
|
|
414
|
+
if (typeof tmpTimes.newStartTime === 'number' && typeof tmpTimes.newEndTime === 'number') {
|
|
415
|
+
newStartTime = tmpTimes.newStartTime;
|
|
416
|
+
newEndTime = tmpTimes.newEndTime;
|
|
417
|
+
}
|
|
450
418
|
}
|
|
451
419
|
}
|
|
452
420
|
}
|
|
@@ -495,7 +463,7 @@ define([
|
|
|
495
463
|
endLimit
|
|
496
464
|
));
|
|
497
465
|
|
|
498
|
-
if (newStartTime
|
|
466
|
+
if (typeof newStartTime === 'number' && typeof newEndTime === 'number') {
|
|
499
467
|
let prevSourceId = currentRange.start
|
|
500
468
|
? currentRange.start.source.id
|
|
501
469
|
: null;
|
|
@@ -602,7 +570,7 @@ define([
|
|
|
602
570
|
}
|
|
603
571
|
|
|
604
572
|
// Update the other edge if dragging and collision
|
|
605
|
-
if (newStartTime
|
|
573
|
+
if (typeof newStartTime === 'number' && typeof newEndTime === 'number') {
|
|
606
574
|
var timeWidth = originalEndTime - originalStartTime;
|
|
607
575
|
|
|
608
576
|
if (startLimited) {
|
|
@@ -616,12 +584,12 @@ define([
|
|
|
616
584
|
|
|
617
585
|
// Check for minimal size of source
|
|
618
586
|
// We assume that only 1 source can be resized at a time
|
|
619
|
-
if (newStartTime
|
|
587
|
+
if (typeof newStartTime === 'number' && typeof newEndTime !== 'number') {
|
|
620
588
|
if (Utils.roundTime(sources[0].endTime - newStartTime) < sources[0].minSize) {
|
|
621
589
|
newStartTime = Utils.roundTime(sources[0].endTime - sources[0].minSize);
|
|
622
590
|
}
|
|
623
591
|
}
|
|
624
|
-
else if (newEndTime
|
|
592
|
+
else if (typeof newEndTime === 'number' && typeof newStartTime !== 'number') {
|
|
625
593
|
if (Utils.roundTime(newEndTime - sources[0].startTime) < sources[0].minSize) {
|
|
626
594
|
newEndTime = Utils.roundTime(sources[0].startTime + sources[0].minSize);
|
|
627
595
|
}
|
package/src/lines.js
CHANGED
|
@@ -43,7 +43,6 @@ define([
|
|
|
43
43
|
);
|
|
44
44
|
|
|
45
45
|
this._peaks.on('line.heightChanged', this._onLineHeightChanged.bind(this));
|
|
46
|
-
this._peaks.on('line.add', this._onLineAdd.bind(this));
|
|
47
46
|
this._peaks.on('line.remove', this._onLineRemove.bind(this));
|
|
48
47
|
|
|
49
48
|
this._peaks.on('sources.show', this._onSourcesWrappingChanged.bind(this));
|
|
@@ -104,14 +103,8 @@ define([
|
|
|
104
103
|
this._view.updateTimeline();
|
|
105
104
|
};
|
|
106
105
|
|
|
107
|
-
Lines.prototype._onLineAdd = function(position) {
|
|
108
|
-
this._createLine(position);
|
|
109
|
-
this._setInteractions(position);
|
|
110
|
-
this._updateLinesPosition(position);
|
|
111
|
-
};
|
|
112
|
-
|
|
113
106
|
Lines.prototype._onLineRemove = function(position) {
|
|
114
|
-
this.
|
|
107
|
+
this._removeLine(position);
|
|
115
108
|
this._updateLinesPosition(position);
|
|
116
109
|
};
|
|
117
110
|
|
|
@@ -123,16 +116,6 @@ define([
|
|
|
123
116
|
}.bind(this));
|
|
124
117
|
};
|
|
125
118
|
|
|
126
|
-
Lines.prototype.changeLineHeight = function(from, to) {
|
|
127
|
-
for (var position in this._linesByPosition) {
|
|
128
|
-
if (Utils.objectHasProperty(this._linesByPosition, position)) {
|
|
129
|
-
if (!this._linesByPosition[position].isSegmentsLine()) {
|
|
130
|
-
this._linesByPosition[position].changeHeight(from, to);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
|
|
136
119
|
Lines.prototype.addSourceGroup = function(source, sourceGroup, position) {
|
|
137
120
|
if (!this._linesByPosition[position] || this._linesByPosition[position].isSegmentsLine()) {
|
|
138
121
|
this._createLine(position);
|
|
@@ -170,7 +153,7 @@ define([
|
|
|
170
153
|
return sourceGroup;
|
|
171
154
|
};
|
|
172
155
|
|
|
173
|
-
Lines.prototype.
|
|
156
|
+
Lines.prototype._removeLine = function(pos) {
|
|
174
157
|
var oldLine = this._linesByPosition[pos];
|
|
175
158
|
var lineId = oldLine.getId();
|
|
176
159
|
|
package/src/main.js
CHANGED
|
@@ -777,13 +777,6 @@ define([
|
|
|
777
777
|
window.removeEventListener('resize', this._onResize);
|
|
778
778
|
};
|
|
779
779
|
|
|
780
|
-
Peaks.prototype.setLineHeight = function(newLineHeight) {
|
|
781
|
-
var oldHeight = this.options.lineHeight;
|
|
782
|
-
|
|
783
|
-
this.options.lineHeight = newLineHeight;
|
|
784
|
-
this.emit('options.set.line_height', oldHeight);
|
|
785
|
-
};
|
|
786
|
-
|
|
787
780
|
Peaks.prototype.zoomIn = function() {
|
|
788
781
|
this.view.setZoom(
|
|
789
782
|
this.view.getTimeToPixelsScale() + Math.floor(this.view.getTimeToPixelsScale() / 10) + 1
|
package/src/source-group.js
CHANGED
|
@@ -47,9 +47,7 @@ define([
|
|
|
47
47
|
var self = this;
|
|
48
48
|
|
|
49
49
|
this._x = this._view.timeToPixels(source.startTime);
|
|
50
|
-
this._roundedX = Math.round(this._x);
|
|
51
50
|
this._width = this._view.timeToPixels(source.endTime - source.startTime);
|
|
52
|
-
this._roundedWidth = Math.round(this._width);
|
|
53
51
|
var heights = SourceGroup.getHeights(source, peaks);
|
|
54
52
|
|
|
55
53
|
this._unwrappedHeight = heights.unwrapped;
|
|
@@ -184,10 +182,6 @@ define([
|
|
|
184
182
|
}.bind(this)
|
|
185
183
|
);
|
|
186
184
|
|
|
187
|
-
this._view.setTimelineLength(
|
|
188
|
-
this._view.timeToPixels(this._source.endTime) + this._view.getWidth()
|
|
189
|
-
);
|
|
190
|
-
|
|
191
185
|
return {
|
|
192
186
|
x: draggedElement.absolutePosition().x,
|
|
193
187
|
y: draggedElement.absolutePosition().y
|
|
@@ -203,13 +197,11 @@ define([
|
|
|
203
197
|
this._group.x(startPixel - frameOffset);
|
|
204
198
|
|
|
205
199
|
this._x = startPixel;
|
|
206
|
-
this._roundedX = Math.round(this._x);
|
|
207
200
|
|
|
208
201
|
const newWidth = endPixel - startPixel;
|
|
209
202
|
|
|
210
203
|
if (newWidth !== this._width) {
|
|
211
204
|
this._width = newWidth;
|
|
212
|
-
this._roundedWidth = Math.round(this._width);
|
|
213
205
|
|
|
214
206
|
// the zoom was changed
|
|
215
207
|
if (newTimeToPixelsScale !== this._currentTimeToPixelsScaleUsed) {
|
|
@@ -277,11 +269,13 @@ define([
|
|
|
277
269
|
start: this._source.startTime,
|
|
278
270
|
end: this._source.endTime
|
|
279
271
|
};
|
|
272
|
+
this._isDragged = true;
|
|
280
273
|
|
|
281
274
|
this._hideButtons();
|
|
282
275
|
};
|
|
283
276
|
|
|
284
277
|
SourceGroup.prototype._onHandleDragEnd = function() {
|
|
278
|
+
this._isDragged = false;
|
|
285
279
|
this._showButtons();
|
|
286
280
|
};
|
|
287
281
|
|
|
@@ -386,7 +380,7 @@ define([
|
|
|
386
380
|
Math.max(
|
|
387
381
|
1,
|
|
388
382
|
Math.min(
|
|
389
|
-
this.
|
|
383
|
+
this._width / 2,
|
|
390
384
|
Math.min(
|
|
391
385
|
CORNER_RADIUS,
|
|
392
386
|
this._height / 2
|
|
@@ -395,63 +389,65 @@ define([
|
|
|
395
389
|
);
|
|
396
390
|
var x = Math.max(
|
|
397
391
|
0,
|
|
398
|
-
this._view.getFrameOffset() - this.
|
|
392
|
+
this._view.getFrameOffset() - this._x - 2 * radius
|
|
399
393
|
);
|
|
400
394
|
var width = Math.min(
|
|
401
|
-
this.
|
|
402
|
-
this._view.getWidth() + radius - Math.max(
|
|
395
|
+
this._width - x,
|
|
396
|
+
this._view.getWidth() + 4 * radius - Math.max(
|
|
403
397
|
0,
|
|
404
|
-
this.
|
|
398
|
+
this._x - this._view.getFrameOffset()
|
|
405
399
|
)
|
|
406
400
|
);
|
|
407
401
|
var xWidth = x + width;
|
|
408
402
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
403
|
+
if (width > 0) {
|
|
404
|
+
ctx.beginPath();
|
|
405
|
+
ctx.moveTo(x + radius, offset);
|
|
406
|
+
ctx.lineTo(xWidth - radius, offset);
|
|
407
|
+
ctx.quadraticCurveTo(xWidth - offset, offset, xWidth - offset, radius);
|
|
408
|
+
ctx.lineTo(xWidth - offset, this._height - radius);
|
|
409
|
+
ctx.quadraticCurveTo(
|
|
410
|
+
xWidth - offset,
|
|
411
|
+
this._height - offset,
|
|
412
|
+
xWidth - radius,
|
|
413
|
+
this._height - offset
|
|
414
|
+
);
|
|
415
|
+
ctx.lineTo(x + radius, this._height - offset);
|
|
416
|
+
ctx.quadraticCurveTo(x + offset, this._height - offset, x + offset, this._height - radius);
|
|
417
|
+
ctx.lineTo(x + offset, radius);
|
|
418
|
+
ctx.quadraticCurveTo(x + offset, offset, x + radius, offset);
|
|
419
|
+
ctx.closePath();
|
|
425
420
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
421
|
+
if (fill) {
|
|
422
|
+
if (this._source.shouldShowWarning()) {
|
|
423
|
+
var gradient = ctx.createLinearGradient(0, 0, this._width, 0);
|
|
429
424
|
|
|
430
|
-
|
|
431
|
-
|
|
425
|
+
if (this._source.mediaEndTime < this._source.duration) {
|
|
426
|
+
var rightStopPosition = Math.max(1 - (this._source.warningWidth / this._width), 0.5);
|
|
432
427
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
428
|
+
gradient.addColorStop(rightStopPosition, this._source.backgroundColor);
|
|
429
|
+
gradient.addColorStop(1, this._source.warningColor);
|
|
430
|
+
}
|
|
436
431
|
|
|
437
|
-
|
|
438
|
-
|
|
432
|
+
if (this._source.mediaStartTime > 0) {
|
|
433
|
+
var leftStopPosition = Math.min(this._source.warningWidth / this._width, 0.5);
|
|
439
434
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
435
|
+
gradient.addColorStop(0, this._source.warningColor);
|
|
436
|
+
gradient.addColorStop(leftStopPosition, this._source.backgroundColor);
|
|
437
|
+
}
|
|
443
438
|
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
439
|
+
ctx.fillStyle = gradient;
|
|
440
|
+
ctx.fill();
|
|
441
|
+
}
|
|
442
|
+
else {
|
|
443
|
+
ctx.fillStyle = this._source.backgroundColor;
|
|
444
|
+
ctx.fill();
|
|
445
|
+
}
|
|
450
446
|
}
|
|
451
|
-
}
|
|
452
447
|
|
|
453
|
-
|
|
454
|
-
|
|
448
|
+
if (shape) {
|
|
449
|
+
ctx.fillStrokeShape(shape);
|
|
450
|
+
}
|
|
455
451
|
}
|
|
456
452
|
};
|
|
457
453
|
|
package/src/sources-layer.js
CHANGED
|
@@ -57,7 +57,6 @@ define([
|
|
|
57
57
|
this._peaks.on('source.update', this._onSourceUpdate.bind(this));
|
|
58
58
|
this._peaks.on('data.retrieved', this._onDataRetrieved.bind(this));
|
|
59
59
|
this._peaks.on('segments.show', this._onSegmentsShow.bind(this));
|
|
60
|
-
this._peaks.on('options.set.line_height', this._onOptionsLineHeightChange.bind(this));
|
|
61
60
|
this._peaks.on('source.setIndicators', this.setIndicators.bind(this));
|
|
62
61
|
}
|
|
63
62
|
|
|
@@ -99,30 +98,6 @@ define([
|
|
|
99
98
|
return this._allowEditing;
|
|
100
99
|
};
|
|
101
100
|
|
|
102
|
-
SourcesLayer.prototype._onOptionsLineHeightChange = function(oldHeight) {
|
|
103
|
-
var positions = [];
|
|
104
|
-
|
|
105
|
-
for (var sourceId in this._sourcesGroup) {
|
|
106
|
-
if (Utils.objectHasProperty(this._sourcesGroup, sourceId)) {
|
|
107
|
-
var source = this._sourcesGroup[sourceId].getSource();
|
|
108
|
-
|
|
109
|
-
if (!positions.includes(source.position)) {
|
|
110
|
-
this._lines.changeLineHeight(
|
|
111
|
-
oldHeight,
|
|
112
|
-
this._peaks.options.lineHeight
|
|
113
|
-
);
|
|
114
|
-
positions.push(source.position);
|
|
115
|
-
}
|
|
116
|
-
this._removeSource(source);
|
|
117
|
-
this._addSourceGroup(source);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (positions) {
|
|
122
|
-
this.refresh();
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
|
|
126
101
|
SourcesLayer.prototype.refresh = function() {
|
|
127
102
|
var frameOffset = this._view.getFrameOffset();
|
|
128
103
|
var width = this._view.getWidth();
|
|
@@ -310,8 +285,6 @@ define([
|
|
|
310
285
|
// Update sources in visible time range.
|
|
311
286
|
var sources = this.findSources(startTime, endTime);
|
|
312
287
|
|
|
313
|
-
// TODO: Should implement virtualization on Y
|
|
314
|
-
|
|
315
288
|
var count = sources.length;
|
|
316
289
|
|
|
317
290
|
sources.forEach(this._updateSource.bind(this));
|
|
@@ -335,9 +308,13 @@ define([
|
|
|
335
308
|
draggedElementId
|
|
336
309
|
);
|
|
337
310
|
|
|
338
|
-
|
|
339
|
-
Object.values(selectedElements).sort((a, b) => a.startTime - b.startTime)
|
|
340
|
-
|
|
311
|
+
if (shouldDragSelectedElements) {
|
|
312
|
+
this._draggedElements = Object.values(selectedElements).sort((a, b) => a.startTime - b.startTime);
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
this._draggedElements = [this._sourcesGroup[draggedElementId].getSource()];
|
|
316
|
+
this._view.deselectAll();
|
|
317
|
+
}
|
|
341
318
|
|
|
342
319
|
this._draggedElementsData = this._draggedElements.reduce(function(bounds, source) {
|
|
343
320
|
bounds.initialStartTime = Math.min(source.startTime, bounds.initialStartTime);
|
|
@@ -389,7 +366,7 @@ define([
|
|
|
389
366
|
)
|
|
390
367
|
);
|
|
391
368
|
|
|
392
|
-
const
|
|
369
|
+
const timeDiff = this._view.pixelsToTime(mousePos - this._mouseDownX);
|
|
393
370
|
const timeOffsetDiff = this._view.getTimeOffset() - this._initialTimeOffset;
|
|
394
371
|
const mousePosX = this._view.getPointerPosition().x;
|
|
395
372
|
const mousePosY = this._view.getPointerPosition().y;
|
|
@@ -397,8 +374,8 @@ define([
|
|
|
397
374
|
|
|
398
375
|
const shouldRedraw = this.manageSourceMovements(
|
|
399
376
|
this._draggedElements,
|
|
400
|
-
initialStartTime + timeOffsetDiff +
|
|
401
|
-
initialEndTime + timeOffsetDiff +
|
|
377
|
+
initialStartTime + timeOffsetDiff + timeDiff,
|
|
378
|
+
initialEndTime + timeOffsetDiff + timeDiff,
|
|
402
379
|
orderable,
|
|
403
380
|
mousePosX,
|
|
404
381
|
mousePosY
|
|
@@ -451,6 +428,9 @@ define([
|
|
|
451
428
|
SourcesLayer.prototype.manageSourceMovements = function(sources, newStartTime, newEndTime, orderable, mouseX,
|
|
452
429
|
mouseY
|
|
453
430
|
) {
|
|
431
|
+
newStartTime = typeof newStartTime === 'number' ? Utils.roundTime(newStartTime) : newStartTime;
|
|
432
|
+
newEndTime = typeof newEndTime === 'number' ? Utils.roundTime(newEndTime) : newEndTime;
|
|
433
|
+
|
|
454
434
|
if (this._peaks.options.canMoveSourcesBetweenLines && typeof mouseY === 'number') {
|
|
455
435
|
this.manageVerticalPosition(sources, newStartTime, newEndTime, mouseX, mouseY);
|
|
456
436
|
}
|
|
@@ -463,7 +443,7 @@ define([
|
|
|
463
443
|
this._applyTimeChangesToSources(sources, sources[0].startTime, newStartTime, newEndTime);
|
|
464
444
|
|
|
465
445
|
this._view.setTimelineLength(
|
|
466
|
-
this._view.timeToPixels(
|
|
446
|
+
this._view.timeToPixels(sources[sources.length - 1].endTime) + this._view.getWidth()
|
|
467
447
|
);
|
|
468
448
|
|
|
469
449
|
return true;
|
|
@@ -692,7 +672,6 @@ define([
|
|
|
692
672
|
this._peaks.off('source.update', this._onSourceUpdate);
|
|
693
673
|
this._peaks.off('data.retrieved', this._onDataRetrieved);
|
|
694
674
|
this._peaks.off('segments.show', this._onSegmentsShow);
|
|
695
|
-
this._peaks.off('options.set.line_height', this._onOptionsLineHeightChange);
|
|
696
675
|
this._peaks.off('source.setIndicators', this.setIndicators);
|
|
697
676
|
};
|
|
698
677
|
|