@checksub_team/peaks_timeline 1.16.0-alpha.2 → 2.0.0-alpha.0
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 +4160 -3938
- package/peaks.js.d.ts +5 -5
- package/src/{timeline-axis.js → components/axis.js} +244 -244
- package/src/{data-retriever.js → components/data-retriever.js} +117 -117
- package/src/{default-segment-marker.js → components/default-segment-marker.js} +132 -132
- package/src/{invoker.js → components/invoker.js} +81 -81
- package/src/{line.js → components/line-group.js} +192 -187
- package/src/components/line-groups.js +584 -0
- package/src/{line-indicator.js → components/line-indicator.js} +308 -293
- package/src/{marker-factories.js → components/marker-factories.js} +1 -1
- package/src/{mode-layer.js → components/mode-layer.js} +8 -12
- package/src/{playhead-layer.js → components/playhead-layer.js} +3 -3
- package/src/{segment-marker.js → components/segment-marker.js} +2 -2
- package/src/{segment-shape.js → components/segment-shape.js} +508 -508
- package/src/{segments-group.js → components/segments-group.js} +805 -805
- package/src/{source-group.js → components/source-group.js} +1641 -1645
- package/src/{sources-layer.js → components/sources-layer.js} +716 -704
- package/src/{waveform-builder.js → components/waveform-builder.js} +2 -2
- package/src/{waveform-shape.js → components/waveform-shape.js} +214 -214
- package/src/keyboard-handler.js +9 -9
- package/src/line-handler.js +179 -0
- package/src/main.js +99 -64
- package/src/models/line.js +156 -0
- package/src/{segment.js → models/segment.js} +420 -419
- package/src/{source.js → models/source.js} +1262 -1269
- package/src/player.js +2 -2
- package/src/{timeline-segments.js → segment-handler.js} +427 -435
- package/src/{timeline-sources.js → source-handler.js} +510 -512
- package/src/utils.js +5 -1
- package/src/{timeline-zoomview.js → view.js} +133 -138
- package/src/lines.js +0 -533
- /package/src/{data.js → components/data.js} +0 -0
- /package/src/{loader.js → components/loader.js} +0 -0
- /package/src/{mouse-drag-handler.js → components/mouse-drag-handler.js} +0 -0
- /package/src/{svgs.js → components/svgs.js} +0 -0
|
@@ -1,35 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file
|
|
3
3
|
*
|
|
4
|
-
* Defines the {@link
|
|
4
|
+
* Defines the {@link lineGroup} class.
|
|
5
5
|
*
|
|
6
|
-
* @module
|
|
6
|
+
* @module lineGroup
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
define([
|
|
10
10
|
'./source-group',
|
|
11
|
-
'
|
|
12
|
-
'
|
|
13
|
-
], function(SourceGroup,
|
|
11
|
+
'../utils',
|
|
12
|
+
'konva'
|
|
13
|
+
], function(SourceGroup, Utils, Konva) {
|
|
14
14
|
'use strict';
|
|
15
15
|
|
|
16
|
-
function
|
|
16
|
+
function LineGroup(peaks, view, line) {
|
|
17
17
|
this._peaks = peaks;
|
|
18
18
|
this._view = view;
|
|
19
19
|
|
|
20
|
-
this.
|
|
21
|
-
this._position =
|
|
20
|
+
this._line = line;
|
|
21
|
+
this._position = null;
|
|
22
22
|
|
|
23
23
|
this._firstSourceId = null;
|
|
24
24
|
this._sources = {};
|
|
25
25
|
|
|
26
26
|
this._sourcesGroup = {};
|
|
27
27
|
this._wrapped = false;
|
|
28
|
-
this._y = y;
|
|
29
28
|
|
|
30
29
|
this._group = new Konva.Group({
|
|
31
|
-
x: 0,
|
|
32
|
-
y: y - this._view.getFrameOffsetY(),
|
|
33
30
|
draggable: true,
|
|
34
31
|
dragBoundFunc: function() {
|
|
35
32
|
return {
|
|
@@ -44,31 +41,35 @@ define([
|
|
|
44
41
|
this._unwrappedCount = 0;
|
|
45
42
|
}
|
|
46
43
|
|
|
47
|
-
|
|
44
|
+
LineGroup.prototype.getPosition = function() {
|
|
48
45
|
return this._position;
|
|
49
46
|
};
|
|
50
47
|
|
|
51
|
-
|
|
52
|
-
return this.
|
|
48
|
+
LineGroup.prototype.getId = function() {
|
|
49
|
+
return this._line.id;
|
|
53
50
|
};
|
|
54
51
|
|
|
55
|
-
|
|
52
|
+
LineGroup.prototype.getLine = function() {
|
|
53
|
+
return this._line;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
LineGroup.prototype.countRemainingElements = function() {
|
|
56
57
|
return this.isSegmentsLine() ?
|
|
57
58
|
this._segmentsGroup.countRemainingElements() :
|
|
58
59
|
Object.keys(this._sources).length;
|
|
59
60
|
};
|
|
60
61
|
|
|
61
|
-
|
|
62
|
+
LineGroup.prototype.isSegmentsLine = function() {
|
|
62
63
|
return Boolean(this._segmentsGroup);
|
|
63
64
|
};
|
|
64
65
|
|
|
65
|
-
|
|
66
|
+
LineGroup.prototype.updateSegments = function(frameStartTime, frameEndTime) {
|
|
66
67
|
if (this.isSegmentsLine()) {
|
|
67
68
|
this._segmentsGroup.updateSegments(frameStartTime, frameEndTime);
|
|
68
69
|
}
|
|
69
70
|
};
|
|
70
71
|
|
|
71
|
-
|
|
72
|
+
LineGroup.prototype.lineLength = function() {
|
|
72
73
|
var length = 0;
|
|
73
74
|
|
|
74
75
|
if (this.isSegmentsLine()) {
|
|
@@ -90,11 +91,11 @@ define([
|
|
|
90
91
|
return length;
|
|
91
92
|
};
|
|
92
93
|
|
|
93
|
-
|
|
94
|
+
LineGroup.prototype.lineHeight = function() {
|
|
94
95
|
return this._height;
|
|
95
96
|
};
|
|
96
97
|
|
|
97
|
-
|
|
98
|
+
LineGroup.prototype._addHeight = function(height) {
|
|
98
99
|
if (this._sourceHeights[height]) {
|
|
99
100
|
this._sourceHeights[height]++;
|
|
100
101
|
}
|
|
@@ -106,7 +107,7 @@ define([
|
|
|
106
107
|
}
|
|
107
108
|
};
|
|
108
109
|
|
|
109
|
-
|
|
110
|
+
LineGroup.prototype._subtractHeight = function(height) {
|
|
110
111
|
if (Object.keys(this._sources).length === 0) {
|
|
111
112
|
this._height = this._peaks.options.emptyLineHeight;
|
|
112
113
|
this._sourceHeights = {};
|
|
@@ -131,7 +132,7 @@ define([
|
|
|
131
132
|
}
|
|
132
133
|
};
|
|
133
134
|
|
|
134
|
-
|
|
135
|
+
LineGroup.prototype.updateLineHeight = function(source, action) {
|
|
135
136
|
var oldHeight = this._height;
|
|
136
137
|
var sourceGroup = this._sourcesGroup[source.id];
|
|
137
138
|
var sourceGroupHeight;
|
|
@@ -162,16 +163,16 @@ define([
|
|
|
162
163
|
}
|
|
163
164
|
|
|
164
165
|
if (this._height !== oldHeight) {
|
|
165
|
-
this._peaks.emit('line.heightChanged', this.
|
|
166
|
+
this._peaks.emit('line.heightChanged', this._line);
|
|
166
167
|
}
|
|
167
168
|
};
|
|
168
169
|
|
|
169
|
-
|
|
170
|
-
return this.
|
|
171
|
-
&& this.
|
|
170
|
+
LineGroup.prototype.isVisible = function() {
|
|
171
|
+
return this.y() < this._view.getHeight()
|
|
172
|
+
&& this.y() + this._height > 0;
|
|
172
173
|
};
|
|
173
174
|
|
|
174
|
-
|
|
175
|
+
LineGroup.prototype.addToLayer = function(layer) {
|
|
175
176
|
layer.add(this._group);
|
|
176
177
|
};
|
|
177
178
|
|
|
@@ -181,110 +182,128 @@ define([
|
|
|
181
182
|
* @param {SourceGroup} sourceGroup - The source group of the source (optional).
|
|
182
183
|
* @returns {void}
|
|
183
184
|
*/
|
|
184
|
-
|
|
185
|
+
LineGroup.prototype.addSource = function(source, sourceGroup, sourcesAround) {
|
|
185
186
|
if (sourceGroup) {
|
|
186
187
|
this._sourcesGroup[source.id] = sourceGroup;
|
|
188
|
+
if (!sourceGroup.getParent() || !sourceGroup.isDescendantOf(this._group)) {
|
|
189
|
+
sourceGroup.moveTo(this._group);
|
|
190
|
+
}
|
|
187
191
|
}
|
|
188
192
|
|
|
189
193
|
if (!this._sources[source.id]) {
|
|
190
|
-
var
|
|
194
|
+
var sourceData = {
|
|
191
195
|
source: source,
|
|
192
196
|
prevSourceId: null,
|
|
193
197
|
nextSourceId: null
|
|
194
198
|
};
|
|
195
199
|
|
|
196
|
-
if (this._firstSourceId) {
|
|
197
|
-
|
|
200
|
+
if (Utils.isNullOrUndefined(this._firstSourceId)) {
|
|
201
|
+
this._firstSourceId = source.id;
|
|
202
|
+
this._sources[source.id] = sourceData;
|
|
203
|
+
}
|
|
204
|
+
else if (Utils.isNullOrUndefined(sourcesAround)) {
|
|
205
|
+
this._addSourceWherePossible(sourceData);
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
if (sourcesAround.left) {
|
|
209
|
+
this._sources[sourcesAround.left.id].nextSourceId = source.id;
|
|
210
|
+
sourceData.prevSourceId = sourcesAround.left.id;
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
this._firstSourceId = source.id;
|
|
214
|
+
}
|
|
215
|
+
if (sourcesAround.right) {
|
|
216
|
+
this._sources[sourcesAround.right.id].prevSourceId = source.id;
|
|
217
|
+
sourceData.nextSourceId = sourcesAround.right.id;
|
|
218
|
+
}
|
|
219
|
+
this._sources[source.id] = sourceData;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
this.updateLineHeight(source, 'add');
|
|
223
|
+
}
|
|
224
|
+
};
|
|
198
225
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
226
|
+
LineGroup.prototype._addSourceWherePossible = function(sourceData) {
|
|
227
|
+
const source = sourceData.source;
|
|
228
|
+
var currentSource = null;
|
|
229
|
+
|
|
230
|
+
do {
|
|
231
|
+
if (!currentSource) {
|
|
232
|
+
currentSource = this._sources[this._firstSourceId];
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
currentSource = this._sources[currentSource.nextSourceId];
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (source.endTime <= currentSource.source.startTime) {
|
|
239
|
+
var startLimit = currentSource.prevSourceId
|
|
240
|
+
? this._sources[currentSource.prevSourceId].source.endTime
|
|
241
|
+
: 0;
|
|
242
|
+
|
|
243
|
+
const { newStartTime, newEndTime } = this._canBePlacedBetween(
|
|
244
|
+
source.startTime,
|
|
245
|
+
source.endTime,
|
|
246
|
+
startLimit,
|
|
247
|
+
currentSource.source.startTime
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
if (!Utils.isNullOrUndefined(newStartTime) && !Utils.isNullOrUndefined(newEndTime)) {
|
|
251
|
+
source.updateTimes(newStartTime, newEndTime);
|
|
252
|
+
|
|
253
|
+
if (currentSource.prevSourceId) {
|
|
254
|
+
this._sources[currentSource.prevSourceId].nextSourceId = source.id;
|
|
255
|
+
sourceData.prevSourceId = currentSource.prevSourceId;
|
|
202
256
|
}
|
|
203
257
|
else {
|
|
204
|
-
|
|
258
|
+
this._firstSourceId = source.id;
|
|
205
259
|
}
|
|
206
260
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
? this._sources[currentSource.prevSourceId].source.endTime
|
|
210
|
-
: 0;
|
|
211
|
-
|
|
212
|
-
const { newStartTime, newEndTime } = this._canBePlacedBetween(
|
|
213
|
-
source.startTime,
|
|
214
|
-
source.endTime,
|
|
215
|
-
startLimit,
|
|
216
|
-
currentSource.source.startTime
|
|
217
|
-
);
|
|
218
|
-
|
|
219
|
-
if (newStartTime !== null && newEndTime !== null) {
|
|
220
|
-
source.updateTimes(newStartTime, newEndTime);
|
|
221
|
-
|
|
222
|
-
if (currentSource.prevSourceId) {
|
|
223
|
-
this._sources[currentSource.prevSourceId].nextSourceId = source.id;
|
|
224
|
-
newSource.prevSourceId = currentSource.prevSourceId;
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
227
|
-
this._firstSourceId = source.id;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
currentSource.prevSourceId = source.id;
|
|
231
|
-
newSource.nextSourceId = currentSource.source.id;
|
|
232
|
-
|
|
233
|
-
this._sources[source.id] = newSource;
|
|
234
|
-
break;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
} while (currentSource.nextSourceId);
|
|
261
|
+
currentSource.prevSourceId = source.id;
|
|
262
|
+
sourceData.nextSourceId = currentSource.source.id;
|
|
238
263
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
// Overlapping with last source
|
|
242
|
-
var timeWidth = source.endTime - source.startTime;
|
|
243
|
-
|
|
244
|
-
source.updateTimes(
|
|
245
|
-
currentSource.source.endTime,
|
|
246
|
-
currentSource.source.endTime + timeWidth
|
|
247
|
-
);
|
|
248
|
-
}
|
|
249
|
-
currentSource.nextSourceId = source.id;
|
|
250
|
-
newSource.prevSourceId = currentSource.source.id;
|
|
251
|
-
this._sources[source.id] = newSource;
|
|
264
|
+
this._sources[source.id] = sourceData;
|
|
265
|
+
break;
|
|
252
266
|
}
|
|
253
267
|
}
|
|
254
|
-
|
|
255
|
-
this._firstSourceId = source.id;
|
|
256
|
-
this._sources[source.id] = newSource;
|
|
257
|
-
}
|
|
268
|
+
} while (currentSource.nextSourceId);
|
|
258
269
|
|
|
259
|
-
|
|
260
|
-
|
|
270
|
+
if (!sourceData.prevSourceId && !sourceData.nextSourceId) {
|
|
271
|
+
if (source.startTime < currentSource.source.endTime) {
|
|
272
|
+
// Overlapping with last source
|
|
273
|
+
var timeWidth = source.endTime - source.startTime;
|
|
261
274
|
|
|
262
|
-
|
|
263
|
-
|
|
275
|
+
source.updateTimes(
|
|
276
|
+
currentSource.source.endTime,
|
|
277
|
+
currentSource.source.endTime + timeWidth
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
currentSource.nextSourceId = source.id;
|
|
281
|
+
sourceData.prevSourceId = currentSource.source.id;
|
|
282
|
+
this._sources[source.id] = sourceData;
|
|
264
283
|
}
|
|
265
284
|
};
|
|
266
285
|
|
|
267
|
-
|
|
286
|
+
LineGroup.prototype.addSegments = function(segmentsGroup) {
|
|
268
287
|
this._segmentsGroup = segmentsGroup;
|
|
269
288
|
|
|
270
289
|
this._height = this._segmentsGroup.getCurrentHeight();
|
|
271
290
|
|
|
272
|
-
segmentsGroup.
|
|
291
|
+
segmentsGroup.moveTo(this._group);
|
|
273
292
|
};
|
|
274
293
|
|
|
275
|
-
|
|
294
|
+
LineGroup.prototype.refreshSegmentsHeight = function() {
|
|
276
295
|
if (this.isSegmentsLine) {
|
|
277
296
|
var oldHeight = this._height;
|
|
278
297
|
|
|
279
298
|
this._height = this._segmentsGroup.getCurrentHeight();
|
|
280
299
|
|
|
281
300
|
if (this._height !== oldHeight) {
|
|
282
|
-
this._peaks.emit('line.heightChanged', this.
|
|
301
|
+
this._peaks.emit('line.heightChanged', this._line);
|
|
283
302
|
}
|
|
284
303
|
}
|
|
285
304
|
};
|
|
286
305
|
|
|
287
|
-
|
|
306
|
+
LineGroup.prototype._canBePlacedBetween = function(startTime, endTime, startLimit, endLimit) {
|
|
288
307
|
var timeWidth = Utils.roundTime(endTime - startTime);
|
|
289
308
|
var newStartTime, newEndTime;
|
|
290
309
|
|
|
@@ -308,68 +327,61 @@ define([
|
|
|
308
327
|
return { newStartTime, newEndTime };
|
|
309
328
|
};
|
|
310
329
|
|
|
311
|
-
|
|
312
|
-
|
|
330
|
+
LineGroup.prototype.removeSourceGroup = function(source) {
|
|
331
|
+
const sourceGroup = this._sourcesGroup[source.id];
|
|
313
332
|
|
|
314
333
|
delete this._sourcesGroup[source.id];
|
|
315
334
|
|
|
316
|
-
if (
|
|
317
|
-
|
|
335
|
+
if (sourceGroup) {
|
|
336
|
+
sourceGroup.hideButKeepFocus();
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
return sourceGroup;
|
|
340
|
+
};
|
|
318
341
|
|
|
319
|
-
|
|
342
|
+
LineGroup.prototype.removeSource = function(source) {
|
|
343
|
+
const sourceGroup = this.removeSourceGroup(source);
|
|
320
344
|
|
|
321
|
-
|
|
322
|
-
setTimeout(function() {
|
|
323
|
-
this._peaks.emit('line.remove', this._position);
|
|
324
|
-
}.bind(this), 0);
|
|
325
|
-
return sourceGroup;
|
|
326
|
-
}
|
|
345
|
+
var sourceData = this._sources[source.id];
|
|
327
346
|
|
|
328
|
-
|
|
329
|
-
this._sources[sourceData.prevSourceId].nextSourceId
|
|
330
|
-
= sourceData.nextSourceId;
|
|
331
|
-
}
|
|
347
|
+
delete this._sources[source.id];
|
|
332
348
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
349
|
+
if (Object.keys(this._sources).length === 0) {
|
|
350
|
+
this._peaks.destroyLine(this._line.id, true);
|
|
351
|
+
return sourceGroup;
|
|
352
|
+
}
|
|
337
353
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
354
|
+
if (sourceData.prevSourceId) {
|
|
355
|
+
this._sources[sourceData.prevSourceId].nextSourceId
|
|
356
|
+
= sourceData.nextSourceId;
|
|
357
|
+
}
|
|
341
358
|
|
|
342
|
-
|
|
359
|
+
if (sourceData.nextSourceId) {
|
|
360
|
+
this._sources[sourceData.nextSourceId].prevSourceId
|
|
361
|
+
= sourceData.prevSourceId;
|
|
343
362
|
}
|
|
344
363
|
|
|
345
|
-
|
|
346
|
-
|
|
364
|
+
if (this._firstSourceId === source.id) {
|
|
365
|
+
this._firstSourceId = sourceData.nextSourceId;
|
|
366
|
+
}
|
|
347
367
|
|
|
348
|
-
|
|
349
|
-
return this._group;
|
|
350
|
-
};
|
|
368
|
+
this.updateLineHeight(source, 'remove');
|
|
351
369
|
|
|
352
|
-
|
|
353
|
-
return this._group.y();
|
|
370
|
+
return sourceGroup;
|
|
354
371
|
};
|
|
355
372
|
|
|
356
|
-
|
|
357
|
-
return this.
|
|
373
|
+
LineGroup.prototype.getKonvaGroup = function() {
|
|
374
|
+
return this._group;
|
|
358
375
|
};
|
|
359
376
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
this._y = value;
|
|
377
|
+
LineGroup.prototype.y = function(value) {
|
|
378
|
+
if (typeof value !== 'number') {
|
|
379
|
+
return this._group.y();
|
|
364
380
|
}
|
|
381
|
+
this._group.y(value);
|
|
365
382
|
};
|
|
366
383
|
|
|
367
|
-
|
|
368
|
-
this._y += dy;
|
|
369
|
-
this._group.y(this._group.y() + dy);
|
|
370
|
-
};
|
|
371
|
-
|
|
372
|
-
Line.prototype.manageOrder = function(sources, startTime, endTime) {
|
|
384
|
+
LineGroup.prototype.manageOrder = function(sources, startTime, endTime) {
|
|
373
385
|
const firstSource = sources[0];
|
|
374
386
|
const lastSource = sources[sources.length - 1];
|
|
375
387
|
const cursorTime = this._view.pixelsToTime(this._view.getPointerPosition().x);
|
|
@@ -422,7 +434,7 @@ define([
|
|
|
422
434
|
return { newStartTime, newEndTime };
|
|
423
435
|
};
|
|
424
436
|
|
|
425
|
-
|
|
437
|
+
LineGroup.prototype._changeSourcesPosition = function(sources, sourceDuration, time) {
|
|
426
438
|
var currentRange = {
|
|
427
439
|
start: null,
|
|
428
440
|
end: null
|
|
@@ -481,7 +493,7 @@ define([
|
|
|
481
493
|
return { newStartTime, newEndTime };
|
|
482
494
|
};
|
|
483
495
|
|
|
484
|
-
|
|
496
|
+
LineGroup.prototype._moveSource = function(source, prevSourceId) {
|
|
485
497
|
// Remove source from the list
|
|
486
498
|
var sourceObj = this._sources[source.id];
|
|
487
499
|
var prevSource = this._sources[sourceObj.prevSourceId];
|
|
@@ -519,7 +531,7 @@ define([
|
|
|
519
531
|
this._sources[source.id] = sourceObj;
|
|
520
532
|
};
|
|
521
533
|
|
|
522
|
-
|
|
534
|
+
LineGroup.prototype.manageCollision = function(sources, newStartTime, newEndTime) {
|
|
523
535
|
var originalStartTime = newStartTime;
|
|
524
536
|
var originalEndTime = newEndTime;
|
|
525
537
|
var startLimited = false;
|
|
@@ -529,42 +541,36 @@ define([
|
|
|
529
541
|
|
|
530
542
|
if (typeof newStartTime === 'number') {
|
|
531
543
|
// startMarker changed
|
|
532
|
-
if (firstSource.
|
|
533
|
-
//
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
newStartTime = previousSource.endTime;
|
|
542
|
-
startLimited = true;
|
|
543
|
-
}
|
|
544
|
+
if (this._sources[firstSource.id].prevSourceId) {
|
|
545
|
+
// there is another source to the left
|
|
546
|
+
var previousSource = this._sources[this._sources[firstSource.id].prevSourceId]
|
|
547
|
+
.source;
|
|
548
|
+
|
|
549
|
+
if (newStartTime < previousSource.endTime) {
|
|
550
|
+
// there is collision
|
|
551
|
+
newStartTime = previousSource.endTime;
|
|
552
|
+
startLimited = true;
|
|
544
553
|
}
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
554
|
+
}
|
|
555
|
+
else {
|
|
556
|
+
if (newStartTime < 0) {
|
|
557
|
+
newStartTime = 0;
|
|
558
|
+
startLimited = true;
|
|
550
559
|
}
|
|
551
560
|
}
|
|
552
561
|
}
|
|
553
562
|
|
|
554
563
|
if (typeof newEndTime === 'number') {
|
|
555
564
|
// endMarker changed
|
|
556
|
-
if (lastSource.
|
|
557
|
-
//
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
newEndTime = nextSource.startTime;
|
|
566
|
-
endLimited = true;
|
|
567
|
-
}
|
|
565
|
+
if (this._sources[lastSource.id].nextSourceId) {
|
|
566
|
+
// there is another source to the right
|
|
567
|
+
var nextSource = this._sources[this._sources[lastSource.id].nextSourceId]
|
|
568
|
+
.source;
|
|
569
|
+
|
|
570
|
+
if (newEndTime > nextSource.startTime) {
|
|
571
|
+
// there is collision
|
|
572
|
+
newEndTime = nextSource.startTime;
|
|
573
|
+
endLimited = true;
|
|
568
574
|
}
|
|
569
575
|
}
|
|
570
576
|
}
|
|
@@ -608,37 +614,37 @@ define([
|
|
|
608
614
|
return { newStartTime, newEndTime };
|
|
609
615
|
};
|
|
610
616
|
|
|
611
|
-
|
|
617
|
+
LineGroup.prototype.getSourcesAfter = function(time) {
|
|
612
618
|
const sources = [];
|
|
613
619
|
var currentId = this._firstSourceId;
|
|
614
620
|
|
|
615
621
|
while (currentId) {
|
|
616
|
-
var
|
|
622
|
+
var sourceData = this._sources[currentId];
|
|
617
623
|
|
|
618
|
-
if (
|
|
624
|
+
if (sourceData.source.startTime >= time) {
|
|
619
625
|
while (currentId) {
|
|
620
|
-
|
|
626
|
+
sourceData = this._sources[currentId];
|
|
621
627
|
|
|
622
|
-
sources.push(
|
|
623
|
-
currentId =
|
|
628
|
+
sources.push(sourceData.source);
|
|
629
|
+
currentId = sourceData.nextSourceId;
|
|
624
630
|
}
|
|
625
631
|
break;
|
|
626
632
|
}
|
|
627
|
-
currentId =
|
|
633
|
+
currentId = sourceData.nextSourceId;
|
|
628
634
|
}
|
|
629
635
|
|
|
630
636
|
return sources;
|
|
631
637
|
};
|
|
632
638
|
|
|
633
|
-
|
|
639
|
+
LineGroup.prototype.getSourcesAround = function(time) {
|
|
634
640
|
var left = null;
|
|
635
641
|
var right = null;
|
|
636
642
|
var overlapping = null;
|
|
637
643
|
var currentId = this._firstSourceId;
|
|
638
644
|
|
|
639
645
|
while (currentId) {
|
|
640
|
-
var
|
|
641
|
-
var source =
|
|
646
|
+
var sourceData = this._sources[currentId];
|
|
647
|
+
var source = sourceData.source;
|
|
642
648
|
|
|
643
649
|
if (time < source.startTime) {
|
|
644
650
|
right = source;
|
|
@@ -651,7 +657,7 @@ define([
|
|
|
651
657
|
else {
|
|
652
658
|
left = source;
|
|
653
659
|
}
|
|
654
|
-
currentId =
|
|
660
|
+
currentId = sourceData.nextSourceId;
|
|
655
661
|
}
|
|
656
662
|
|
|
657
663
|
if (overlapping) {
|
|
@@ -662,26 +668,25 @@ define([
|
|
|
662
668
|
}
|
|
663
669
|
};
|
|
664
670
|
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
if (Utils.objectHasProperty(this._sources, sourceId)) {
|
|
668
|
-
this._sources[sourceId].source.position = pos;
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
|
|
671
|
+
LineGroup.prototype.updatePosition = function(pos) {
|
|
672
|
+
this._line.position = pos;
|
|
672
673
|
this._position = pos;
|
|
673
674
|
};
|
|
674
675
|
|
|
675
|
-
|
|
676
|
+
LineGroup.prototype.hasSource = function(sourceId) {
|
|
677
|
+
return Boolean(this._sources[sourceId]);
|
|
678
|
+
};
|
|
679
|
+
|
|
680
|
+
LineGroup.prototype.destroy = function() {
|
|
676
681
|
this._firstSourceId = null;
|
|
677
682
|
this._sources = {};
|
|
678
683
|
this._sourcesGroup = {};
|
|
679
684
|
this._group.destroy();
|
|
680
685
|
};
|
|
681
686
|
|
|
682
|
-
|
|
687
|
+
LineGroup.prototype.allowInteractions = function(bool) {
|
|
683
688
|
this._group.listening(bool);
|
|
684
689
|
};
|
|
685
690
|
|
|
686
|
-
return
|
|
691
|
+
return LineGroup;
|
|
687
692
|
});
|