@checksub_team/peaks_timeline 1.16.1 → 2.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/package.json +1 -1
  2. package/peaks.js +4716 -4409
  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 +692 -0
  9. package/src/components/line-groups.js +585 -0
  10. package/src/{line-indicator.js → components/line-indicator.js} +308 -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} +1661 -1640
  18. package/src/{sources-layer.js → components/sources-layer.js} +716 -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 +179 -0
  23. package/src/main.js +110 -71
  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 -137
  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,692 @@
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.getLine = function() {
53
+ return this._line;
54
+ };
55
+
56
+ LineGroup.prototype.countRemainingElements = function() {
57
+ return this.isSegmentsLine() ?
58
+ this._segmentsGroup.countRemainingElements() :
59
+ Object.keys(this._sources).length;
60
+ };
61
+
62
+ LineGroup.prototype.isSegmentsLine = function() {
63
+ return Boolean(this._segmentsGroup);
64
+ };
65
+
66
+ LineGroup.prototype.updateSegments = function(frameStartTime, frameEndTime) {
67
+ if (this.isSegmentsLine()) {
68
+ this._segmentsGroup.updateSegments(frameStartTime, frameEndTime);
69
+ }
70
+ };
71
+
72
+ LineGroup.prototype.lineLength = function() {
73
+ var length = 0;
74
+
75
+ if (this.isSegmentsLine()) {
76
+ return this._segmentsGroup.getSegmentsGroupLength();
77
+ }
78
+
79
+ for (var sourceId in this._sources) {
80
+ if (Utils.objectHasProperty(this._sources, sourceId)) {
81
+ var sourceGroupLength = this._view.timeToPixels(
82
+ this._sources[sourceId].source.endTime
83
+ );
84
+
85
+ if (sourceGroupLength > length) {
86
+ length = sourceGroupLength;
87
+ }
88
+ }
89
+ }
90
+
91
+ return length;
92
+ };
93
+
94
+ LineGroup.prototype.lineHeight = function() {
95
+ return this._height;
96
+ };
97
+
98
+ LineGroup.prototype._addHeight = function(height) {
99
+ if (this._sourceHeights[height]) {
100
+ this._sourceHeights[height]++;
101
+ }
102
+ else {
103
+ this._sourceHeights[height] = 1;
104
+ if (height > this._height) {
105
+ this._height = height;
106
+ }
107
+ }
108
+ };
109
+
110
+ LineGroup.prototype._subtractHeight = function(height) {
111
+ if (Object.keys(this._sources).length === 0) {
112
+ this._height = this._peaks.options.emptyLineHeight;
113
+ this._sourceHeights = {};
114
+ }
115
+ else {
116
+ this._sourceHeights[height]--;
117
+
118
+ if (this._sourceHeights[height] === 0
119
+ && height === this._height) {
120
+ delete this._sourceHeights[height];
121
+ this._height = 0;
122
+ for (var sourceHeight in this._sourceHeights) {
123
+ if (Utils.objectHasProperty(this._sourceHeights, sourceHeight)) {
124
+ var parsedHeight = parseInt(sourceHeight, 10);
125
+
126
+ if (parsedHeight > this._height) {
127
+ this._height = parsedHeight;
128
+ }
129
+ }
130
+ }
131
+ }
132
+ }
133
+ };
134
+
135
+ LineGroup.prototype.updateLineHeight = function(source, action) {
136
+ var oldHeight = this._height;
137
+ var sourceGroup = this._sourcesGroup[source.id];
138
+ var sourceGroupHeight;
139
+
140
+ switch (action) {
141
+ case 'add':
142
+ sourceGroupHeight = sourceGroup ?
143
+ sourceGroup.getCurrentHeight() :
144
+ SourceGroup.getHeights(source, this._peaks).current;
145
+
146
+ this._addHeight(sourceGroupHeight);
147
+ break;
148
+ case 'remove':
149
+ sourceGroupHeight = sourceGroup ?
150
+ sourceGroup.getCurrentHeight() :
151
+ SourceGroup.getHeights(source, this._peaks).current;
152
+
153
+ this._subtractHeight(sourceGroupHeight);
154
+ break;
155
+ default:
156
+ // wrappingChanged
157
+ var { unwrapped, wrapped } = sourceGroup ?
158
+ sourceGroup.getHeights() :
159
+ SourceGroup.getHeights(source, this._peaks);
160
+
161
+ this._addHeight(source.wrapped ? wrapped : unwrapped);
162
+ this._subtractHeight(source.wrapped ? unwrapped : wrapped);
163
+ }
164
+
165
+ if (this._height !== oldHeight) {
166
+ this._peaks.emit('line.heightChanged', this._line);
167
+ }
168
+ };
169
+
170
+ LineGroup.prototype.isVisible = function() {
171
+ return this.y() < this._view.getHeight()
172
+ && this.y() + this._height > 0;
173
+ };
174
+
175
+ LineGroup.prototype.addToLayer = function(layer) {
176
+ layer.add(this._group);
177
+ };
178
+
179
+ /**
180
+ * Adds a source to the line.
181
+ * @param {Source} source - The source to add.
182
+ * @param {SourceGroup} sourceGroup - The source group of the source (optional).
183
+ * @returns {void}
184
+ */
185
+ LineGroup.prototype.addSource = function(source, sourceGroup, sourcesAround) {
186
+ if (sourceGroup) {
187
+ this._sourcesGroup[source.id] = sourceGroup;
188
+ if (!sourceGroup.getParent() || !sourceGroup.isDescendantOf(this._group)) {
189
+ sourceGroup.moveTo(this._group);
190
+ }
191
+ }
192
+
193
+ if (!this._sources[source.id]) {
194
+ var sourceData = {
195
+ source: source,
196
+ prevSourceId: null,
197
+ nextSourceId: null
198
+ };
199
+
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
+ };
225
+
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;
256
+ }
257
+ else {
258
+ this._firstSourceId = source.id;
259
+ }
260
+
261
+ currentSource.prevSourceId = source.id;
262
+ sourceData.nextSourceId = currentSource.source.id;
263
+
264
+ this._sources[source.id] = sourceData;
265
+ break;
266
+ }
267
+ }
268
+ } while (currentSource.nextSourceId);
269
+
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;
274
+
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;
283
+ }
284
+ };
285
+
286
+ LineGroup.prototype.addSegments = function(segmentsGroup) {
287
+ this._segmentsGroup = segmentsGroup;
288
+
289
+ this._height = this._segmentsGroup.getCurrentHeight();
290
+
291
+ segmentsGroup.moveTo(this._group);
292
+ };
293
+
294
+ LineGroup.prototype.refreshSegmentsHeight = function() {
295
+ if (this.isSegmentsLine) {
296
+ var oldHeight = this._height;
297
+
298
+ this._height = this._segmentsGroup.getCurrentHeight();
299
+
300
+ if (this._height !== oldHeight) {
301
+ this._peaks.emit('line.heightChanged', this._line);
302
+ }
303
+ }
304
+ };
305
+
306
+ LineGroup.prototype._canBePlacedBetween = function(startTime, endTime, startLimit, endLimit) {
307
+ var timeWidth = Utils.roundTime(endTime - startTime);
308
+ var newStartTime, newEndTime;
309
+
310
+ if ((!endLimit && startTime > startLimit) || (startTime > startLimit && endTime < endLimit)) {
311
+ // Can be placed at its wanted position with wanted start/end time
312
+ newStartTime = startTime;
313
+ newEndTime = endTime;
314
+ }
315
+ else if (Utils.roundTime(endLimit - startLimit) >= timeWidth) {
316
+ // Can be placed at its wanted position but not with its wanted start/end time
317
+ if (startTime > startLimit) {
318
+ newStartTime = Utils.roundTime(endLimit - timeWidth);
319
+ newEndTime = endLimit;
320
+ }
321
+ else {
322
+ newStartTime = startLimit;
323
+ newEndTime = Utils.roundTime(startLimit + timeWidth);
324
+ }
325
+ }
326
+
327
+ return { newStartTime, newEndTime };
328
+ };
329
+
330
+ LineGroup.prototype.removeSourceGroup = function(source) {
331
+ const sourceGroup = this._sourcesGroup[source.id];
332
+
333
+ delete this._sourcesGroup[source.id];
334
+
335
+ if (sourceGroup) {
336
+ sourceGroup.hideButKeepFocus();
337
+ }
338
+
339
+ return sourceGroup;
340
+ };
341
+
342
+ LineGroup.prototype.removeSource = function(source) {
343
+ const sourceGroup = this.removeSourceGroup(source);
344
+
345
+ var sourceData = this._sources[source.id];
346
+
347
+ delete this._sources[source.id];
348
+
349
+ if (Object.keys(this._sources).length === 0) {
350
+ this._peaks.destroyLine(this._line.id, true);
351
+ return sourceGroup;
352
+ }
353
+
354
+ if (sourceData.prevSourceId) {
355
+ this._sources[sourceData.prevSourceId].nextSourceId
356
+ = sourceData.nextSourceId;
357
+ }
358
+
359
+ if (sourceData.nextSourceId) {
360
+ this._sources[sourceData.nextSourceId].prevSourceId
361
+ = sourceData.prevSourceId;
362
+ }
363
+
364
+ if (this._firstSourceId === source.id) {
365
+ this._firstSourceId = sourceData.nextSourceId;
366
+ }
367
+
368
+ this.updateLineHeight(source, 'remove');
369
+
370
+ return sourceGroup;
371
+ };
372
+
373
+ LineGroup.prototype.getKonvaGroup = function() {
374
+ return this._group;
375
+ };
376
+
377
+ LineGroup.prototype.y = function(value) {
378
+ if (typeof value !== 'number') {
379
+ return this._group.y();
380
+ }
381
+ this._group.y(value);
382
+ };
383
+
384
+ LineGroup.prototype.manageOrder = function(sources, startTime, endTime) {
385
+ const firstSource = sources[0];
386
+ const lastSource = sources[sources.length - 1];
387
+ const cursorTime = this._view.pixelsToTime(this._view.getPointerPosition().x);
388
+ var newStartTime = startTime;
389
+ var newEndTime = endTime;
390
+ var tmpTimes;
391
+
392
+ var sourceDuration = Utils.roundTime(endTime - startTime);
393
+
394
+ if (typeof newStartTime === 'number' && typeof newEndTime === 'number') {
395
+ if (this._sources[firstSource.id].prevSourceId) {
396
+ // there is another source to the left
397
+ var previousStartTime = this._sources[this._sources[firstSource.id].prevSourceId].source.startTime;
398
+
399
+ if (Utils.roundTime(cursorTime + this._view.getTimeOffset()) < previousStartTime) {
400
+ // we want to change order
401
+ tmpTimes = this._changeSourcesPosition(
402
+ sources,
403
+ sourceDuration,
404
+ cursorTime + this._view.getTimeOffset()
405
+ );
406
+
407
+ if (typeof tmpTimes.newStartTime === 'number' && typeof tmpTimes.newEndTime === 'number') {
408
+ newStartTime = tmpTimes.newStartTime;
409
+ newEndTime = tmpTimes.newEndTime;
410
+ }
411
+ }
412
+ }
413
+
414
+ if (this._sources[lastSource.id].nextSourceId) {
415
+ // there is another source to the right
416
+ var nextEndTime = this._sources[this._sources[lastSource.id].nextSourceId].source.endTime;
417
+
418
+ if (Utils.roundTime(cursorTime + this._view.getTimeOffset()) > nextEndTime) {
419
+ // we want to change order
420
+ tmpTimes = this._changeSourcesPosition(
421
+ sources,
422
+ sourceDuration,
423
+ cursorTime + this._view.getTimeOffset()
424
+ );
425
+
426
+ if (typeof tmpTimes.newStartTime === 'number' && typeof tmpTimes.newEndTime === 'number') {
427
+ newStartTime = tmpTimes.newStartTime;
428
+ newEndTime = tmpTimes.newEndTime;
429
+ }
430
+ }
431
+ }
432
+ }
433
+
434
+ return { newStartTime, newEndTime };
435
+ };
436
+
437
+ LineGroup.prototype._changeSourcesPosition = function(sources, sourceDuration, time) {
438
+ var currentRange = {
439
+ start: null,
440
+ end: null
441
+ };
442
+ var startLimit = null;
443
+ var endLimit = null;
444
+
445
+ let newStartTime, newEndTime;
446
+
447
+ do {
448
+ if (!currentRange.end) {
449
+ currentRange.end = this._sources[this._firstSourceId];
450
+ }
451
+ else {
452
+ currentRange.start = currentRange.end;
453
+ currentRange.end = this._sources[currentRange.start.nextSourceId];
454
+ }
455
+
456
+ if (currentRange.start) {
457
+ startLimit = currentRange.start.source.endTime;
458
+ }
459
+ else {
460
+ startLimit = 0;
461
+ }
462
+
463
+ if (currentRange.end) {
464
+ endLimit = currentRange.end.source.startTime;
465
+ }
466
+ else {
467
+ endLimit = null;
468
+ }
469
+
470
+ if (time > startLimit && (endLimit === null || time < endLimit)) {
471
+ ({ newStartTime, newEndTime } = this._canBePlacedBetween(
472
+ time,
473
+ time + sourceDuration,
474
+ startLimit,
475
+ endLimit
476
+ ));
477
+
478
+ if (typeof newStartTime === 'number' && typeof newEndTime === 'number') {
479
+ let prevSourceId = currentRange.start
480
+ ? currentRange.start.source.id
481
+ : null;
482
+
483
+ sources.forEach(function(source) {
484
+ this._moveSource(this._sources[source.id].source, prevSourceId);
485
+ prevSourceId = source.id;
486
+ }.bind(this));
487
+ }
488
+
489
+ return { newStartTime, newEndTime };
490
+ }
491
+ } while (currentRange.end);
492
+
493
+ return { newStartTime, newEndTime };
494
+ };
495
+
496
+ LineGroup.prototype._moveSource = function(source, prevSourceId) {
497
+ // Remove source from the list
498
+ var sourceObj = this._sources[source.id];
499
+ var prevSource = this._sources[sourceObj.prevSourceId];
500
+ var nextSource = this._sources[sourceObj.nextSourceId];
501
+
502
+ if (prevSource) {
503
+ this._sources[sourceObj.prevSourceId].nextSourceId = sourceObj.nextSourceId;
504
+ }
505
+ else {
506
+ this._firstSourceId = sourceObj.nextSourceId;
507
+ }
508
+
509
+ if (nextSource) {
510
+ this._sources[sourceObj.nextSourceId].prevSourceId = sourceObj.prevSourceId;
511
+ }
512
+
513
+ delete this._sources[source.id];
514
+
515
+ // Add source back to the list
516
+ sourceObj.prevSourceId = prevSourceId;
517
+
518
+ if (prevSourceId) {
519
+ sourceObj.nextSourceId = this._sources[prevSourceId].nextSourceId;
520
+ this._sources[prevSourceId].nextSourceId = source.id;
521
+ }
522
+ else {
523
+ sourceObj.nextSourceId = this._firstSourceId;
524
+ this._firstSourceId = source.id;
525
+ }
526
+
527
+ if (sourceObj.nextSourceId) {
528
+ this._sources[sourceObj.nextSourceId].prevSourceId = source.id;
529
+ }
530
+
531
+ this._sources[source.id] = sourceObj;
532
+ };
533
+
534
+ LineGroup.prototype.manageCollision = function(sources, newStartTime, newEndTime) {
535
+ var originalStartTime = newStartTime;
536
+ var originalEndTime = newEndTime;
537
+ var startLimited = false;
538
+ var endLimited = false;
539
+ const firstSource = sources[0];
540
+ const lastSource = sources[sources.length - 1];
541
+
542
+ if (typeof newStartTime === 'number') {
543
+ // startMarker changed
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;
553
+ }
554
+ }
555
+ else {
556
+ if (newStartTime < 0) {
557
+ newStartTime = 0;
558
+ startLimited = true;
559
+ }
560
+ }
561
+ }
562
+
563
+ if (typeof newEndTime === 'number') {
564
+ // endMarker changed
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;
574
+ }
575
+ }
576
+ }
577
+
578
+ // Update the other edge if dragging and collision
579
+ if (typeof newStartTime === 'number' && typeof newEndTime === 'number') {
580
+ var timeWidth = originalEndTime - originalStartTime;
581
+
582
+ if (startLimited) {
583
+ newEndTime = Utils.roundTime(newStartTime + timeWidth);
584
+ }
585
+
586
+ if (endLimited) {
587
+ newStartTime = Utils.roundTime(newEndTime - timeWidth);
588
+ }
589
+ }
590
+
591
+ // Check for minimal size of source
592
+ // We assume that only 1 source can be resized at a time
593
+ if (typeof newStartTime === 'number' && typeof newEndTime !== 'number') {
594
+ if (Utils.roundTime(sources[0].endTime - newStartTime) < sources[0].minSize) {
595
+ newStartTime = Utils.roundTime(sources[0].endTime - sources[0].minSize);
596
+ }
597
+ }
598
+ else if (typeof newEndTime === 'number' && typeof newStartTime !== 'number') {
599
+ if (Utils.roundTime(newEndTime - sources[0].startTime) < sources[0].minSize) {
600
+ newEndTime = Utils.roundTime(sources[0].startTime + sources[0].minSize);
601
+ }
602
+ }
603
+ else {
604
+ if (Utils.roundTime(newEndTime - newStartTime) < sources[0].minSize) {
605
+ if (sources[0].endTime !== newEndTime) {
606
+ newEndTime = Utils.roundTime(newStartTime + sources[0].minSize);
607
+ }
608
+ if (sources[0].startTime !== newStartTime) {
609
+ newStartTime = Utils.roundTime(newEndTime - sources[0].minSize);
610
+ }
611
+ }
612
+ }
613
+
614
+ return { newStartTime, newEndTime };
615
+ };
616
+
617
+ LineGroup.prototype.getSourcesAfter = function(time) {
618
+ const sources = [];
619
+ var currentId = this._firstSourceId;
620
+
621
+ while (currentId) {
622
+ var sourceData = this._sources[currentId];
623
+
624
+ if (sourceData.source.startTime >= time) {
625
+ while (currentId) {
626
+ sourceData = this._sources[currentId];
627
+
628
+ sources.push(sourceData.source);
629
+ currentId = sourceData.nextSourceId;
630
+ }
631
+ break;
632
+ }
633
+ currentId = sourceData.nextSourceId;
634
+ }
635
+
636
+ return sources;
637
+ };
638
+
639
+ LineGroup.prototype.getSourcesAround = function(time) {
640
+ var left = null;
641
+ var right = null;
642
+ var overlapping = null;
643
+ var currentId = this._firstSourceId;
644
+
645
+ while (currentId) {
646
+ var sourceData = this._sources[currentId];
647
+ var source = sourceData.source;
648
+
649
+ if (time < source.startTime) {
650
+ right = source;
651
+ break;
652
+ }
653
+ else if (time >= source.startTime && time <= source.endTime) {
654
+ overlapping = source;
655
+ break;
656
+ }
657
+ else {
658
+ left = source;
659
+ }
660
+ currentId = sourceData.nextSourceId;
661
+ }
662
+
663
+ if (overlapping) {
664
+ return { overlapping: overlapping };
665
+ }
666
+ else {
667
+ return { left: left, right: right };
668
+ }
669
+ };
670
+
671
+ LineGroup.prototype.updatePosition = function(pos) {
672
+ this._line.position = pos;
673
+ this._position = pos;
674
+ };
675
+
676
+ LineGroup.prototype.hasSource = function(sourceId) {
677
+ return Boolean(this._sources[sourceId]);
678
+ };
679
+
680
+ LineGroup.prototype.destroy = function() {
681
+ this._firstSourceId = null;
682
+ this._sources = {};
683
+ this._sourcesGroup = {};
684
+ this._group.destroy();
685
+ };
686
+
687
+ LineGroup.prototype.allowInteractions = function(bool) {
688
+ this._group.listening(bool);
689
+ };
690
+
691
+ return LineGroup;
692
+ });