@checksub_team/peaks_timeline 1.16.1 → 2.0.0-alpha.10

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.
Files changed (37) hide show
  1. package/package.json +1 -1
  2. package/peaks.js +4691 -4380
  3. package/peaks.js.d.ts +5 -5
  4. package/src/{timeline-axis.js → components/axis.js} +244 -244
  5. package/src/{data-retriever.js → components/data-retriever.js} +117 -117
  6. package/src/{default-segment-marker.js → components/default-segment-marker.js} +132 -132
  7. package/src/{invoker.js → components/invoker.js} +81 -81
  8. package/src/components/line-group.js +696 -0
  9. package/src/components/line-groups.js +591 -0
  10. package/src/{line-indicator.js → components/line-indicator.js} +313 -303
  11. package/src/{marker-factories.js → components/marker-factories.js} +1 -1
  12. package/src/{mode-layer.js → components/mode-layer.js} +8 -12
  13. package/src/{playhead-layer.js → components/playhead-layer.js} +3 -3
  14. package/src/{segment-marker.js → components/segment-marker.js} +2 -2
  15. package/src/{segment-shape.js → components/segment-shape.js} +508 -508
  16. package/src/{segments-group.js → components/segments-group.js} +805 -801
  17. package/src/{source-group.js → components/source-group.js} +1663 -1640
  18. package/src/{sources-layer.js → components/sources-layer.js} +722 -730
  19. package/src/{waveform-builder.js → components/waveform-builder.js} +2 -2
  20. package/src/{waveform-shape.js → components/waveform-shape.js} +214 -214
  21. package/src/keyboard-handler.js +9 -9
  22. package/src/line-handler.js +180 -0
  23. package/src/main.js +109 -82
  24. package/src/models/line.js +156 -0
  25. package/src/{segment.js → models/segment.js} +420 -419
  26. package/src/{source.js → models/source.js} +1311 -1315
  27. package/src/player.js +2 -2
  28. package/src/{timeline-segments.js → segment-handler.js} +435 -435
  29. package/src/{timeline-sources.js → source-handler.js} +521 -514
  30. package/src/utils.js +5 -1
  31. package/src/{timeline-zoomview.js → view.js} +136 -143
  32. package/src/line.js +0 -690
  33. package/src/lines.js +0 -427
  34. /package/src/{data.js → components/data.js} +0 -0
  35. /package/src/{loader.js → components/loader.js} +0 -0
  36. /package/src/{mouse-drag-handler.js → components/mouse-drag-handler.js} +0 -0
  37. /package/src/{svgs.js → components/svgs.js} +0 -0
@@ -0,0 +1,696 @@
1
+ /**
2
+ * @file
3
+ *
4
+ * Defines the {@link lineGroup} class.
5
+ *
6
+ * @module lineGroup
7
+ */
8
+
9
+ define([
10
+ './source-group',
11
+ '../utils',
12
+ 'konva'
13
+ ], function(SourceGroup, Utils, Konva) {
14
+ 'use strict';
15
+
16
+ function LineGroup(peaks, view, line) {
17
+ this._peaks = peaks;
18
+ this._view = view;
19
+
20
+ this._line = line;
21
+ this._position = null;
22
+
23
+ this._firstSourceId = null;
24
+ this._sources = {};
25
+
26
+ this._sourcesGroup = {};
27
+ this._wrapped = false;
28
+
29
+ this._group = new Konva.Group({
30
+ draggable: true,
31
+ dragBoundFunc: function() {
32
+ return {
33
+ x: this.absolutePosition().x,
34
+ y: this.absolutePosition().y
35
+ };
36
+ }
37
+ });
38
+
39
+ this._sourceHeights = {};
40
+ this._height = this._peaks.options.emptyLineHeight;
41
+ this._unwrappedCount = 0;
42
+ }
43
+
44
+ LineGroup.prototype.getPosition = function() {
45
+ return this._position;
46
+ };
47
+
48
+ LineGroup.prototype.getId = function() {
49
+ return this._line.id;
50
+ };
51
+
52
+ LineGroup.prototype.isLocked = function() {
53
+ return this._line.locked;
54
+ };
55
+
56
+ LineGroup.prototype.getLine = function() {
57
+ return this._line;
58
+ };
59
+
60
+ LineGroup.prototype.countRemainingElements = function() {
61
+ return this.isSegmentsLine() ?
62
+ this._segmentsGroup.countRemainingElements() :
63
+ Object.keys(this._sources).length;
64
+ };
65
+
66
+ LineGroup.prototype.isSegmentsLine = function() {
67
+ return Boolean(this._segmentsGroup);
68
+ };
69
+
70
+ LineGroup.prototype.updateSegments = function(frameStartTime, frameEndTime) {
71
+ if (this.isSegmentsLine()) {
72
+ this._segmentsGroup.updateSegments(frameStartTime, frameEndTime);
73
+ }
74
+ };
75
+
76
+ LineGroup.prototype.lineLength = function() {
77
+ var length = 0;
78
+
79
+ if (this.isSegmentsLine()) {
80
+ return this._segmentsGroup.getSegmentsGroupLength();
81
+ }
82
+
83
+ for (var sourceId in this._sources) {
84
+ if (Utils.objectHasProperty(this._sources, sourceId)) {
85
+ var sourceGroupLength = this._view.timeToPixels(
86
+ this._sources[sourceId].source.endTime
87
+ );
88
+
89
+ if (sourceGroupLength > length) {
90
+ length = sourceGroupLength;
91
+ }
92
+ }
93
+ }
94
+
95
+ return length;
96
+ };
97
+
98
+ LineGroup.prototype.lineHeight = function() {
99
+ return this._height;
100
+ };
101
+
102
+ LineGroup.prototype._addHeight = function(height) {
103
+ if (this._sourceHeights[height]) {
104
+ this._sourceHeights[height]++;
105
+ }
106
+ else {
107
+ this._sourceHeights[height] = 1;
108
+ if (height > this._height) {
109
+ this._height = height;
110
+ }
111
+ }
112
+ };
113
+
114
+ LineGroup.prototype._subtractHeight = function(height) {
115
+ if (Object.keys(this._sources).length === 0) {
116
+ this._height = this._peaks.options.emptyLineHeight;
117
+ this._sourceHeights = {};
118
+ }
119
+ else {
120
+ this._sourceHeights[height]--;
121
+
122
+ if (this._sourceHeights[height] === 0
123
+ && height === this._height) {
124
+ delete this._sourceHeights[height];
125
+ this._height = 0;
126
+ for (var sourceHeight in this._sourceHeights) {
127
+ if (Utils.objectHasProperty(this._sourceHeights, sourceHeight)) {
128
+ var parsedHeight = parseInt(sourceHeight, 10);
129
+
130
+ if (parsedHeight > this._height) {
131
+ this._height = parsedHeight;
132
+ }
133
+ }
134
+ }
135
+ }
136
+ }
137
+ };
138
+
139
+ LineGroup.prototype.updateLineHeight = function(source, action) {
140
+ var oldHeight = this._height;
141
+ var sourceGroup = this._sourcesGroup[source.id];
142
+ var sourceGroupHeight;
143
+
144
+ switch (action) {
145
+ case 'add':
146
+ sourceGroupHeight = sourceGroup ?
147
+ sourceGroup.getCurrentHeight() :
148
+ SourceGroup.getHeights(source, this._peaks).current;
149
+
150
+ this._addHeight(sourceGroupHeight);
151
+ break;
152
+ case 'remove':
153
+ sourceGroupHeight = sourceGroup ?
154
+ sourceGroup.getCurrentHeight() :
155
+ SourceGroup.getHeights(source, this._peaks).current;
156
+
157
+ this._subtractHeight(sourceGroupHeight);
158
+ break;
159
+ default:
160
+ // wrappingChanged
161
+ var { unwrapped, wrapped } = sourceGroup ?
162
+ sourceGroup.getHeights() :
163
+ SourceGroup.getHeights(source, this._peaks);
164
+
165
+ this._addHeight(source.wrapped ? wrapped : unwrapped);
166
+ this._subtractHeight(source.wrapped ? unwrapped : wrapped);
167
+ }
168
+
169
+ if (this._height !== oldHeight) {
170
+ this._peaks.emit('line.heightChanged', this._line);
171
+ }
172
+ };
173
+
174
+ LineGroup.prototype.isVisible = function() {
175
+ return this.y() < this._view.getHeight()
176
+ && this.y() + this._height > 0;
177
+ };
178
+
179
+ LineGroup.prototype.addToLayer = function(layer) {
180
+ layer.add(this._group);
181
+ };
182
+
183
+ /**
184
+ * Adds a source to the line.
185
+ * @param {Source} source - The source to add.
186
+ * @param {SourceGroup} sourceGroup - The source group of the source (optional).
187
+ * @returns {void}
188
+ */
189
+ LineGroup.prototype.addSource = function(source, sourceGroup, sourcesAround) {
190
+ if (sourceGroup) {
191
+ this._sourcesGroup[source.id] = sourceGroup;
192
+ if (!sourceGroup.getParent() || !sourceGroup.isDescendantOf(this._group)) {
193
+ sourceGroup.moveTo(this._group);
194
+ }
195
+ }
196
+
197
+ if (!this._sources[source.id]) {
198
+ var sourceData = {
199
+ source: source,
200
+ prevSourceId: null,
201
+ nextSourceId: null
202
+ };
203
+
204
+ if (Utils.isNullOrUndefined(this._firstSourceId)) {
205
+ this._firstSourceId = source.id;
206
+ this._sources[source.id] = sourceData;
207
+ }
208
+ else if (Utils.isNullOrUndefined(sourcesAround)) {
209
+ this._addSourceWherePossible(sourceData);
210
+ }
211
+ else {
212
+ if (sourcesAround.left) {
213
+ this._sources[sourcesAround.left.id].nextSourceId = source.id;
214
+ sourceData.prevSourceId = sourcesAround.left.id;
215
+ }
216
+ else {
217
+ this._firstSourceId = source.id;
218
+ }
219
+ if (sourcesAround.right) {
220
+ this._sources[sourcesAround.right.id].prevSourceId = source.id;
221
+ sourceData.nextSourceId = sourcesAround.right.id;
222
+ }
223
+ this._sources[source.id] = sourceData;
224
+ }
225
+
226
+ this.updateLineHeight(source, 'add');
227
+ }
228
+ };
229
+
230
+ LineGroup.prototype._addSourceWherePossible = function(sourceData) {
231
+ const source = sourceData.source;
232
+ var currentSource = null;
233
+
234
+ do {
235
+ if (!currentSource) {
236
+ currentSource = this._sources[this._firstSourceId];
237
+ }
238
+ else {
239
+ currentSource = this._sources[currentSource.nextSourceId];
240
+ }
241
+
242
+ if (source.endTime <= currentSource.source.startTime) {
243
+ var startLimit = currentSource.prevSourceId
244
+ ? this._sources[currentSource.prevSourceId].source.endTime
245
+ : 0;
246
+
247
+ const { newStartTime, newEndTime } = this._canBePlacedBetween(
248
+ source.startTime,
249
+ source.endTime,
250
+ startLimit,
251
+ currentSource.source.startTime
252
+ );
253
+
254
+ if (!Utils.isNullOrUndefined(newStartTime) && !Utils.isNullOrUndefined(newEndTime)) {
255
+ source.updateTimes(newStartTime, newEndTime);
256
+
257
+ if (currentSource.prevSourceId) {
258
+ this._sources[currentSource.prevSourceId].nextSourceId = source.id;
259
+ sourceData.prevSourceId = currentSource.prevSourceId;
260
+ }
261
+ else {
262
+ this._firstSourceId = source.id;
263
+ }
264
+
265
+ currentSource.prevSourceId = source.id;
266
+ sourceData.nextSourceId = currentSource.source.id;
267
+
268
+ this._sources[source.id] = sourceData;
269
+ break;
270
+ }
271
+ }
272
+ } while (currentSource.nextSourceId);
273
+
274
+ if (!sourceData.prevSourceId && !sourceData.nextSourceId) {
275
+ if (source.startTime < currentSource.source.endTime) {
276
+ // Overlapping with last source
277
+ var timeWidth = source.endTime - source.startTime;
278
+
279
+ source.updateTimes(
280
+ currentSource.source.endTime,
281
+ currentSource.source.endTime + timeWidth
282
+ );
283
+ }
284
+ currentSource.nextSourceId = source.id;
285
+ sourceData.prevSourceId = currentSource.source.id;
286
+ this._sources[source.id] = sourceData;
287
+ }
288
+ };
289
+
290
+ LineGroup.prototype.addSegments = function(segmentsGroup) {
291
+ this._segmentsGroup = segmentsGroup;
292
+
293
+ this._height = this._segmentsGroup.getCurrentHeight();
294
+
295
+ segmentsGroup.moveTo(this._group);
296
+ };
297
+
298
+ LineGroup.prototype.refreshSegmentsHeight = function() {
299
+ if (this.isSegmentsLine) {
300
+ var oldHeight = this._height;
301
+
302
+ this._height = this._segmentsGroup.getCurrentHeight();
303
+
304
+ if (this._height !== oldHeight) {
305
+ this._peaks.emit('line.heightChanged', this._line);
306
+ }
307
+ }
308
+ };
309
+
310
+ LineGroup.prototype._canBePlacedBetween = function(startTime, endTime, startLimit, endLimit) {
311
+ var timeWidth = Utils.roundTime(endTime - startTime);
312
+ var newStartTime, newEndTime;
313
+
314
+ if ((!endLimit && startTime > startLimit) || (startTime > startLimit && endTime < endLimit)) {
315
+ // Can be placed at its wanted position with wanted start/end time
316
+ newStartTime = startTime;
317
+ newEndTime = endTime;
318
+ }
319
+ else if (Utils.roundTime(endLimit - startLimit) >= timeWidth) {
320
+ // Can be placed at its wanted position but not with its wanted start/end time
321
+ if (startTime > startLimit) {
322
+ newStartTime = Utils.roundTime(endLimit - timeWidth);
323
+ newEndTime = endLimit;
324
+ }
325
+ else {
326
+ newStartTime = startLimit;
327
+ newEndTime = Utils.roundTime(startLimit + timeWidth);
328
+ }
329
+ }
330
+
331
+ return { newStartTime, newEndTime };
332
+ };
333
+
334
+ LineGroup.prototype.removeSourceGroup = function(source) {
335
+ const sourceGroup = this._sourcesGroup[source.id];
336
+
337
+ delete this._sourcesGroup[source.id];
338
+
339
+ if (sourceGroup) {
340
+ sourceGroup.hideButKeepFocus();
341
+ }
342
+
343
+ return sourceGroup;
344
+ };
345
+
346
+ LineGroup.prototype.removeSource = function(source) {
347
+ const sourceGroup = this.removeSourceGroup(source);
348
+
349
+ var sourceData = this._sources[source.id];
350
+
351
+ delete this._sources[source.id];
352
+
353
+ if (Object.keys(this._sources).length === 0) {
354
+ this._peaks.destroyLine(this._line.id, true);
355
+ return sourceGroup;
356
+ }
357
+
358
+ if (sourceData.prevSourceId) {
359
+ this._sources[sourceData.prevSourceId].nextSourceId
360
+ = sourceData.nextSourceId;
361
+ }
362
+
363
+ if (sourceData.nextSourceId) {
364
+ this._sources[sourceData.nextSourceId].prevSourceId
365
+ = sourceData.prevSourceId;
366
+ }
367
+
368
+ if (this._firstSourceId === source.id) {
369
+ this._firstSourceId = sourceData.nextSourceId;
370
+ }
371
+
372
+ this.updateLineHeight(source, 'remove');
373
+
374
+ return sourceGroup;
375
+ };
376
+
377
+ LineGroup.prototype.getKonvaGroup = function() {
378
+ return this._group;
379
+ };
380
+
381
+ LineGroup.prototype.y = function(value) {
382
+ if (typeof value !== 'number') {
383
+ return this._group.y();
384
+ }
385
+ this._group.y(value);
386
+ };
387
+
388
+ LineGroup.prototype.manageOrder = function(sources, startTime, endTime) {
389
+ const firstSource = sources[0];
390
+ const lastSource = sources[sources.length - 1];
391
+ const cursorTime = this._view.pixelsToTime(this._view.getPointerPosition().x);
392
+ var newStartTime = startTime;
393
+ var newEndTime = endTime;
394
+ var tmpTimes;
395
+
396
+ var sourceDuration = Utils.roundTime(endTime - startTime);
397
+
398
+ if (typeof newStartTime === 'number' && typeof newEndTime === 'number') {
399
+ if (this._sources[firstSource.id].prevSourceId) {
400
+ // there is another source to the left
401
+ var previousStartTime = this._sources[this._sources[firstSource.id].prevSourceId].source.startTime;
402
+
403
+ if (Utils.roundTime(cursorTime + this._view.getTimeOffset()) < previousStartTime) {
404
+ // we want to change order
405
+ tmpTimes = this._changeSourcesPosition(
406
+ sources,
407
+ sourceDuration,
408
+ cursorTime + this._view.getTimeOffset()
409
+ );
410
+
411
+ if (typeof tmpTimes.newStartTime === 'number' && typeof tmpTimes.newEndTime === 'number') {
412
+ newStartTime = tmpTimes.newStartTime;
413
+ newEndTime = tmpTimes.newEndTime;
414
+ }
415
+ }
416
+ }
417
+
418
+ if (this._sources[lastSource.id].nextSourceId) {
419
+ // there is another source to the right
420
+ var nextEndTime = this._sources[this._sources[lastSource.id].nextSourceId].source.endTime;
421
+
422
+ if (Utils.roundTime(cursorTime + this._view.getTimeOffset()) > nextEndTime) {
423
+ // we want to change order
424
+ tmpTimes = this._changeSourcesPosition(
425
+ sources,
426
+ sourceDuration,
427
+ cursorTime + this._view.getTimeOffset()
428
+ );
429
+
430
+ if (typeof tmpTimes.newStartTime === 'number' && typeof tmpTimes.newEndTime === 'number') {
431
+ newStartTime = tmpTimes.newStartTime;
432
+ newEndTime = tmpTimes.newEndTime;
433
+ }
434
+ }
435
+ }
436
+ }
437
+
438
+ return { newStartTime, newEndTime };
439
+ };
440
+
441
+ LineGroup.prototype._changeSourcesPosition = function(sources, sourceDuration, time) {
442
+ var currentRange = {
443
+ start: null,
444
+ end: null
445
+ };
446
+ var startLimit = null;
447
+ var endLimit = null;
448
+
449
+ let newStartTime, newEndTime;
450
+
451
+ do {
452
+ if (!currentRange.end) {
453
+ currentRange.end = this._sources[this._firstSourceId];
454
+ }
455
+ else {
456
+ currentRange.start = currentRange.end;
457
+ currentRange.end = this._sources[currentRange.start.nextSourceId];
458
+ }
459
+
460
+ if (currentRange.start) {
461
+ startLimit = currentRange.start.source.endTime;
462
+ }
463
+ else {
464
+ startLimit = 0;
465
+ }
466
+
467
+ if (currentRange.end) {
468
+ endLimit = currentRange.end.source.startTime;
469
+ }
470
+ else {
471
+ endLimit = null;
472
+ }
473
+
474
+ if (time > startLimit && (endLimit === null || time < endLimit)) {
475
+ ({ newStartTime, newEndTime } = this._canBePlacedBetween(
476
+ time,
477
+ time + sourceDuration,
478
+ startLimit,
479
+ endLimit
480
+ ));
481
+
482
+ if (typeof newStartTime === 'number' && typeof newEndTime === 'number') {
483
+ let prevSourceId = currentRange.start
484
+ ? currentRange.start.source.id
485
+ : null;
486
+
487
+ sources.forEach(function(source) {
488
+ this._moveSource(this._sources[source.id].source, prevSourceId);
489
+ prevSourceId = source.id;
490
+ }.bind(this));
491
+ }
492
+
493
+ return { newStartTime, newEndTime };
494
+ }
495
+ } while (currentRange.end);
496
+
497
+ return { newStartTime, newEndTime };
498
+ };
499
+
500
+ LineGroup.prototype._moveSource = function(source, prevSourceId) {
501
+ // Remove source from the list
502
+ var sourceObj = this._sources[source.id];
503
+ var prevSource = this._sources[sourceObj.prevSourceId];
504
+ var nextSource = this._sources[sourceObj.nextSourceId];
505
+
506
+ if (prevSource) {
507
+ this._sources[sourceObj.prevSourceId].nextSourceId = sourceObj.nextSourceId;
508
+ }
509
+ else {
510
+ this._firstSourceId = sourceObj.nextSourceId;
511
+ }
512
+
513
+ if (nextSource) {
514
+ this._sources[sourceObj.nextSourceId].prevSourceId = sourceObj.prevSourceId;
515
+ }
516
+
517
+ delete this._sources[source.id];
518
+
519
+ // Add source back to the list
520
+ sourceObj.prevSourceId = prevSourceId;
521
+
522
+ if (prevSourceId) {
523
+ sourceObj.nextSourceId = this._sources[prevSourceId].nextSourceId;
524
+ this._sources[prevSourceId].nextSourceId = source.id;
525
+ }
526
+ else {
527
+ sourceObj.nextSourceId = this._firstSourceId;
528
+ this._firstSourceId = source.id;
529
+ }
530
+
531
+ if (sourceObj.nextSourceId) {
532
+ this._sources[sourceObj.nextSourceId].prevSourceId = source.id;
533
+ }
534
+
535
+ this._sources[source.id] = sourceObj;
536
+ };
537
+
538
+ LineGroup.prototype.manageCollision = function(sources, newStartTime, newEndTime) {
539
+ var originalStartTime = newStartTime;
540
+ var originalEndTime = newEndTime;
541
+ var startLimited = false;
542
+ var endLimited = false;
543
+ const firstSource = sources[0];
544
+ const lastSource = sources[sources.length - 1];
545
+
546
+ if (typeof newStartTime === 'number') {
547
+ // startMarker changed
548
+ if (this._sources[firstSource.id].prevSourceId) {
549
+ // there is another source to the left
550
+ var previousSource = this._sources[this._sources[firstSource.id].prevSourceId]
551
+ .source;
552
+
553
+ if (newStartTime < previousSource.endTime) {
554
+ // there is collision
555
+ newStartTime = previousSource.endTime;
556
+ startLimited = true;
557
+ }
558
+ }
559
+ else {
560
+ if (newStartTime < 0) {
561
+ newStartTime = 0;
562
+ startLimited = true;
563
+ }
564
+ }
565
+ }
566
+
567
+ if (typeof newEndTime === 'number') {
568
+ // endMarker changed
569
+ if (this._sources[lastSource.id].nextSourceId) {
570
+ // there is another source to the right
571
+ var nextSource = this._sources[this._sources[lastSource.id].nextSourceId]
572
+ .source;
573
+
574
+ if (newEndTime > nextSource.startTime) {
575
+ // there is collision
576
+ newEndTime = nextSource.startTime;
577
+ endLimited = true;
578
+ }
579
+ }
580
+ }
581
+
582
+ // Update the other edge if dragging and collision
583
+ if (typeof newStartTime === 'number' && typeof newEndTime === 'number') {
584
+ var timeWidth = originalEndTime - originalStartTime;
585
+
586
+ if (startLimited) {
587
+ newEndTime = Utils.roundTime(newStartTime + timeWidth);
588
+ }
589
+
590
+ if (endLimited) {
591
+ newStartTime = Utils.roundTime(newEndTime - timeWidth);
592
+ }
593
+ }
594
+
595
+ // Check for minimal size of source
596
+ // We assume that only 1 source can be resized at a time
597
+ if (typeof newStartTime === 'number' && typeof newEndTime !== 'number') {
598
+ if (Utils.roundTime(sources[0].endTime - newStartTime) < sources[0].minSize) {
599
+ newStartTime = Utils.roundTime(sources[0].endTime - sources[0].minSize);
600
+ }
601
+ }
602
+ else if (typeof newEndTime === 'number' && typeof newStartTime !== 'number') {
603
+ if (Utils.roundTime(newEndTime - sources[0].startTime) < sources[0].minSize) {
604
+ newEndTime = Utils.roundTime(sources[0].startTime + sources[0].minSize);
605
+ }
606
+ }
607
+ else {
608
+ if (Utils.roundTime(newEndTime - newStartTime) < sources[0].minSize) {
609
+ if (sources[0].endTime !== newEndTime) {
610
+ newEndTime = Utils.roundTime(newStartTime + sources[0].minSize);
611
+ }
612
+ if (sources[0].startTime !== newStartTime) {
613
+ newStartTime = Utils.roundTime(newEndTime - sources[0].minSize);
614
+ }
615
+ }
616
+ }
617
+
618
+ return { newStartTime, newEndTime };
619
+ };
620
+
621
+ LineGroup.prototype.getSourcesAfter = function(time) {
622
+ const sources = [];
623
+ var currentId = this._firstSourceId;
624
+
625
+ while (currentId) {
626
+ var sourceData = this._sources[currentId];
627
+
628
+ if (sourceData.source.startTime >= time) {
629
+ while (currentId) {
630
+ sourceData = this._sources[currentId];
631
+
632
+ sources.push(sourceData.source);
633
+ currentId = sourceData.nextSourceId;
634
+ }
635
+ break;
636
+ }
637
+ currentId = sourceData.nextSourceId;
638
+ }
639
+
640
+ return sources;
641
+ };
642
+
643
+ LineGroup.prototype.getSourcesAround = function(time) {
644
+ var left = null;
645
+ var right = null;
646
+ var overlapping = null;
647
+ var currentId = this._firstSourceId;
648
+
649
+ while (currentId) {
650
+ var sourceData = this._sources[currentId];
651
+ var source = sourceData.source;
652
+
653
+ if (time < source.startTime) {
654
+ right = source;
655
+ break;
656
+ }
657
+ else if (time >= source.startTime && time <= source.endTime) {
658
+ overlapping = source;
659
+ break;
660
+ }
661
+ else {
662
+ left = source;
663
+ }
664
+ currentId = sourceData.nextSourceId;
665
+ }
666
+
667
+ if (overlapping) {
668
+ return { overlapping: overlapping };
669
+ }
670
+ else {
671
+ return { left: left, right: right };
672
+ }
673
+ };
674
+
675
+ LineGroup.prototype.updatePosition = function(pos) {
676
+ this._line.position = pos;
677
+ this._position = pos;
678
+ };
679
+
680
+ LineGroup.prototype.hasSource = function(sourceId) {
681
+ return Boolean(this._sources[sourceId]);
682
+ };
683
+
684
+ LineGroup.prototype.destroy = function() {
685
+ this._firstSourceId = null;
686
+ this._sources = {};
687
+ this._sourcesGroup = {};
688
+ this._group.destroy();
689
+ };
690
+
691
+ LineGroup.prototype.allowInteractions = function(bool) {
692
+ this._group.listening(bool);
693
+ };
694
+
695
+ return LineGroup;
696
+ });