@checksub_team/peaks_timeline 1.16.0-alpha.2 → 1.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/peaks.js +448 -470
- package/src/line-indicator.js +10 -0
- package/src/line.js +225 -222
- package/src/lines.js +56 -162
- package/src/main.js +8 -7
- package/src/segments-group.js +0 -4
- package/src/source-group.js +79 -84
- package/src/source.js +64 -18
- package/src/sources-layer.js +118 -92
- package/src/timeline-sources.js +12 -10
- package/src/timeline-zoomview.js +0 -4
package/peaks.js
CHANGED
|
@@ -14809,6 +14809,12 @@ 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
|
+
};
|
|
14812
14818
|
LineIndicator.prototype._createIndicator = function (line, type, text) {
|
|
14813
14819
|
var indicator = new Konva.Group();
|
|
14814
14820
|
var indicatorHeight = 0;
|
|
@@ -14943,7 +14949,7 @@ module.exports = function (Konva, Utils, SVGs) {
|
|
|
14943
14949
|
return LineIndicator;
|
|
14944
14950
|
}(_dereq_('konva'), _dereq_('./utils'), _dereq_('./svgs'));
|
|
14945
14951
|
},{"./svgs":108,"./utils":113,"konva":43}],92:[function(_dereq_,module,exports){
|
|
14946
|
-
module.exports = function (
|
|
14952
|
+
module.exports = function (Konva, Utils) {
|
|
14947
14953
|
'use strict';
|
|
14948
14954
|
function Line(peaks, view, y, id, position) {
|
|
14949
14955
|
this._peaks = peaks;
|
|
@@ -14976,8 +14982,8 @@ module.exports = function (SourceGroup, Konva, Utils) {
|
|
|
14976
14982
|
Line.prototype.getId = function () {
|
|
14977
14983
|
return this._id;
|
|
14978
14984
|
};
|
|
14979
|
-
Line.prototype.
|
|
14980
|
-
return this.isSegmentsLine() ? this._segmentsGroup.
|
|
14985
|
+
Line.prototype.isEmpty = function () {
|
|
14986
|
+
return this.isSegmentsLine() ? this._segmentsGroup.isEmpty() : Object.keys(this._sources).length === 0;
|
|
14981
14987
|
};
|
|
14982
14988
|
Line.prototype.isSegmentsLine = function () {
|
|
14983
14989
|
return Boolean(this._segmentsGroup);
|
|
@@ -15005,53 +15011,71 @@ module.exports = function (SourceGroup, Konva, Utils) {
|
|
|
15005
15011
|
Line.prototype.lineHeight = function () {
|
|
15006
15012
|
return this._height;
|
|
15007
15013
|
};
|
|
15008
|
-
Line.prototype.
|
|
15009
|
-
if (this._sourceHeights[
|
|
15010
|
-
this.
|
|
15011
|
-
|
|
15012
|
-
|
|
15013
|
-
|
|
15014
|
-
this.
|
|
15014
|
+
Line.prototype.changeHeight = function (from, to) {
|
|
15015
|
+
if (this._sourceHeights[from]) {
|
|
15016
|
+
var oldHeight = this._height;
|
|
15017
|
+
if (this._sourceHeights[to]) {
|
|
15018
|
+
this._sourceHeights[to] += this._sourceHeights[from];
|
|
15019
|
+
} else {
|
|
15020
|
+
this._sourceHeights[to] = this._sourceHeights[from];
|
|
15015
15021
|
}
|
|
15016
|
-
|
|
15017
|
-
|
|
15018
|
-
|
|
15019
|
-
if (Object.keys(this._sources).length === 0) {
|
|
15020
|
-
this._height = this._peaks.options.emptyLineHeight;
|
|
15021
|
-
this._sourceHeights = {};
|
|
15022
|
-
} else {
|
|
15023
|
-
this._sourceHeights[height]--;
|
|
15024
|
-
if (this._sourceHeights[height] === 0 && height === this._height) {
|
|
15025
|
-
delete this._sourceHeights[height];
|
|
15022
|
+
if (to > this._height) {
|
|
15023
|
+
this._height = to;
|
|
15024
|
+
} else if (from === this._height) {
|
|
15026
15025
|
this._height = 0;
|
|
15027
|
-
for (var
|
|
15028
|
-
if (Utils.objectHasProperty(this._sourceHeights,
|
|
15029
|
-
var parsedHeight = parseInt(
|
|
15030
|
-
if (parsedHeight
|
|
15031
|
-
this._height
|
|
15026
|
+
for (var height in this._sourceHeights) {
|
|
15027
|
+
if (Utils.objectHasProperty(this._sourceHeights, height)) {
|
|
15028
|
+
var parsedHeight = parseInt(height, 10);
|
|
15029
|
+
if (parsedHeight !== from) {
|
|
15030
|
+
if (parsedHeight > this._height) {
|
|
15031
|
+
this._height = parsedHeight;
|
|
15032
|
+
}
|
|
15032
15033
|
}
|
|
15033
15034
|
}
|
|
15034
15035
|
}
|
|
15035
15036
|
}
|
|
15037
|
+
if (this._height !== oldHeight) {
|
|
15038
|
+
this._peaks.emit('line.heightChanged', this._position);
|
|
15039
|
+
}
|
|
15040
|
+
delete this._sourceHeights[from];
|
|
15036
15041
|
}
|
|
15037
15042
|
};
|
|
15038
|
-
Line.prototype.updateLineHeight = function (
|
|
15043
|
+
Line.prototype.updateLineHeight = function (sourceGroup, action) {
|
|
15039
15044
|
var oldHeight = this._height;
|
|
15040
|
-
var sourceGroup = this._sourcesGroup[source.id];
|
|
15041
15045
|
var sourceGroupHeight;
|
|
15042
15046
|
switch (action) {
|
|
15043
15047
|
case 'add':
|
|
15044
|
-
sourceGroupHeight = sourceGroup
|
|
15045
|
-
this.
|
|
15048
|
+
sourceGroupHeight = sourceGroup.getCurrentHeight();
|
|
15049
|
+
if (this._sourceHeights[sourceGroupHeight]) {
|
|
15050
|
+
this._sourceHeights[sourceGroupHeight]++;
|
|
15051
|
+
} else {
|
|
15052
|
+
this._sourceHeights[sourceGroupHeight] = 1;
|
|
15053
|
+
if (sourceGroupHeight > this._height) {
|
|
15054
|
+
this._height = sourceGroupHeight;
|
|
15055
|
+
}
|
|
15056
|
+
}
|
|
15046
15057
|
break;
|
|
15047
15058
|
case 'remove':
|
|
15048
|
-
|
|
15049
|
-
|
|
15059
|
+
if (Object.keys(this._sources).length === 0) {
|
|
15060
|
+
this._height = this._peaks.options.emptyLineHeight;
|
|
15061
|
+
this._sourceHeights = {};
|
|
15062
|
+
} else {
|
|
15063
|
+
sourceGroupHeight = sourceGroup.getCurrentHeight();
|
|
15064
|
+
this._sourceHeights[sourceGroupHeight]--;
|
|
15065
|
+
if (this._sourceHeights[sourceGroupHeight] === 0 && sourceGroupHeight === this._height) {
|
|
15066
|
+
delete this._sourceHeights[sourceGroupHeight];
|
|
15067
|
+
this._height = 0;
|
|
15068
|
+
for (var height in this._sourceHeights) {
|
|
15069
|
+
if (Utils.objectHasProperty(this._sourceHeights, height)) {
|
|
15070
|
+
var parsedHeight = parseInt(height, 10);
|
|
15071
|
+
if (parsedHeight > this._height) {
|
|
15072
|
+
this._height = parsedHeight;
|
|
15073
|
+
}
|
|
15074
|
+
}
|
|
15075
|
+
}
|
|
15076
|
+
}
|
|
15077
|
+
}
|
|
15050
15078
|
break;
|
|
15051
|
-
default:
|
|
15052
|
-
var {unwrapped, wrapped} = sourceGroup ? sourceGroup.getHeights() : SourceGroup.getHeights(source, this._peaks);
|
|
15053
|
-
this._addHeight(source.wrapped ? wrapped : unwrapped);
|
|
15054
|
-
this._subtractHeight(source.wrapped ? unwrapped : wrapped);
|
|
15055
15079
|
}
|
|
15056
15080
|
if (this._height !== oldHeight) {
|
|
15057
15081
|
this._peaks.emit('line.heightChanged', this._position);
|
|
@@ -15063,10 +15087,9 @@ module.exports = function (SourceGroup, Konva, Utils) {
|
|
|
15063
15087
|
Line.prototype.addToLayer = function (layer) {
|
|
15064
15088
|
layer.add(this._group);
|
|
15065
15089
|
};
|
|
15066
|
-
Line.prototype.addSourceGroup = function (
|
|
15067
|
-
|
|
15068
|
-
|
|
15069
|
-
}
|
|
15090
|
+
Line.prototype.addSourceGroup = function (sourceGroup) {
|
|
15091
|
+
var source = sourceGroup.getSource();
|
|
15092
|
+
this._sourcesGroup[source.id] = sourceGroup;
|
|
15070
15093
|
if (!this._sources[source.id]) {
|
|
15071
15094
|
var newSource = {
|
|
15072
15095
|
source: source,
|
|
@@ -15083,9 +15106,9 @@ module.exports = function (SourceGroup, Konva, Utils) {
|
|
|
15083
15106
|
}
|
|
15084
15107
|
if (source.endTime <= currentSource.source.startTime) {
|
|
15085
15108
|
var startLimit = currentSource.prevSourceId ? this._sources[currentSource.prevSourceId].source.endTime : 0;
|
|
15086
|
-
|
|
15087
|
-
if (
|
|
15088
|
-
source.updateTimes(
|
|
15109
|
+
var newTimes = this._canBePlacedBetween(source.startTime, source.endTime, startLimit, currentSource.source.startTime);
|
|
15110
|
+
if (newTimes) {
|
|
15111
|
+
source.updateTimes(newTimes.start, newTimes.end);
|
|
15089
15112
|
if (currentSource.prevSourceId) {
|
|
15090
15113
|
this._sources[currentSource.prevSourceId].nextSourceId = source.id;
|
|
15091
15114
|
newSource.prevSourceId = currentSource.prevSourceId;
|
|
@@ -15112,9 +15135,9 @@ module.exports = function (SourceGroup, Konva, Utils) {
|
|
|
15112
15135
|
this._firstSourceId = source.id;
|
|
15113
15136
|
this._sources[source.id] = newSource;
|
|
15114
15137
|
}
|
|
15115
|
-
this.updateLineHeight(
|
|
15138
|
+
this.updateLineHeight(sourceGroup, 'add');
|
|
15116
15139
|
}
|
|
15117
|
-
if (
|
|
15140
|
+
if (!sourceGroup.getParent() || !sourceGroup.isDescendantOf(this._group)) {
|
|
15118
15141
|
sourceGroup.addToGroup(this._group);
|
|
15119
15142
|
}
|
|
15120
15143
|
};
|
|
@@ -15134,46 +15157,42 @@ module.exports = function (SourceGroup, Konva, Utils) {
|
|
|
15134
15157
|
};
|
|
15135
15158
|
Line.prototype._canBePlacedBetween = function (startTime, endTime, startLimit, endLimit) {
|
|
15136
15159
|
var timeWidth = Utils.roundTime(endTime - startTime);
|
|
15137
|
-
var
|
|
15160
|
+
var newTimes = null;
|
|
15138
15161
|
if (!endLimit && startTime > startLimit || startTime > startLimit && endTime < endLimit) {
|
|
15139
|
-
|
|
15140
|
-
|
|
15162
|
+
newTimes = {
|
|
15163
|
+
start: startTime,
|
|
15164
|
+
end: endTime
|
|
15165
|
+
};
|
|
15141
15166
|
} else if (Utils.roundTime(endLimit - startLimit) >= timeWidth) {
|
|
15142
15167
|
if (startTime > startLimit) {
|
|
15143
|
-
|
|
15144
|
-
|
|
15168
|
+
newTimes = {
|
|
15169
|
+
start: Utils.roundTime(endLimit - timeWidth),
|
|
15170
|
+
end: endLimit
|
|
15171
|
+
};
|
|
15145
15172
|
} else {
|
|
15146
|
-
|
|
15147
|
-
|
|
15173
|
+
newTimes = {
|
|
15174
|
+
start: startLimit,
|
|
15175
|
+
end: Utils.roundTime(startLimit + timeWidth)
|
|
15176
|
+
};
|
|
15148
15177
|
}
|
|
15149
15178
|
}
|
|
15150
|
-
return
|
|
15151
|
-
newStartTime,
|
|
15152
|
-
newEndTime
|
|
15153
|
-
};
|
|
15179
|
+
return newTimes;
|
|
15154
15180
|
};
|
|
15155
15181
|
Line.prototype.removeSourceGroup = function (source, isPermanent) {
|
|
15156
15182
|
var sourceGroup = this._sourcesGroup[source.id];
|
|
15157
15183
|
delete this._sourcesGroup[source.id];
|
|
15158
15184
|
if (isPermanent) {
|
|
15159
|
-
|
|
15160
|
-
|
|
15161
|
-
if (Object.keys(this._sources).length === 0) {
|
|
15162
|
-
setTimeout(function () {
|
|
15163
|
-
this._peaks.emit('line.remove', this._position);
|
|
15164
|
-
}.bind(this), 0);
|
|
15165
|
-
return sourceGroup;
|
|
15166
|
-
}
|
|
15167
|
-
if (sourceData.prevSourceId) {
|
|
15168
|
-
this._sources[sourceData.prevSourceId].nextSourceId = sourceData.nextSourceId;
|
|
15185
|
+
if (this._sources[source.id].prevSourceId) {
|
|
15186
|
+
this._sources[this._sources[source.id].prevSourceId].nextSourceId = this._sources[source.id].nextSourceId;
|
|
15169
15187
|
}
|
|
15170
|
-
if (
|
|
15171
|
-
this._sources[
|
|
15188
|
+
if (this._sources[source.id].nextSourceId) {
|
|
15189
|
+
this._sources[this._sources[source.id].nextSourceId].prevSourceId = this._sources[source.id].prevSourceId;
|
|
15172
15190
|
}
|
|
15173
15191
|
if (this._firstSourceId === source.id) {
|
|
15174
|
-
this._firstSourceId =
|
|
15192
|
+
this._firstSourceId = this._sources[source.id].nextSourceId;
|
|
15175
15193
|
}
|
|
15176
|
-
this.
|
|
15194
|
+
delete this._sources[source.id];
|
|
15195
|
+
this.updateLineHeight(sourceGroup, 'remove');
|
|
15177
15196
|
}
|
|
15178
15197
|
return sourceGroup;
|
|
15179
15198
|
};
|
|
@@ -15196,85 +15215,83 @@ module.exports = function (SourceGroup, Konva, Utils) {
|
|
|
15196
15215
|
this._y += dy;
|
|
15197
15216
|
this._group.y(this._group.y() + dy);
|
|
15198
15217
|
};
|
|
15199
|
-
Line.prototype.
|
|
15200
|
-
|
|
15201
|
-
const lastSource = sources[sources.length - 1];
|
|
15202
|
-
const cursorTime = this._view.pixelsToTime(this._view.getPointerPosition().x);
|
|
15203
|
-
var newStartTime = startTime;
|
|
15204
|
-
var newEndTime = endTime;
|
|
15218
|
+
Line.prototype.manageSourceOrder = function (source, newTimes) {
|
|
15219
|
+
var cursorTime = this._view.pixelsToTime(this._view.getPointerPosition().x);
|
|
15205
15220
|
var tmpTimes;
|
|
15206
|
-
var sourceDuration =
|
|
15207
|
-
if (
|
|
15208
|
-
if (this._sources[
|
|
15209
|
-
var previousStartTime = this._sources[this._sources[
|
|
15210
|
-
if (
|
|
15211
|
-
tmpTimes = this.
|
|
15212
|
-
if (
|
|
15213
|
-
|
|
15214
|
-
|
|
15221
|
+
var sourceDuration = source.endTime - source.startTime;
|
|
15222
|
+
if (newTimes.start !== null && newTimes.end !== null) {
|
|
15223
|
+
if (this._sources[source.id].prevSourceId) {
|
|
15224
|
+
var previousStartTime = this._sources[this._sources[source.id].prevSourceId].source.startTime;
|
|
15225
|
+
if (cursorTime + this._view.getTimeOffset() < previousStartTime) {
|
|
15226
|
+
tmpTimes = this._changeSourcePosition(source, sourceDuration, cursorTime + this._view.getTimeOffset());
|
|
15227
|
+
if (tmpTimes) {
|
|
15228
|
+
newTimes.start = tmpTimes.start;
|
|
15229
|
+
newTimes.end = tmpTimes.end;
|
|
15215
15230
|
}
|
|
15216
15231
|
}
|
|
15217
15232
|
}
|
|
15218
|
-
if (this._sources[
|
|
15219
|
-
var nextEndTime = this._sources[this._sources[
|
|
15220
|
-
if (
|
|
15221
|
-
tmpTimes = this.
|
|
15222
|
-
if (
|
|
15223
|
-
|
|
15224
|
-
|
|
15233
|
+
if (this._sources[source.id].nextSourceId) {
|
|
15234
|
+
var nextEndTime = this._sources[this._sources[source.id].nextSourceId].source.endTime;
|
|
15235
|
+
if (cursorTime + this._view.getTimeOffset() > nextEndTime) {
|
|
15236
|
+
tmpTimes = this._changeSourcePosition(source, sourceDuration, cursorTime + this._view.getTimeOffset());
|
|
15237
|
+
if (tmpTimes) {
|
|
15238
|
+
newTimes.start = tmpTimes.start;
|
|
15239
|
+
newTimes.end = tmpTimes.end;
|
|
15225
15240
|
}
|
|
15226
15241
|
}
|
|
15227
15242
|
}
|
|
15228
15243
|
}
|
|
15229
|
-
|
|
15230
|
-
|
|
15231
|
-
|
|
15232
|
-
|
|
15244
|
+
if (newTimes.start) {
|
|
15245
|
+
newTimes.start = Utils.roundTime(newTimes.start);
|
|
15246
|
+
}
|
|
15247
|
+
if (newTimes.end) {
|
|
15248
|
+
newTimes.end = Utils.roundTime(newTimes.end);
|
|
15249
|
+
}
|
|
15250
|
+
return newTimes;
|
|
15233
15251
|
};
|
|
15234
|
-
Line.prototype.
|
|
15235
|
-
|
|
15236
|
-
|
|
15237
|
-
|
|
15238
|
-
|
|
15239
|
-
|
|
15240
|
-
|
|
15241
|
-
|
|
15242
|
-
|
|
15243
|
-
|
|
15244
|
-
|
|
15245
|
-
|
|
15246
|
-
|
|
15247
|
-
|
|
15248
|
-
|
|
15249
|
-
|
|
15250
|
-
|
|
15251
|
-
|
|
15252
|
-
|
|
15253
|
-
|
|
15254
|
-
|
|
15255
|
-
|
|
15256
|
-
|
|
15257
|
-
|
|
15258
|
-
|
|
15259
|
-
|
|
15260
|
-
|
|
15261
|
-
|
|
15262
|
-
|
|
15263
|
-
|
|
15252
|
+
Line.prototype._changeSourcePosition = function (source, sourceDuration, time) {
|
|
15253
|
+
if (source.orderable && this._firstSourceId) {
|
|
15254
|
+
var currentRange = {
|
|
15255
|
+
start: null,
|
|
15256
|
+
end: null
|
|
15257
|
+
};
|
|
15258
|
+
var startLimit = null;
|
|
15259
|
+
var endLimit = null;
|
|
15260
|
+
do {
|
|
15261
|
+
if (!currentRange.end) {
|
|
15262
|
+
currentRange.end = this._sources[this._firstSourceId];
|
|
15263
|
+
} else {
|
|
15264
|
+
currentRange.start = currentRange.end;
|
|
15265
|
+
currentRange.end = this._sources[currentRange.start.nextSourceId];
|
|
15266
|
+
}
|
|
15267
|
+
if (currentRange.start) {
|
|
15268
|
+
startLimit = currentRange.start.source.endTime;
|
|
15269
|
+
} else {
|
|
15270
|
+
startLimit = 0;
|
|
15271
|
+
}
|
|
15272
|
+
if (currentRange.end) {
|
|
15273
|
+
endLimit = currentRange.end.source.startTime;
|
|
15274
|
+
} else {
|
|
15275
|
+
endLimit = null;
|
|
15276
|
+
}
|
|
15277
|
+
if (time > startLimit && (endLimit === null || time < endLimit)) {
|
|
15278
|
+
var newTimes = this._canBePlacedBetween(time, time + sourceDuration, startLimit, endLimit);
|
|
15279
|
+
if (newTimes) {
|
|
15280
|
+
if (newTimes.start) {
|
|
15281
|
+
newTimes.start = Utils.roundTime(newTimes.start);
|
|
15282
|
+
}
|
|
15283
|
+
if (newTimes.end) {
|
|
15284
|
+
newTimes.end = Utils.roundTime(newTimes.end);
|
|
15285
|
+
}
|
|
15286
|
+
source.updateTimes(newTimes.start, newTimes.end);
|
|
15287
|
+
var prevSourceId = currentRange.start ? currentRange.start.source.id : null;
|
|
15264
15288
|
this._moveSource(this._sources[source.id].source, prevSourceId);
|
|
15265
|
-
|
|
15266
|
-
}
|
|
15289
|
+
return newTimes;
|
|
15290
|
+
}
|
|
15267
15291
|
}
|
|
15268
|
-
|
|
15269
|
-
|
|
15270
|
-
|
|
15271
|
-
};
|
|
15272
|
-
}
|
|
15273
|
-
} while (currentRange.end);
|
|
15274
|
-
return {
|
|
15275
|
-
newStartTime,
|
|
15276
|
-
newEndTime
|
|
15277
|
-
};
|
|
15292
|
+
} while (currentRange.end);
|
|
15293
|
+
}
|
|
15294
|
+
return null;
|
|
15278
15295
|
};
|
|
15279
15296
|
Line.prototype._moveSource = function (source, prevSourceId) {
|
|
15280
15297
|
var sourceObj = this._sources[source.id];
|
|
@@ -15302,17 +15319,20 @@ module.exports = function (SourceGroup, Konva, Utils) {
|
|
|
15302
15319
|
}
|
|
15303
15320
|
this._sources[source.id] = sourceObj;
|
|
15304
15321
|
};
|
|
15305
|
-
Line.prototype.manageCollision = function (
|
|
15306
|
-
var originalStartTime =
|
|
15307
|
-
var originalEndTime =
|
|
15322
|
+
Line.prototype.manageCollision = function (source, newTimes) {
|
|
15323
|
+
var originalStartTime = null;
|
|
15324
|
+
var originalEndTime = null;
|
|
15325
|
+
var newStartTime = null;
|
|
15326
|
+
var newEndTime = null;
|
|
15308
15327
|
var startLimited = false;
|
|
15309
15328
|
var endLimited = false;
|
|
15310
|
-
|
|
15311
|
-
|
|
15312
|
-
|
|
15313
|
-
|
|
15314
|
-
|
|
15315
|
-
|
|
15329
|
+
newTimes.updateTimelineLength = false;
|
|
15330
|
+
if (newTimes.start !== null) {
|
|
15331
|
+
originalStartTime = newTimes.start;
|
|
15332
|
+
newStartTime = originalStartTime;
|
|
15333
|
+
if (source.startTime > newStartTime) {
|
|
15334
|
+
if (this._sources[source.id].prevSourceId) {
|
|
15335
|
+
var previousSource = this._sources[this._sources[source.id].prevSourceId].source;
|
|
15316
15336
|
if (newStartTime < previousSource.endTime) {
|
|
15317
15337
|
newStartTime = previousSource.endTime;
|
|
15318
15338
|
startLimited = true;
|
|
@@ -15325,10 +15345,12 @@ module.exports = function (SourceGroup, Konva, Utils) {
|
|
|
15325
15345
|
}
|
|
15326
15346
|
}
|
|
15327
15347
|
}
|
|
15328
|
-
if (
|
|
15329
|
-
|
|
15330
|
-
|
|
15331
|
-
|
|
15348
|
+
if (newTimes.end !== null) {
|
|
15349
|
+
originalEndTime = newTimes.end;
|
|
15350
|
+
newEndTime = originalEndTime;
|
|
15351
|
+
if (source.endTime < newEndTime) {
|
|
15352
|
+
if (this._sources[source.id].nextSourceId) {
|
|
15353
|
+
var nextSource = this._sources[this._sources[source.id].nextSourceId].source;
|
|
15332
15354
|
if (newEndTime > nextSource.startTime) {
|
|
15333
15355
|
newEndTime = nextSource.startTime;
|
|
15334
15356
|
endLimited = true;
|
|
@@ -15336,7 +15358,7 @@ module.exports = function (SourceGroup, Konva, Utils) {
|
|
|
15336
15358
|
}
|
|
15337
15359
|
}
|
|
15338
15360
|
}
|
|
15339
|
-
if (
|
|
15361
|
+
if (newStartTime !== null && newEndTime !== null) {
|
|
15340
15362
|
var timeWidth = originalEndTime - originalStartTime;
|
|
15341
15363
|
if (startLimited) {
|
|
15342
15364
|
newEndTime = Utils.roundTime(newStartTime + timeWidth);
|
|
@@ -15345,28 +15367,34 @@ module.exports = function (SourceGroup, Konva, Utils) {
|
|
|
15345
15367
|
newStartTime = Utils.roundTime(newEndTime - timeWidth);
|
|
15346
15368
|
}
|
|
15347
15369
|
}
|
|
15348
|
-
if (
|
|
15349
|
-
if (Utils.roundTime(
|
|
15350
|
-
newStartTime = Utils.roundTime(
|
|
15370
|
+
if (newStartTime !== null && newEndTime === null) {
|
|
15371
|
+
if (Utils.roundTime(source.endTime - newStartTime) < source.minSize) {
|
|
15372
|
+
newStartTime = Utils.roundTime(source.endTime - source.minSize);
|
|
15351
15373
|
}
|
|
15352
|
-
} else if (
|
|
15353
|
-
if (Utils.roundTime(newEndTime -
|
|
15354
|
-
newEndTime = Utils.roundTime(
|
|
15374
|
+
} else if (newEndTime !== null && newStartTime === null) {
|
|
15375
|
+
if (Utils.roundTime(newEndTime - source.startTime) < source.minSize) {
|
|
15376
|
+
newEndTime = Utils.roundTime(source.startTime + source.minSize);
|
|
15355
15377
|
}
|
|
15356
15378
|
} else {
|
|
15357
|
-
if (Utils.roundTime(newEndTime - newStartTime) <
|
|
15358
|
-
if (
|
|
15359
|
-
newEndTime = Utils.roundTime(newStartTime +
|
|
15379
|
+
if (Utils.roundTime(newEndTime - newStartTime) < source.minSize) {
|
|
15380
|
+
if (source.endTime !== newEndTime) {
|
|
15381
|
+
newEndTime = Utils.roundTime(newStartTime + source.minSize);
|
|
15360
15382
|
}
|
|
15361
|
-
if (
|
|
15362
|
-
newStartTime = Utils.roundTime(newEndTime -
|
|
15383
|
+
if (source.startTime !== newStartTime) {
|
|
15384
|
+
newStartTime = Utils.roundTime(newEndTime - source.minSize);
|
|
15363
15385
|
}
|
|
15364
15386
|
}
|
|
15365
15387
|
}
|
|
15366
|
-
|
|
15367
|
-
newStartTime
|
|
15368
|
-
|
|
15369
|
-
|
|
15388
|
+
if (newStartTime !== null && newStartTime !== originalStartTime) {
|
|
15389
|
+
newTimes.start = newStartTime;
|
|
15390
|
+
}
|
|
15391
|
+
if (newEndTime !== null && newEndTime !== originalEndTime) {
|
|
15392
|
+
newTimes.end = newEndTime;
|
|
15393
|
+
if (this._sources[source.id].nextSourceId === null) {
|
|
15394
|
+
newTimes.updateTimelineLength = true;
|
|
15395
|
+
}
|
|
15396
|
+
}
|
|
15397
|
+
return newTimes;
|
|
15370
15398
|
};
|
|
15371
15399
|
Line.prototype.getSourcesAfter = function (time) {
|
|
15372
15400
|
const sources = [];
|
|
@@ -15385,34 +15413,6 @@ module.exports = function (SourceGroup, Konva, Utils) {
|
|
|
15385
15413
|
}
|
|
15386
15414
|
return sources;
|
|
15387
15415
|
};
|
|
15388
|
-
Line.prototype.getSourcesAround = function (time) {
|
|
15389
|
-
var left = null;
|
|
15390
|
-
var right = null;
|
|
15391
|
-
var overlapping = null;
|
|
15392
|
-
var currentId = this._firstSourceId;
|
|
15393
|
-
while (currentId) {
|
|
15394
|
-
var lineSource = this._sources[currentId];
|
|
15395
|
-
var source = lineSource.source;
|
|
15396
|
-
if (time < source.startTime) {
|
|
15397
|
-
right = source;
|
|
15398
|
-
break;
|
|
15399
|
-
} else if (time >= source.startTime && time <= source.endTime) {
|
|
15400
|
-
overlapping = source;
|
|
15401
|
-
break;
|
|
15402
|
-
} else {
|
|
15403
|
-
left = source;
|
|
15404
|
-
}
|
|
15405
|
-
currentId = lineSource.nextSourceId;
|
|
15406
|
-
}
|
|
15407
|
-
if (overlapping) {
|
|
15408
|
-
return { overlapping: overlapping };
|
|
15409
|
-
} else {
|
|
15410
|
-
return {
|
|
15411
|
-
left: left,
|
|
15412
|
-
right: right
|
|
15413
|
-
};
|
|
15414
|
-
}
|
|
15415
|
-
};
|
|
15416
15416
|
Line.prototype.updatePosition = function (pos) {
|
|
15417
15417
|
for (var sourceId in this._sources) {
|
|
15418
15418
|
if (Utils.objectHasProperty(this._sources, sourceId)) {
|
|
@@ -15431,29 +15431,26 @@ module.exports = function (SourceGroup, Konva, Utils) {
|
|
|
15431
15431
|
this._group.listening(bool);
|
|
15432
15432
|
};
|
|
15433
15433
|
return Line;
|
|
15434
|
-
}(_dereq_('
|
|
15435
|
-
},{"./
|
|
15434
|
+
}(_dereq_('konva'), _dereq_('./utils'));
|
|
15435
|
+
},{"./utils":113,"konva":43}],93:[function(_dereq_,module,exports){
|
|
15436
15436
|
module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
|
|
15437
15437
|
'use strict';
|
|
15438
15438
|
function Lines(peaks, view, layer) {
|
|
15439
15439
|
this._peaks = peaks;
|
|
15440
15440
|
this._view = view;
|
|
15441
15441
|
this._layer = layer;
|
|
15442
|
+
this._linesBySourceId = {};
|
|
15442
15443
|
this._linesByPosition = {};
|
|
15443
15444
|
this._autoAddToLayer = false;
|
|
15444
15445
|
this._areSourceInteractionsAllowed = true;
|
|
15445
15446
|
this._areSegmentInteractionsAllowed = true;
|
|
15446
|
-
this._automaticallyCreatedLineId = null;
|
|
15447
|
-
this._automaticLineCreationPosition = null;
|
|
15448
|
-
this._automaticLineCreationTimeout = null;
|
|
15449
15447
|
this._segmentsGroups = {};
|
|
15450
15448
|
this._segmentsGroupToLine = {};
|
|
15451
15449
|
this._lineId = 0;
|
|
15452
15450
|
this._lineIndicator = new LineIndicator(peaks, view, document.getElementById('line-indicator-container'));
|
|
15453
15451
|
this._peaks.on('line.heightChanged', this._onLineHeightChanged.bind(this));
|
|
15452
|
+
this._peaks.on('line.add', this._onLineAdd.bind(this));
|
|
15454
15453
|
this._peaks.on('line.remove', this._onLineRemove.bind(this));
|
|
15455
|
-
this._peaks.on('sources.show', this._onSourcesWrappingChanged.bind(this));
|
|
15456
|
-
this._peaks.on('sources.hide', this._onSourcesWrappingChanged.bind(this));
|
|
15457
15454
|
this._peaks.on('segment.updated', this._onSegmentsUpdate.bind(this));
|
|
15458
15455
|
this._peaks.on('segments.add', this._onSegmentsAdd.bind(this));
|
|
15459
15456
|
this._peaks.on('segments.remove', this._onSegmentsRemove.bind(this));
|
|
@@ -15497,24 +15494,33 @@ module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
|
|
|
15497
15494
|
this._updateLinesPosition(position);
|
|
15498
15495
|
this._view.updateTimeline();
|
|
15499
15496
|
};
|
|
15500
|
-
Lines.prototype.
|
|
15501
|
-
this.
|
|
15497
|
+
Lines.prototype._onLineAdd = function (position) {
|
|
15498
|
+
this._createLine(position);
|
|
15499
|
+
this._setInteractions(position);
|
|
15502
15500
|
this._updateLinesPosition(position);
|
|
15503
15501
|
};
|
|
15504
|
-
Lines.prototype.
|
|
15505
|
-
|
|
15506
|
-
|
|
15507
|
-
|
|
15502
|
+
Lines.prototype._onLineRemove = function (position) {
|
|
15503
|
+
var oldLine = this.removeLine(position);
|
|
15504
|
+
var lineNewY = oldLine.getY();
|
|
15505
|
+
this._updateLinesPosition(position, lineNewY);
|
|
15506
|
+
};
|
|
15507
|
+
Lines.prototype.changeLineHeight = function (from, to) {
|
|
15508
|
+
for (var position in this._linesByPosition) {
|
|
15509
|
+
if (Utils.objectHasProperty(this._linesByPosition, position)) {
|
|
15510
|
+
if (!this._linesByPosition[position].isSegmentsLine()) {
|
|
15511
|
+
this._linesByPosition[position].changeHeight(from, to);
|
|
15512
|
+
}
|
|
15508
15513
|
}
|
|
15509
|
-
}
|
|
15514
|
+
}
|
|
15510
15515
|
};
|
|
15511
|
-
Lines.prototype.addSourceGroup = function (
|
|
15516
|
+
Lines.prototype.addSourceGroup = function (sourceGroup, position) {
|
|
15512
15517
|
if (!this._linesByPosition[position] || this._linesByPosition[position].isSegmentsLine()) {
|
|
15513
15518
|
this._createLine(position);
|
|
15514
15519
|
this._setInteractions(position);
|
|
15515
15520
|
}
|
|
15516
|
-
|
|
15517
|
-
this._linesByPosition[position].addSourceGroup(
|
|
15521
|
+
sourceGroup.getSource().position = position;
|
|
15522
|
+
this._linesByPosition[position].addSourceGroup(sourceGroup);
|
|
15523
|
+
this._linesBySourceId[sourceGroup.getSource().id] = this._linesByPosition[position];
|
|
15518
15524
|
};
|
|
15519
15525
|
Lines.prototype.addSegments = function (lineId, position) {
|
|
15520
15526
|
this._createLine(position);
|
|
@@ -15525,28 +15531,22 @@ module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
|
|
|
15525
15531
|
this._updateLinesPosition(position);
|
|
15526
15532
|
};
|
|
15527
15533
|
Lines.prototype.removeSourceGroup = function (source, isPermanent) {
|
|
15528
|
-
if (!this._linesByPosition[source.position]) {
|
|
15529
|
-
return null;
|
|
15530
|
-
}
|
|
15531
15534
|
var sourceGroup = this._linesByPosition[source.position].removeSourceGroup(source, isPermanent);
|
|
15532
15535
|
if (isPermanent) {
|
|
15536
|
+
delete this._linesBySourceId[source.id];
|
|
15533
15537
|
this._updateLinesPosition(source.position);
|
|
15534
15538
|
}
|
|
15535
15539
|
return sourceGroup;
|
|
15536
15540
|
};
|
|
15537
|
-
Lines.prototype.
|
|
15541
|
+
Lines.prototype.removeLine = function (pos) {
|
|
15538
15542
|
var oldLine = this._linesByPosition[pos];
|
|
15539
|
-
var lineId = oldLine.getId();
|
|
15540
|
-
if (this._automaticallyCreatedLineId === lineId) {
|
|
15541
|
-
this._automaticallyCreatedLineId = null;
|
|
15542
|
-
}
|
|
15543
15543
|
oldLine.destroy();
|
|
15544
15544
|
delete this._linesByPosition[pos];
|
|
15545
|
-
this._lineIndicator.removeIndicator(
|
|
15545
|
+
this._lineIndicator.removeIndicator(oldLine.getId(), false);
|
|
15546
15546
|
return oldLine;
|
|
15547
15547
|
};
|
|
15548
15548
|
Lines.prototype.isLineVisible = function (position) {
|
|
15549
|
-
return this._linesByPosition[position]
|
|
15549
|
+
return this._linesByPosition[position].isVisible();
|
|
15550
15550
|
};
|
|
15551
15551
|
Lines.prototype.getVisibleLines = function () {
|
|
15552
15552
|
var positions = {};
|
|
@@ -15576,18 +15576,14 @@ module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
|
|
|
15576
15576
|
Lines.prototype.updateLines = function (position) {
|
|
15577
15577
|
this._updateLinesPosition(position);
|
|
15578
15578
|
};
|
|
15579
|
-
Lines.prototype._updateLinesPosition = function (position) {
|
|
15579
|
+
Lines.prototype._updateLinesPosition = function (position, forceNewY) {
|
|
15580
15580
|
var line = this._linesByPosition[position];
|
|
15581
15581
|
var dy = null;
|
|
15582
15582
|
var newY;
|
|
15583
|
-
if (
|
|
15584
|
-
newY =
|
|
15583
|
+
if (forceNewY) {
|
|
15584
|
+
newY = forceNewY;
|
|
15585
15585
|
} else {
|
|
15586
|
-
|
|
15587
|
-
while ((previousLine === undefined || previousLine === null) && position > 0) {
|
|
15588
|
-
previousLine = this._linesByPosition[--position];
|
|
15589
|
-
}
|
|
15590
|
-
newY = previousLine ? previousLine.getY() + previousLine.lineHeight() + this._peaks.options.interline : 0;
|
|
15586
|
+
newY = line.getY() + line.lineHeight() + this._peaks.options.interline;
|
|
15591
15587
|
}
|
|
15592
15588
|
for (var pos in this._linesByPosition) {
|
|
15593
15589
|
if (Utils.objectHasProperty(this._linesByPosition, pos)) {
|
|
@@ -15603,7 +15599,7 @@ module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
|
|
|
15603
15599
|
}
|
|
15604
15600
|
this._lineIndicator.updateIndicators();
|
|
15605
15601
|
this._lineIndicator.draw();
|
|
15606
|
-
this._view.
|
|
15602
|
+
this._view.drawSourcesLayer();
|
|
15607
15603
|
};
|
|
15608
15604
|
Lines.prototype.setOffsetY = function (frameOffset) {
|
|
15609
15605
|
for (var position in this._linesByPosition) {
|
|
@@ -15637,83 +15633,22 @@ module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
|
|
|
15637
15633
|
}
|
|
15638
15634
|
return length;
|
|
15639
15635
|
};
|
|
15640
|
-
Lines.prototype.
|
|
15641
|
-
if (
|
|
15642
|
-
|
|
15643
|
-
|
|
15644
|
-
|
|
15645
|
-
this._automaticLineCreationPosition = null;
|
|
15646
|
-
this._automaticallyCreatedLineId = null;
|
|
15647
|
-
};
|
|
15648
|
-
Lines.prototype.manageAutomaticLineCreation = function (newLinePosition, initialPosition, sources) {
|
|
15649
|
-
if (this._automaticallyCreatedLineId !== null) {
|
|
15650
|
-
return;
|
|
15651
|
-
} else if (this._automaticLineCreationPosition !== null && this._automaticLineCreationPosition !== newLinePosition) {
|
|
15652
|
-
this.stopAutomaticLineCreation();
|
|
15653
|
-
}
|
|
15654
|
-
if (this._automaticLineCreationTimeout) {
|
|
15655
|
-
return;
|
|
15656
|
-
}
|
|
15657
|
-
this._automaticLineCreationPosition = newLinePosition;
|
|
15658
|
-
this._automaticLineCreationTimeout = setTimeout(function () {
|
|
15659
|
-
this._automaticLineCreationTimeout = null;
|
|
15660
|
-
var currentLine = this._linesByPosition[initialPosition];
|
|
15661
|
-
if (currentLine.countRemainingElements() === sources.length) {
|
|
15662
|
-
this.stopAutomaticLineCreation();
|
|
15663
|
-
return;
|
|
15664
|
-
}
|
|
15665
|
-
this._automaticallyCreatedLineId = this._createLine(newLinePosition);
|
|
15666
|
-
this._setInteractions(newLinePosition);
|
|
15667
|
-
this.moveSourcesToPosition(sources, currentLine.getPosition(), newLinePosition);
|
|
15668
|
-
}.bind(this), this._peaks.options.automaticLineCreationDelay);
|
|
15669
|
-
};
|
|
15670
|
-
Lines.prototype.manageVerticalPosition = function (sources, startTime, endTime, mouseX, mouseY) {
|
|
15671
|
-
if (mouseX === null || mouseX === undefined) {
|
|
15672
|
-
return;
|
|
15673
|
-
}
|
|
15674
|
-
const position = sources[0].position;
|
|
15675
|
-
const linePos = this.getLinesUnderY(mouseY);
|
|
15676
|
-
if (linePos[0] !== linePos[1]) {
|
|
15677
|
-
this.manageAutomaticLineCreation(linePos[0] + 1, position, sources);
|
|
15678
|
-
} else {
|
|
15679
|
-
this.stopAutomaticLineCreation();
|
|
15680
|
-
if (mouseX !== null && mouseX !== undefined && linePos[0] !== position && !this._linesByPosition[linePos[0]].isSegmentsLine()) {
|
|
15681
|
-
var mouseTime = this._view.pixelsToTime(mouseX + this._view.getFrameOffset());
|
|
15682
|
-
var sourceDuration = Utils.roundTime(endTime - startTime);
|
|
15683
|
-
if (this._hasSpaceForSourceAt(linePos[0], mouseTime, sourceDuration)) {
|
|
15684
|
-
this.moveSourcesToPosition(sources, position, linePos[0]);
|
|
15685
|
-
}
|
|
15636
|
+
Lines.prototype.manageVerticalPosition = function (source, newY) {
|
|
15637
|
+
if (newY !== null && newY !== undefined) {
|
|
15638
|
+
var pos = this.getLineOnPosition(newY);
|
|
15639
|
+
if (pos[0] === pos[1] && pos[0] !== source.position && !this._linesByPosition[pos[0]].isSegmentsLine()) {
|
|
15640
|
+
this.moveSourceToPosition(source, pos[0]);
|
|
15686
15641
|
}
|
|
15687
15642
|
}
|
|
15688
15643
|
};
|
|
15689
|
-
Lines.prototype._hasSpaceForSourceAt = function (linePosition, mouseTime, sourceDuration) {
|
|
15690
|
-
var line = this._linesByPosition[linePosition];
|
|
15691
|
-
if (!line || line.isSegmentsLine()) {
|
|
15692
|
-
return false;
|
|
15693
|
-
}
|
|
15694
|
-
var sourcesAround = line.getSourcesAround(mouseTime);
|
|
15695
|
-
if (sourcesAround.overlapping) {
|
|
15696
|
-
return false;
|
|
15697
|
-
} else if (!sourcesAround.right) {
|
|
15698
|
-
return true;
|
|
15699
|
-
} else {
|
|
15700
|
-
var leftLimit = sourcesAround.left ? sourcesAround.left.endTime : 0;
|
|
15701
|
-
var rightLimit = sourcesAround.right.startTime;
|
|
15702
|
-
return sourceDuration <= Utils.roundTime(rightLimit - leftLimit);
|
|
15703
|
-
}
|
|
15704
|
-
};
|
|
15705
15644
|
Lines.prototype.getLineByPosition = function (pos) {
|
|
15706
15645
|
return this._linesByPosition[pos];
|
|
15707
15646
|
};
|
|
15708
|
-
Lines.prototype.
|
|
15709
|
-
var keys = Object.keys(this._linesByPosition);
|
|
15710
|
-
return keys.pop();
|
|
15711
|
-
};
|
|
15712
|
-
Lines.prototype.getLinesUnderY = function (y) {
|
|
15647
|
+
Lines.prototype.getLineOnPosition = function (y) {
|
|
15713
15648
|
var height;
|
|
15714
15649
|
var pos = [
|
|
15715
15650
|
-1,
|
|
15716
|
-
|
|
15651
|
+
Number.MAX_VALUE
|
|
15717
15652
|
];
|
|
15718
15653
|
for (var position in this._linesByPosition) {
|
|
15719
15654
|
if (Utils.objectHasProperty(this._linesByPosition, position)) {
|
|
@@ -15728,15 +15663,12 @@ module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
|
|
|
15728
15663
|
}
|
|
15729
15664
|
return pos;
|
|
15730
15665
|
};
|
|
15731
|
-
Lines.prototype.
|
|
15732
|
-
|
|
15733
|
-
|
|
15734
|
-
|
|
15735
|
-
|
|
15736
|
-
|
|
15737
|
-
this.addSourceGroup(source, sourceGroup, targetPosition);
|
|
15738
|
-
}.bind(this));
|
|
15739
|
-
this._updateLinesPosition(initialPosition);
|
|
15666
|
+
Lines.prototype.moveSourceToPosition = function (source, pos) {
|
|
15667
|
+
var sourceGroup = this._linesByPosition[source.position].removeSourceGroup(source, true);
|
|
15668
|
+
delete this._linesBySourceId[source.id];
|
|
15669
|
+
sourceGroup.moveTo(this._linesByPosition[pos].getKonvaGroup());
|
|
15670
|
+
this._updateLinesPosition(source.position);
|
|
15671
|
+
this.addSourceGroup(sourceGroup, pos);
|
|
15740
15672
|
};
|
|
15741
15673
|
Lines.prototype._getNextLineId = function () {
|
|
15742
15674
|
this._lineId++;
|
|
@@ -15752,13 +15684,9 @@ module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
|
|
|
15752
15684
|
if (currentPos < position) {
|
|
15753
15685
|
y += this._linesByPosition[pos].lineHeight() + this._peaks.options.interline;
|
|
15754
15686
|
} else {
|
|
15755
|
-
if (
|
|
15756
|
-
|
|
15757
|
-
this._linesByPosition[currentPos]
|
|
15758
|
-
newLinesByPosition[newPosition] = this._linesByPosition[currentPos];
|
|
15759
|
-
if (!this._linesByPosition[newPosition]) {
|
|
15760
|
-
break;
|
|
15761
|
-
}
|
|
15687
|
+
if (this._linesByPosition[position]) {
|
|
15688
|
+
this._linesByPosition[currentPos].updatePosition(currentPos + 1);
|
|
15689
|
+
newLinesByPosition[currentPos + 1] = this._linesByPosition[currentPos];
|
|
15762
15690
|
}
|
|
15763
15691
|
}
|
|
15764
15692
|
}
|
|
@@ -15770,7 +15698,6 @@ module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
|
|
|
15770
15698
|
}
|
|
15771
15699
|
newLinesByPosition[position] = line;
|
|
15772
15700
|
this._linesByPosition = newLinesByPosition;
|
|
15773
|
-
return line.getId();
|
|
15774
15701
|
};
|
|
15775
15702
|
Lines.prototype.updateSegments = function (frameStartTime, frameEndTime) {
|
|
15776
15703
|
for (var lineId in this._segmentsGroups) {
|
|
@@ -15779,11 +15706,11 @@ module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
|
|
|
15779
15706
|
}
|
|
15780
15707
|
}
|
|
15781
15708
|
};
|
|
15782
|
-
Lines.prototype.manageCollision = function (
|
|
15783
|
-
return this.
|
|
15709
|
+
Lines.prototype.manageCollision = function (source, newTimes) {
|
|
15710
|
+
return this._linesBySourceId[source.id].manageCollision(source, newTimes);
|
|
15784
15711
|
};
|
|
15785
|
-
Lines.prototype.
|
|
15786
|
-
return this.
|
|
15712
|
+
Lines.prototype.manageSourceOrder = function (source, newTimes) {
|
|
15713
|
+
return this._linesBySourceId[source.id].manageSourceOrder(source, newTimes);
|
|
15787
15714
|
};
|
|
15788
15715
|
Lines.prototype._setInteractions = function (position) {
|
|
15789
15716
|
var line = this._linesByPosition[position];
|
|
@@ -15936,8 +15863,7 @@ module.exports = function (Colors, EventEmitter, TimelineSegments, TimelineSourc
|
|
|
15936
15863
|
autoScrollThreshold: 0.05,
|
|
15937
15864
|
minSourceSize: 0.05,
|
|
15938
15865
|
minSegmentSize: 0.2,
|
|
15939
|
-
canMoveSourcesBetweenLines: true
|
|
15940
|
-
automaticLineCreationDelay: 100
|
|
15866
|
+
canMoveSourcesBetweenLines: true
|
|
15941
15867
|
};
|
|
15942
15868
|
this.logger = console.error.bind(console);
|
|
15943
15869
|
return this;
|
|
@@ -16115,6 +16041,11 @@ module.exports = function (Colors, EventEmitter, TimelineSegments, TimelineSourc
|
|
|
16115
16041
|
Peaks.prototype._removeWindowResizeHandler = function () {
|
|
16116
16042
|
window.removeEventListener('resize', this._onResize);
|
|
16117
16043
|
};
|
|
16044
|
+
Peaks.prototype.setLineHeight = function (newLineHeight) {
|
|
16045
|
+
var oldHeight = this.options.lineHeight;
|
|
16046
|
+
this.options.lineHeight = newLineHeight;
|
|
16047
|
+
this.emit('options.set.line_height', oldHeight);
|
|
16048
|
+
};
|
|
16118
16049
|
Peaks.prototype.zoomIn = function () {
|
|
16119
16050
|
this.view.setZoom(this.view.getTimeToPixelsScale() + Math.floor(this.view.getTimeToPixelsScale() / 10) + 1);
|
|
16120
16051
|
};
|
|
@@ -17640,9 +17571,6 @@ module.exports = function (SegmentShape, Utils, Konva) {
|
|
|
17640
17571
|
SegmentsGroup.prototype.isEmpty = function () {
|
|
17641
17572
|
return Object.keys(this._segments).length === 0;
|
|
17642
17573
|
};
|
|
17643
|
-
SegmentsGroup.prototype.countRemainingElements = function () {
|
|
17644
|
-
return Object.keys(this._segments).length;
|
|
17645
|
-
};
|
|
17646
17574
|
SegmentsGroup.prototype.addToGroup = function (group) {
|
|
17647
17575
|
group.add(this._group);
|
|
17648
17576
|
};
|
|
@@ -18148,12 +18076,13 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Loader, Konva)
|
|
|
18148
18076
|
this._indicators = {};
|
|
18149
18077
|
var self = this;
|
|
18150
18078
|
this._x = this._view.timeToPixels(source.startTime);
|
|
18079
|
+
this._roundedX = Math.round(this._x);
|
|
18151
18080
|
this._width = this._view.timeToPixels(source.endTime - source.startTime);
|
|
18152
|
-
|
|
18153
|
-
this._unwrappedHeight =
|
|
18154
|
-
this._wrappedHeight =
|
|
18155
|
-
this._height = heights.current;
|
|
18081
|
+
this._roundedWidth = Math.round(this._width);
|
|
18082
|
+
this._unwrappedHeight = source.binaryHeight && source.previewHeight ? source.binaryHeight + source.previewHeight : this._peaks.options.lineHeight;
|
|
18083
|
+
this._wrappedHeight = this._peaks.options.wrappedLineHeight;
|
|
18156
18084
|
this._borderWidth = this._source.borderWidth || 0;
|
|
18085
|
+
this._height = this._unwrappedHeight;
|
|
18157
18086
|
this._currentTimeToPixelsScaleUsed = this._view.getTimeToPixelsScale();
|
|
18158
18087
|
this._selected = this._source.selected;
|
|
18159
18088
|
this._isDragged = false;
|
|
@@ -18174,12 +18103,14 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Loader, Konva)
|
|
|
18174
18103
|
this._group.on('dragend', this._onDragEnd.bind(this));
|
|
18175
18104
|
this._cursor = null;
|
|
18176
18105
|
this._group.on('mouseenter', function () {
|
|
18106
|
+
self._setHovered(true);
|
|
18177
18107
|
self._view.setHoveredElement(self);
|
|
18178
18108
|
if (!self._source.loading) {
|
|
18179
18109
|
self._showButtons();
|
|
18180
18110
|
}
|
|
18181
18111
|
});
|
|
18182
18112
|
this._group.on('mouseleave', function () {
|
|
18113
|
+
self._setHovered(false);
|
|
18183
18114
|
self._view.setHoveredElement(null);
|
|
18184
18115
|
self._hideButtons();
|
|
18185
18116
|
});
|
|
@@ -18217,6 +18148,10 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Loader, Konva)
|
|
|
18217
18148
|
this.createIndicators();
|
|
18218
18149
|
this.setLoadingState(this._source.loading);
|
|
18219
18150
|
}
|
|
18151
|
+
SourceGroup.prototype._setHovered = function (newValue) {
|
|
18152
|
+
this._hovered = newValue;
|
|
18153
|
+
this._group.draw();
|
|
18154
|
+
};
|
|
18220
18155
|
SourceGroup.prototype._onDragStart = function (element) {
|
|
18221
18156
|
this._isDragged = true;
|
|
18222
18157
|
this._layer.onSourcesGroupDragStart(element);
|
|
@@ -18246,10 +18181,11 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Loader, Konva)
|
|
|
18246
18181
|
const timeOffsetDiff = this._view.getTimeOffset() - this._initialTimeOffset;
|
|
18247
18182
|
const {start, end} = this._initialTimes;
|
|
18248
18183
|
this._view.updateWithAutoScroll(function () {
|
|
18249
|
-
if (this._layer.
|
|
18184
|
+
if (this._layer.updateSource(this._source, leftHandle ? start + diff + timeOffsetDiff : null, leftHandle ? null : end + diff + timeOffsetDiff)) {
|
|
18250
18185
|
this._layer.draw();
|
|
18251
18186
|
}
|
|
18252
18187
|
}.bind(this));
|
|
18188
|
+
this._view.setTimelineLength(this._view.timeToPixels(this._source.endTime) + this._view.getWidth());
|
|
18253
18189
|
return {
|
|
18254
18190
|
x: draggedElement.absolutePosition().x,
|
|
18255
18191
|
y: draggedElement.absolutePosition().y
|
|
@@ -18262,9 +18198,11 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Loader, Konva)
|
|
|
18262
18198
|
const newTimeToPixelsScale = this._view.getTimeToPixelsScale();
|
|
18263
18199
|
this._group.x(startPixel - frameOffset);
|
|
18264
18200
|
this._x = startPixel;
|
|
18201
|
+
this._roundedX = Math.round(this._x);
|
|
18265
18202
|
const newWidth = endPixel - startPixel;
|
|
18266
18203
|
if (newWidth !== this._width) {
|
|
18267
18204
|
this._width = newWidth;
|
|
18205
|
+
this._roundedWidth = Math.round(this._width);
|
|
18268
18206
|
if (newTimeToPixelsScale !== this._currentTimeToPixelsScaleUsed) {
|
|
18269
18207
|
this._currentTimeToPixelsScaleUsed = newTimeToPixelsScale;
|
|
18270
18208
|
this._updateMarkers();
|
|
@@ -18315,11 +18253,9 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Loader, Konva)
|
|
|
18315
18253
|
start: this._source.startTime,
|
|
18316
18254
|
end: this._source.endTime
|
|
18317
18255
|
};
|
|
18318
|
-
this._isDragged = true;
|
|
18319
18256
|
this._hideButtons();
|
|
18320
18257
|
};
|
|
18321
18258
|
SourceGroup.prototype._onHandleDragEnd = function () {
|
|
18322
|
-
this._isDragged = false;
|
|
18323
18259
|
this._showButtons();
|
|
18324
18260
|
};
|
|
18325
18261
|
SourceGroup.prototype._addHandles = function (forceCreate) {
|
|
@@ -18401,46 +18337,52 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Loader, Konva)
|
|
|
18401
18337
|
};
|
|
18402
18338
|
SourceGroup.prototype.drawSourceShape = function (ctx, shape, addBorderWidth, fill) {
|
|
18403
18339
|
var offset = addBorderWidth ? this._borderWidth : 0;
|
|
18404
|
-
var radius = this._source.borderRadius !== undefined && this._source.borderRadius !== null ? this._source.borderRadius : Math.max(1, Math.min(this.
|
|
18405
|
-
var x = Math.max(0, this._view.getFrameOffset() - this.
|
|
18406
|
-
var width = Math.min(this.
|
|
18340
|
+
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)));
|
|
18341
|
+
var x = Math.max(0, this._view.getFrameOffset() - this._roundedX - radius);
|
|
18342
|
+
var width = Math.min(this._roundedWidth - x, this._view.getWidth() + radius - Math.max(0, this._roundedX - this._view.getFrameOffset()));
|
|
18407
18343
|
var xWidth = x + width;
|
|
18408
|
-
|
|
18409
|
-
|
|
18410
|
-
|
|
18411
|
-
|
|
18412
|
-
|
|
18413
|
-
|
|
18414
|
-
|
|
18415
|
-
|
|
18416
|
-
|
|
18417
|
-
|
|
18418
|
-
|
|
18419
|
-
|
|
18420
|
-
|
|
18421
|
-
|
|
18422
|
-
|
|
18423
|
-
|
|
18424
|
-
|
|
18425
|
-
|
|
18426
|
-
|
|
18427
|
-
|
|
18428
|
-
|
|
18429
|
-
|
|
18430
|
-
|
|
18431
|
-
|
|
18432
|
-
|
|
18433
|
-
|
|
18434
|
-
ctx.fill();
|
|
18435
|
-
} else {
|
|
18436
|
-
ctx.fillStyle = this._source.backgroundColor;
|
|
18437
|
-
ctx.fill();
|
|
18344
|
+
ctx.beginPath();
|
|
18345
|
+
ctx.moveTo(x + radius, offset);
|
|
18346
|
+
ctx.lineTo(xWidth - radius, offset);
|
|
18347
|
+
ctx.quadraticCurveTo(xWidth - offset, offset, xWidth - offset, radius);
|
|
18348
|
+
ctx.lineTo(xWidth - offset, this._height - radius);
|
|
18349
|
+
ctx.quadraticCurveTo(xWidth - offset, this._height - offset, xWidth - radius, this._height - offset);
|
|
18350
|
+
ctx.lineTo(x + radius, this._height - offset);
|
|
18351
|
+
ctx.quadraticCurveTo(x + offset, this._height - offset, x + offset, this._height - radius);
|
|
18352
|
+
ctx.lineTo(x + offset, radius);
|
|
18353
|
+
ctx.quadraticCurveTo(x + offset, offset, x + radius, offset);
|
|
18354
|
+
ctx.closePath();
|
|
18355
|
+
if (fill) {
|
|
18356
|
+
var backgroundColor;
|
|
18357
|
+
if (this._selected) {
|
|
18358
|
+
backgroundColor = this._source.selectedBackgroundColor;
|
|
18359
|
+
} else if (this._hovered) {
|
|
18360
|
+
backgroundColor = this._source.hoverBackgroundColor;
|
|
18361
|
+
} else {
|
|
18362
|
+
backgroundColor = this._source.backgroundColor;
|
|
18363
|
+
}
|
|
18364
|
+
if (this._source.shouldShowWarning()) {
|
|
18365
|
+
var gradient = ctx.createLinearGradient(0, 0, this._roundedWidth, 0);
|
|
18366
|
+
if (this._source.mediaEndTime < this._source.duration) {
|
|
18367
|
+
var rightStopPosition = Math.max(1 - this._source.warningWidth / this._roundedWidth, 0.5);
|
|
18368
|
+
gradient.addColorStop(rightStopPosition, backgroundColor);
|
|
18369
|
+
gradient.addColorStop(1, this._source.warningColor);
|
|
18438
18370
|
}
|
|
18439
|
-
|
|
18440
|
-
|
|
18441
|
-
|
|
18371
|
+
if (this._source.mediaStartTime > 0) {
|
|
18372
|
+
var leftStopPosition = Math.min(this._source.warningWidth / this._roundedWidth, 0.5);
|
|
18373
|
+
gradient.addColorStop(0, this._source.warningColor);
|
|
18374
|
+
gradient.addColorStop(leftStopPosition, backgroundColor);
|
|
18375
|
+
}
|
|
18376
|
+
ctx.fillStyle = gradient;
|
|
18377
|
+
ctx.fill();
|
|
18378
|
+
} else {
|
|
18379
|
+
ctx.fillStyle = backgroundColor;
|
|
18380
|
+
ctx.fill();
|
|
18442
18381
|
}
|
|
18443
18382
|
}
|
|
18383
|
+
if (shape) {
|
|
18384
|
+
ctx.fillStrokeShape(shape);
|
|
18385
|
+
}
|
|
18444
18386
|
};
|
|
18445
18387
|
SourceGroup.prototype._addUnwrap = function (forceCreate) {
|
|
18446
18388
|
if (!this._unwrap || forceCreate) {
|
|
@@ -18774,7 +18716,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Loader, Konva)
|
|
|
18774
18716
|
this._selected = this._source.selected;
|
|
18775
18717
|
if (this._border) {
|
|
18776
18718
|
if (this._selected) {
|
|
18777
|
-
this._border.fill(this._source.
|
|
18719
|
+
this._border.fill(this._source.selectedBorderColor);
|
|
18778
18720
|
this._borderWidth = this._peaks.options.sourceSelectedBorderWidth;
|
|
18779
18721
|
} else {
|
|
18780
18722
|
this._border.fill(this._source.borderColor);
|
|
@@ -18787,7 +18729,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Loader, Konva)
|
|
|
18787
18729
|
})[0];
|
|
18788
18730
|
if (unwrap_background) {
|
|
18789
18731
|
if (this._selected) {
|
|
18790
|
-
unwrap_background.stroke(this._source.
|
|
18732
|
+
unwrap_background.stroke(this._source.selectedBorderColor);
|
|
18791
18733
|
unwrap_background.strokeWidth(this._peaks.options.sourceSelectedBorderWidth);
|
|
18792
18734
|
} else {
|
|
18793
18735
|
unwrap_background.strokeWidth(0);
|
|
@@ -18800,7 +18742,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Loader, Konva)
|
|
|
18800
18742
|
})[0];
|
|
18801
18743
|
if (wrap_background) {
|
|
18802
18744
|
if (this._selected) {
|
|
18803
|
-
wrap_background.stroke(this._source.
|
|
18745
|
+
wrap_background.stroke(this._source.selectedBorderColor);
|
|
18804
18746
|
wrap_background.strokeWidth(this._peaks.options.sourceSelectedBorderWidth);
|
|
18805
18747
|
} else {
|
|
18806
18748
|
wrap_background.strokeWidth(0);
|
|
@@ -18953,13 +18895,6 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Loader, Konva)
|
|
|
18953
18895
|
SourceGroup.prototype.getCurrentHeight = function () {
|
|
18954
18896
|
return this._height;
|
|
18955
18897
|
};
|
|
18956
|
-
SourceGroup.prototype.getHeights = function () {
|
|
18957
|
-
return {
|
|
18958
|
-
unwrapped: this._unwrappedHeight,
|
|
18959
|
-
wrapped: this._wrappedHeight,
|
|
18960
|
-
current: this._height
|
|
18961
|
-
};
|
|
18962
|
-
};
|
|
18963
18898
|
SourceGroup.prototype.setVisible = function (boolean) {
|
|
18964
18899
|
this._group.visible(boolean);
|
|
18965
18900
|
};
|
|
@@ -19342,16 +19277,6 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Loader, Konva)
|
|
|
19342
19277
|
}
|
|
19343
19278
|
this._group.destroy();
|
|
19344
19279
|
};
|
|
19345
|
-
SourceGroup.getHeights = function (source, peaks) {
|
|
19346
|
-
var unwrappedHeight = source.binaryHeight && source.previewHeight ? source.binaryHeight + source.previewHeight : peaks.options.lineHeight;
|
|
19347
|
-
var wrappedHeight = peaks.options.wrappedLineHeight;
|
|
19348
|
-
var height = source.wrapped ? wrappedHeight : unwrappedHeight;
|
|
19349
|
-
return {
|
|
19350
|
-
unwrapped: unwrappedHeight,
|
|
19351
|
-
wrapped: wrappedHeight,
|
|
19352
|
-
current: height
|
|
19353
|
-
};
|
|
19354
|
-
};
|
|
19355
19280
|
return SourceGroup;
|
|
19356
19281
|
}(_dereq_('./waveform-builder'), _dereq_('./waveform-shape'), _dereq_('./utils'), _dereq_('./loader'), _dereq_('konva'));
|
|
19357
19282
|
},{"./loader":94,"./utils":113,"./waveform-builder":114,"./waveform-shape":115,"konva":43}],106:[function(_dereq_,module,exports){
|
|
@@ -19434,13 +19359,23 @@ module.exports = function (Utils) {
|
|
|
19434
19359
|
if (!Utils.isValidColor(options.backgroundColor)) {
|
|
19435
19360
|
throw new TypeError('peaks.sources.' + context + ': backgroundColor should be a valid CSS color');
|
|
19436
19361
|
}
|
|
19362
|
+
if (Utils.isNullOrUndefined(options.selectedBackgroundColor)) {
|
|
19363
|
+
options.selectedBackgroundColor = options.backgroundColor;
|
|
19364
|
+
} else if (!Utils.isValidColor(options.selectedBackgroundColor)) {
|
|
19365
|
+
throw new TypeError('peaks.sources.' + context + ': selectedBackgroundColor should be a valid CSS color');
|
|
19366
|
+
}
|
|
19367
|
+
if (Utils.isNullOrUndefined(options.hoverBackgroundColor)) {
|
|
19368
|
+
options.hoverBackgroundColor = Utils.shadeColor(options.backgroundColor, 30);
|
|
19369
|
+
} else if (!Utils.isValidColor(options.hoverBackgroundColor)) {
|
|
19370
|
+
throw new TypeError('peaks.sources.' + context + ': hoverBackgroundColor should be a valid CSS color');
|
|
19371
|
+
}
|
|
19437
19372
|
if (!Utils.isValidColor(options.borderColor)) {
|
|
19438
19373
|
options.borderColor = options.color;
|
|
19439
19374
|
}
|
|
19440
|
-
if (Utils.isNullOrUndefined(options.
|
|
19441
|
-
options.
|
|
19442
|
-
} else if (!Utils.isValidColor(options.
|
|
19443
|
-
throw new TypeError('peaks.sources.' + context + ':
|
|
19375
|
+
if (Utils.isNullOrUndefined(options.selectedBorderColor)) {
|
|
19376
|
+
options.selectedBorderColor = Utils.shadeColor(options.borderColor, 30);
|
|
19377
|
+
} else if (!Utils.isValidColor(options.selectedBorderColor)) {
|
|
19378
|
+
throw new TypeError('peaks.sources.' + context + ': selectedBorderColor should be a valid CSS color');
|
|
19444
19379
|
}
|
|
19445
19380
|
if (Utils.isNullOrUndefined(options.warningColor)) {
|
|
19446
19381
|
options.warningColor = null;
|
|
@@ -19592,7 +19527,7 @@ module.exports = function (Utils) {
|
|
|
19592
19527
|
throw new TypeError('peaks.sources.' + context + ': loading must be a boolean');
|
|
19593
19528
|
}
|
|
19594
19529
|
}
|
|
19595
|
-
function Source(peaks, id, originId, elementId, title, titleAlignments, url, previewUrl, binaryUrl, kind, subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor, borderColor,
|
|
19530
|
+
function Source(peaks, id, originId, elementId, title, titleAlignments, url, previewUrl, binaryUrl, kind, subkind, duration, startTime, endTime, mediaStartTime, mediaEndTime, color, backgroundColor, hoverBackgroundColor, selectedBackgroundColor, borderColor, selectedBorderColor, warningColor, warningWidth, volumeSliderColor, volumeSliderWidth, volumeSliderDraggingWidth, textFont, textFontSize, textColor, textBackgroundColor, textPosition, textAutoScroll, borderWidth, borderRadius, wrapped, position, draggable, orderable, resizable, cuttable, deletable, wrapping, previewHeight, binaryHeight, indicators, markers, buttons, markerColor, markerWidth, volume, volumeRange, loading, ...customParams) {
|
|
19596
19531
|
var opts = {
|
|
19597
19532
|
title: title,
|
|
19598
19533
|
titleAlignments: titleAlignments,
|
|
@@ -19608,8 +19543,10 @@ module.exports = function (Utils) {
|
|
|
19608
19543
|
mediaEndTime: mediaEndTime,
|
|
19609
19544
|
color: color,
|
|
19610
19545
|
backgroundColor: backgroundColor,
|
|
19546
|
+
hoverBackgroundColor: hoverBackgroundColor,
|
|
19547
|
+
selectedBackgroundColor: selectedBackgroundColor,
|
|
19611
19548
|
borderColor: borderColor,
|
|
19612
|
-
|
|
19549
|
+
selectedBorderColor: selectedBorderColor,
|
|
19613
19550
|
warningColor: warningColor,
|
|
19614
19551
|
warningWidth: warningWidth,
|
|
19615
19552
|
textFont: textFont,
|
|
@@ -19661,8 +19598,10 @@ module.exports = function (Utils) {
|
|
|
19661
19598
|
this._mediaEndTime = opts.mediaEndTime;
|
|
19662
19599
|
this._color = opts.color;
|
|
19663
19600
|
this._backgroundColor = opts.backgroundColor;
|
|
19601
|
+
this._hoverBackgroundColor = opts.hoverBackgroundColor;
|
|
19602
|
+
this._selectedBackgroundColor = opts.selectedBackgroundColor;
|
|
19664
19603
|
this._borderColor = opts.borderColor;
|
|
19665
|
-
this.
|
|
19604
|
+
this._selectedBorderColor = opts.selectedBorderColor;
|
|
19666
19605
|
this._warningColor = opts.warningColor;
|
|
19667
19606
|
this._warningWidth = opts.warningWidth;
|
|
19668
19607
|
this._volumeSliderColor = opts.volumeSliderColor;
|
|
@@ -19828,6 +19767,24 @@ module.exports = function (Utils) {
|
|
|
19828
19767
|
this._backgroundColor = backgroundColor;
|
|
19829
19768
|
}
|
|
19830
19769
|
},
|
|
19770
|
+
hoverBackgroundColor: {
|
|
19771
|
+
enumerable: true,
|
|
19772
|
+
get: function () {
|
|
19773
|
+
return this._hoverBackgroundColor;
|
|
19774
|
+
},
|
|
19775
|
+
set: function (hoverBackgroundColor) {
|
|
19776
|
+
this._hoverBackgroundColor = hoverBackgroundColor;
|
|
19777
|
+
}
|
|
19778
|
+
},
|
|
19779
|
+
selectedBackgroundColor: {
|
|
19780
|
+
enumerable: true,
|
|
19781
|
+
get: function () {
|
|
19782
|
+
return this._selectedBackgroundColor;
|
|
19783
|
+
},
|
|
19784
|
+
set: function (selectedBackgroundColor) {
|
|
19785
|
+
this._selectedBackgroundColor = selectedBackgroundColor;
|
|
19786
|
+
}
|
|
19787
|
+
},
|
|
19831
19788
|
borderColor: {
|
|
19832
19789
|
enumerable: true,
|
|
19833
19790
|
get: function () {
|
|
@@ -19837,13 +19794,13 @@ module.exports = function (Utils) {
|
|
|
19837
19794
|
this._borderColor = borderColor;
|
|
19838
19795
|
}
|
|
19839
19796
|
},
|
|
19840
|
-
|
|
19797
|
+
selectedBorderColor: {
|
|
19841
19798
|
enumerable: true,
|
|
19842
19799
|
get: function () {
|
|
19843
|
-
return this.
|
|
19800
|
+
return this._selectedBorderColor;
|
|
19844
19801
|
},
|
|
19845
|
-
set: function (
|
|
19846
|
-
this.
|
|
19802
|
+
set: function (selectedBorderColor) {
|
|
19803
|
+
this._selectedBorderColor = selectedBorderColor;
|
|
19847
19804
|
}
|
|
19848
19805
|
},
|
|
19849
19806
|
warningColor: {
|
|
@@ -20202,8 +20159,10 @@ module.exports = function (Utils) {
|
|
|
20202
20159
|
mediaEndTime: this.mediaEndTime,
|
|
20203
20160
|
color: this.color,
|
|
20204
20161
|
backgroundColor: this.backgroundColor,
|
|
20162
|
+
hoverBackgroundColor: this.hoverBackgroundColor,
|
|
20163
|
+
selectedBackgroundColor: this.selectedBackgroundColor,
|
|
20205
20164
|
borderColor: this.borderColor,
|
|
20206
|
-
|
|
20165
|
+
selectedBorderColor: this.selectedBorderColor,
|
|
20207
20166
|
warningColor: this.warningColor,
|
|
20208
20167
|
warningWidth: this.warningWidth,
|
|
20209
20168
|
volumeSliderColor: this.volumeSliderColor,
|
|
@@ -20252,8 +20211,10 @@ module.exports = function (Utils) {
|
|
|
20252
20211
|
this._mediaEndTime = opts.mediaEndTime;
|
|
20253
20212
|
this._color = opts.color;
|
|
20254
20213
|
this._backgroundColor = opts.backgroundColor;
|
|
20214
|
+
this._hoverBackgroundColor = opts.hoverBackgroundColor;
|
|
20215
|
+
this._selectedBackgroundColor = opts.selectedBackgroundColor;
|
|
20255
20216
|
this._borderColor = opts.borderColor;
|
|
20256
|
-
this.
|
|
20217
|
+
this._selectedBorderColor = opts.selectedBorderColor;
|
|
20257
20218
|
this._warningColor = opts.warningColor;
|
|
20258
20219
|
this._warningWidth = opts.warningWidth;
|
|
20259
20220
|
this._volumeSliderColor = opts.volumeSliderColor;
|
|
@@ -20357,7 +20318,9 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
20357
20318
|
this._peaks.on('sources.setSelected', this._onSourcesSetSelected.bind(this));
|
|
20358
20319
|
this._peaks.on('source.update', this._onSourceUpdate.bind(this));
|
|
20359
20320
|
this._peaks.on('data.retrieved', this._onDataRetrieved.bind(this));
|
|
20321
|
+
this._peaks.on('sources.refresh', this._onSourcesRefresh.bind(this));
|
|
20360
20322
|
this._peaks.on('segments.show', this._onSegmentsShow.bind(this));
|
|
20323
|
+
this._peaks.on('options.set.line_height', this._onOptionsLineHeightChange.bind(this));
|
|
20361
20324
|
this._peaks.on('source.setIndicators', this.setIndicators.bind(this));
|
|
20362
20325
|
}
|
|
20363
20326
|
SourcesLayer.prototype.fitToView = function () {
|
|
@@ -20384,10 +20347,24 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
20384
20347
|
SourcesLayer.prototype.isEditingEnabled = function () {
|
|
20385
20348
|
return this._allowEditing;
|
|
20386
20349
|
};
|
|
20387
|
-
SourcesLayer.prototype.
|
|
20388
|
-
var
|
|
20389
|
-
var
|
|
20390
|
-
|
|
20350
|
+
SourcesLayer.prototype._onOptionsLineHeightChange = function (oldHeight) {
|
|
20351
|
+
var positions = [];
|
|
20352
|
+
for (var sourceId in this._sourcesGroup) {
|
|
20353
|
+
if (Utils.objectHasProperty(this._sourcesGroup, sourceId)) {
|
|
20354
|
+
var source = this._sourcesGroup[sourceId].getSource();
|
|
20355
|
+
if (!positions.includes(source.position)) {
|
|
20356
|
+
this._lines.changeLineHeight(oldHeight, this._peaks.options.lineHeight);
|
|
20357
|
+
positions.push(source.position);
|
|
20358
|
+
}
|
|
20359
|
+
this._removeSource(source);
|
|
20360
|
+
this._addSourceGroup(source);
|
|
20361
|
+
}
|
|
20362
|
+
}
|
|
20363
|
+
if (positions) {
|
|
20364
|
+
var frameOffset = this._view.getFrameOffset();
|
|
20365
|
+
var width = this._view.getWidth();
|
|
20366
|
+
this.updateSources(this._view.pixelsToTime(frameOffset), this._view.pixelsToTime(frameOffset + width));
|
|
20367
|
+
}
|
|
20391
20368
|
};
|
|
20392
20369
|
SourcesLayer.prototype._onSourceUpdate = function (source) {
|
|
20393
20370
|
var redraw = false;
|
|
@@ -20417,6 +20394,13 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
20417
20394
|
}.bind(this));
|
|
20418
20395
|
this.draw();
|
|
20419
20396
|
};
|
|
20397
|
+
SourcesLayer.prototype._onSourcesShow = function (sources) {
|
|
20398
|
+
var self = this;
|
|
20399
|
+
sources.forEach(function (source) {
|
|
20400
|
+
self._sourcesGroup[source.id].setWrapping(false, true);
|
|
20401
|
+
});
|
|
20402
|
+
this._layer.draw();
|
|
20403
|
+
};
|
|
20420
20404
|
SourcesLayer.prototype._onSourcesAdd = function (sources) {
|
|
20421
20405
|
var self = this;
|
|
20422
20406
|
var frameOffset = self._view.getFrameOffset();
|
|
@@ -20475,6 +20459,9 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
20475
20459
|
}
|
|
20476
20460
|
}
|
|
20477
20461
|
};
|
|
20462
|
+
SourcesLayer.prototype._onSourcesRefresh = function () {
|
|
20463
|
+
this._layer.draw();
|
|
20464
|
+
};
|
|
20478
20465
|
SourcesLayer.prototype._onSegmentsShow = function (lineId, position) {
|
|
20479
20466
|
this._lines.addSegments(lineId, position);
|
|
20480
20467
|
this._view.updateTimelineLength();
|
|
@@ -20486,7 +20473,7 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
20486
20473
|
SourcesLayer.prototype._addSourceGroup = function (source, startDataRetrieval = true) {
|
|
20487
20474
|
var sourceGroup = this._createSourceGroup(source);
|
|
20488
20475
|
this._sourcesGroup[source.id] = sourceGroup;
|
|
20489
|
-
this._lines.addSourceGroup(
|
|
20476
|
+
this._lines.addSourceGroup(sourceGroup, source.position);
|
|
20490
20477
|
if (startDataRetrieval) {
|
|
20491
20478
|
this._dataRetriever.retrieveData(source);
|
|
20492
20479
|
}
|
|
@@ -20513,28 +20500,20 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
20513
20500
|
SourcesLayer.prototype.onSourcesGroupDragStart = function (element) {
|
|
20514
20501
|
this._initialTimeOffset = this._view.getTimeOffset();
|
|
20515
20502
|
this._mouseDownX = this._view.getPointerPosition().x;
|
|
20503
|
+
this._activeElements = {};
|
|
20516
20504
|
const draggedElementId = element.currentTarget.attrs.sourceId;
|
|
20517
|
-
|
|
20518
|
-
|
|
20519
|
-
|
|
20520
|
-
|
|
20521
|
-
|
|
20522
|
-
|
|
20523
|
-
|
|
20524
|
-
|
|
20525
|
-
|
|
20526
|
-
bounds.initialStartTime = Math.min(source.startTime, bounds.initialStartTime);
|
|
20527
|
-
bounds.initialEndTime = Math.max(source.endTime, bounds.initialEndTime);
|
|
20528
|
-
bounds.orderable = source.orderable && bounds.orderable;
|
|
20529
|
-
return bounds;
|
|
20530
|
-
}, {
|
|
20531
|
-
initialStartTime: Infinity,
|
|
20532
|
-
initialEndTime: -Infinity,
|
|
20533
|
-
orderable: true
|
|
20534
|
-
});
|
|
20505
|
+
const shouldDragSelectedElements = Object.keys(this._view.getSelectedElements()).includes(draggedElementId);
|
|
20506
|
+
this._nonSelectedElement = shouldDragSelectedElements ? null : [this._sourcesGroup[draggedElementId].getSource()];
|
|
20507
|
+
this._isDraggable = true;
|
|
20508
|
+
(this._nonSelectedElement || Object.values(this._view.getSelectedElements())).forEach(function (source) {
|
|
20509
|
+
if (!source.draggable) {
|
|
20510
|
+
this._isDraggable = false;
|
|
20511
|
+
return;
|
|
20512
|
+
}
|
|
20513
|
+
}.bind(this));
|
|
20535
20514
|
};
|
|
20536
20515
|
SourcesLayer.prototype.onSourcesGroupDragEnd = function () {
|
|
20537
|
-
const updatedSources = this.
|
|
20516
|
+
const updatedSources = (this._nonSelectedElement || Object.values(this._view.getSelectedElements())).map(function (source) {
|
|
20538
20517
|
const sourceGroup = this._sourcesGroup[source.id];
|
|
20539
20518
|
if (sourceGroup) {
|
|
20540
20519
|
sourceGroup.prepareDragEnd();
|
|
@@ -20543,6 +20522,7 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
20543
20522
|
}.bind(this));
|
|
20544
20523
|
this._view.drawSourcesLayer();
|
|
20545
20524
|
this._view.updateTimelineLength();
|
|
20525
|
+
this._activeElements = {};
|
|
20546
20526
|
this._peaks.emit('sources.updated', updatedSources);
|
|
20547
20527
|
};
|
|
20548
20528
|
SourcesLayer.prototype.onSourcesGroupDrag = function (draggedElement) {
|
|
@@ -20554,15 +20534,28 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
20554
20534
|
};
|
|
20555
20535
|
SourcesLayer.prototype._dragSourcesGroup = function () {
|
|
20556
20536
|
var mousePos = Math.min(this._view.getWidth() - this._peaks.options.autoScrollThreshold * this._view.getWidth(), Math.max(0, this._view.getPointerPosition().x));
|
|
20557
|
-
const
|
|
20537
|
+
const diff = this._view.pixelsToTime(mousePos - this._mouseDownX);
|
|
20558
20538
|
const timeOffsetDiff = this._view.getTimeOffset() - this._initialTimeOffset;
|
|
20559
|
-
const mousePosX = this._view.getPointerPosition().x;
|
|
20560
20539
|
const mousePosY = this._view.getPointerPosition().y;
|
|
20561
|
-
|
|
20562
|
-
|
|
20540
|
+
var newEnd = 0;
|
|
20541
|
+
var shouldRedraw = false;
|
|
20542
|
+
(this._nonSelectedElement || Object.values(this._view.getSelectedElements())).forEach(function (source) {
|
|
20543
|
+
if (!this._activeElements[source.id]) {
|
|
20544
|
+
this._activeElements[source.id] = {
|
|
20545
|
+
initialStartTime: source.startTime,
|
|
20546
|
+
initialEndTime: source.endTime
|
|
20547
|
+
};
|
|
20548
|
+
}
|
|
20549
|
+
const {initialStartTime, initialEndTime} = this._activeElements[source.id];
|
|
20550
|
+
newEnd = Math.max(newEnd, source.endTime);
|
|
20551
|
+
if (this._isDraggable) {
|
|
20552
|
+
shouldRedraw = this.updateSource(source, initialStartTime + diff + timeOffsetDiff, initialEndTime + diff + timeOffsetDiff, mousePosY) || shouldRedraw;
|
|
20553
|
+
}
|
|
20554
|
+
}.bind(this));
|
|
20563
20555
|
if (shouldRedraw) {
|
|
20564
20556
|
this.draw();
|
|
20565
20557
|
}
|
|
20558
|
+
this._view.setTimelineLength(this._view.timeToPixels(newEnd) + this._view.getWidth());
|
|
20566
20559
|
};
|
|
20567
20560
|
SourcesLayer.prototype.findSources = function (startTime, endTime) {
|
|
20568
20561
|
var sources = this._peaks.sources.find(startTime, endTime);
|
|
@@ -20571,41 +20564,31 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
20571
20564
|
return positions[source.position];
|
|
20572
20565
|
});
|
|
20573
20566
|
};
|
|
20574
|
-
SourcesLayer.prototype.
|
|
20575
|
-
|
|
20576
|
-
|
|
20577
|
-
|
|
20578
|
-
|
|
20579
|
-
|
|
20580
|
-
|
|
20581
|
-
|
|
20582
|
-
|
|
20583
|
-
|
|
20584
|
-
|
|
20585
|
-
|
|
20586
|
-
|
|
20587
|
-
|
|
20588
|
-
newStartTime = typeof newStartTime === 'number' ? Utils.roundTime(newStartTime) : newStartTime;
|
|
20589
|
-
newEndTime = typeof newEndTime === 'number' ? Utils.roundTime(newEndTime) : newEndTime;
|
|
20590
|
-
if (this._peaks.options.canMoveSourcesBetweenLines && typeof mouseY === 'number') {
|
|
20591
|
-
this.manageVerticalPosition(sources, newStartTime, newEndTime, mouseX, mouseY);
|
|
20592
|
-
}
|
|
20593
|
-
if (orderable) {
|
|
20594
|
-
({newStartTime, newEndTime} = this.manageOrder(sources, newStartTime, newEndTime));
|
|
20567
|
+
SourcesLayer.prototype.updateSource = function (source, startTime, endTime, newY) {
|
|
20568
|
+
var newTimes = {
|
|
20569
|
+
start: startTime,
|
|
20570
|
+
end: endTime
|
|
20571
|
+
};
|
|
20572
|
+
if (this._peaks.options.canMoveSourcesBetweenLines) {
|
|
20573
|
+
this.manageVerticalPosition(source, newY);
|
|
20574
|
+
}
|
|
20575
|
+
newTimes = this.manageSourceOrder(source, newTimes);
|
|
20576
|
+
newTimes = this.manageCollision(source, newTimes);
|
|
20577
|
+
source.updateTimes(newTimes.start, newTimes.end);
|
|
20578
|
+
if (newTimes) {
|
|
20579
|
+
this._updateSource(source);
|
|
20580
|
+
return true;
|
|
20595
20581
|
}
|
|
20596
|
-
|
|
20597
|
-
this._applyTimeChangesToSources(sources, sources[0].startTime, newStartTime, newEndTime);
|
|
20598
|
-
this._view.setTimelineLength(this._view.timeToPixels(sources[sources.length - 1].endTime) + this._view.getWidth());
|
|
20599
|
-
return true;
|
|
20582
|
+
return false;
|
|
20600
20583
|
};
|
|
20601
|
-
SourcesLayer.prototype.manageVerticalPosition = function (
|
|
20602
|
-
return this._lines.manageVerticalPosition(
|
|
20584
|
+
SourcesLayer.prototype.manageVerticalPosition = function (source, newY) {
|
|
20585
|
+
return this._lines.manageVerticalPosition(source, newY);
|
|
20603
20586
|
};
|
|
20604
|
-
SourcesLayer.prototype.
|
|
20605
|
-
return this._lines.
|
|
20587
|
+
SourcesLayer.prototype.manageSourceOrder = function (source, newTimes) {
|
|
20588
|
+
return this._lines.manageSourceOrder(source, newTimes);
|
|
20606
20589
|
};
|
|
20607
|
-
SourcesLayer.prototype.manageCollision = function (
|
|
20608
|
-
return this._lines.manageCollision(
|
|
20590
|
+
SourcesLayer.prototype.manageCollision = function (source, newTimes) {
|
|
20591
|
+
return this._lines.manageCollision(source, newTimes);
|
|
20609
20592
|
};
|
|
20610
20593
|
SourcesLayer.prototype._updateSource = function (source) {
|
|
20611
20594
|
var sourceGroup = this._findOrAddSourceGroup(source);
|
|
@@ -20739,7 +20722,9 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
|
|
|
20739
20722
|
this._peaks.off('sources.hide', this._onSourcesHide);
|
|
20740
20723
|
this._peaks.off('source.update', this._onSourceUpdate);
|
|
20741
20724
|
this._peaks.off('data.retrieved', this._onDataRetrieved);
|
|
20725
|
+
this._peaks.off('sources.refresh', this._onSourcesRefresh);
|
|
20742
20726
|
this._peaks.off('segments.show', this._onSegmentsShow);
|
|
20727
|
+
this._peaks.off('options.set.line_height', this._onOptionsLineHeightChange);
|
|
20743
20728
|
this._peaks.off('source.setIndicators', this.setIndicators);
|
|
20744
20729
|
};
|
|
20745
20730
|
SourcesLayer.prototype.getHeight = function () {
|
|
@@ -21129,8 +21114,10 @@ module.exports = function (Source, Utils) {
|
|
|
21129
21114
|
mediaEndTime: originalMediaEndTime,
|
|
21130
21115
|
color: sourceToCut.color,
|
|
21131
21116
|
backgroundColor: sourceToCut.backgroundColor,
|
|
21117
|
+
hoverBackgroundColor: sourceToCut.hoverBackgroundColor,
|
|
21118
|
+
selectedBackgroundColor: sourceToCut.selectedBackgroundColor,
|
|
21132
21119
|
borderColor: sourceToCut.borderColor,
|
|
21133
|
-
|
|
21120
|
+
selectedBorderColor: sourceToCut.selectedBorderColor,
|
|
21134
21121
|
warningColor: sourceToCut.warningColor,
|
|
21135
21122
|
warningWidth: sourceToCut.warningWidth,
|
|
21136
21123
|
volumeSliderColor: sourceToCut.volumeSliderColor,
|
|
@@ -21190,7 +21177,7 @@ module.exports = function (Source, Utils) {
|
|
|
21190
21177
|
customParams.push(key, value);
|
|
21191
21178
|
}
|
|
21192
21179
|
});
|
|
21193
|
-
var source = new Source(this._peaks, options.id || this._getNextSourceId(), options.originId, options.elementId, options.title, options.titleAlignments, options.url, options.previewUrl, options.binaryUrl, options.kind, options.subkind, options.duration, options.startTime, options.endTime, options.mediaStartTime, options.mediaEndTime, options.color, options.backgroundColor, options.borderColor, options.
|
|
21180
|
+
var source = new Source(this._peaks, options.id || this._getNextSourceId(), options.originId, options.elementId, options.title, options.titleAlignments, options.url, options.previewUrl, options.binaryUrl, options.kind, options.subkind, options.duration, options.startTime, options.endTime, options.mediaStartTime, options.mediaEndTime, options.color, options.backgroundColor, options.hoverBackgroundColor, options.selectedBackgroundColor, options.borderColor, options.selectedBorderColor, options.warningColor, options.warningWidth, options.volumeSliderColor, options.volumeSliderWidth, options.volumeSliderDraggingWidth, options.textFont, options.textFontSize, options.textColor, options.textBackgroundColor, options.textPosition, options.textAutoScroll, options.borderWidth, options.borderRadius, options.wrapped, options.position, options.draggable, options.orderable, options.resizable, options.cuttable, options.deletable, options.wrapping, options.previewHeight, options.binaryHeight, options.indicators, options.markers, options.buttons, options.markerColor, options.markerWidth, options.volume, options.volumeRange, options.loading, ...customParams);
|
|
21194
21181
|
return source;
|
|
21195
21182
|
};
|
|
21196
21183
|
TimelineSources.prototype.getSources = function () {
|
|
@@ -21296,16 +21283,10 @@ module.exports = function (Source, Utils) {
|
|
|
21296
21283
|
}, shouldBlockEvent);
|
|
21297
21284
|
};
|
|
21298
21285
|
TimelineSources.prototype.showById = function (sourceId) {
|
|
21299
|
-
if (this._sourcesById[sourceId].wrapped === false) {
|
|
21300
|
-
return;
|
|
21301
|
-
}
|
|
21302
21286
|
this._sourcesById[sourceId].wrapped = false;
|
|
21303
21287
|
this._peaks.emit('sources.show', [this._sourcesById[sourceId]]);
|
|
21304
21288
|
};
|
|
21305
21289
|
TimelineSources.prototype.hideById = function (sourceId) {
|
|
21306
|
-
if (this._sourcesById[sourceId].wrapped === true) {
|
|
21307
|
-
return;
|
|
21308
|
-
}
|
|
21309
21290
|
this._sourcesById[sourceId].wrapped = true;
|
|
21310
21291
|
this._peaks.emit('sources.hide', [this._sourcesById[sourceId]]);
|
|
21311
21292
|
};
|
|
@@ -21580,9 +21561,6 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
|
|
|
21580
21561
|
TimelineZoomView.prototype.drawSourcesLayer = function () {
|
|
21581
21562
|
this._sourcesLayer.draw();
|
|
21582
21563
|
};
|
|
21583
|
-
TimelineZoomView.prototype.refresh = function () {
|
|
21584
|
-
this._sourcesLayer.refresh();
|
|
21585
|
-
};
|
|
21586
21564
|
TimelineZoomView.prototype.getSegmentsGroup = function () {
|
|
21587
21565
|
return this._sourcesLayer.getSegmentsGroup();
|
|
21588
21566
|
};
|