@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.
@@ -118,6 +118,16 @@ define([
118
118
  this.draw();
119
119
  };
120
120
 
121
+ LineIndicator.prototype._showMenu = function(menu) {
122
+ menu.style.display = 'block';
123
+ var containerRect = this._stage.container().getBoundingClientRect();
124
+
125
+ menu.style.top = containerRect.top
126
+ + this._stage.getPointerPosition().y
127
+ - menu.offsetHeight + 'px';
128
+ menu.style.left = containerRect.left + this._stage.getPointerPosition().x + 6 + 'px';
129
+ };
130
+
121
131
  LineIndicator.prototype._createIndicator = function(line, type, text) {
122
132
  var indicator = new Konva.Group();
123
133
  var indicatorHeight = 0;
package/src/line.js CHANGED
@@ -7,10 +7,9 @@
7
7
  */
8
8
 
9
9
  define([
10
- './source-group',
11
10
  'konva',
12
11
  './utils'
13
- ], function(SourceGroup, Konva, Utils) {
12
+ ], function(Konva, Utils) {
14
13
  'use strict';
15
14
 
16
15
  function Line(peaks, view, y, id, position) {
@@ -52,10 +51,10 @@ define([
52
51
  return this._id;
53
52
  };
54
53
 
55
- Line.prototype.countRemainingElements = function() {
54
+ Line.prototype.isEmpty = function() {
56
55
  return this.isSegmentsLine() ?
57
- this._segmentsGroup.countRemainingElements() :
58
- Object.keys(this._sources).length;
56
+ this._segmentsGroup.isEmpty() :
57
+ Object.keys(this._sources).length === 0;
59
58
  };
60
59
 
61
60
  Line.prototype.isSegmentsLine = function() {
@@ -94,71 +93,87 @@ define([
94
93
  return this._height;
95
94
  };
96
95
 
97
- Line.prototype._addHeight = function(height) {
98
- if (this._sourceHeights[height]) {
99
- this._sourceHeights[height]++;
100
- }
101
- else {
102
- this._sourceHeights[height] = 1;
103
- if (height > this._height) {
104
- this._height = height;
105
- }
106
- }
107
- };
96
+ Line.prototype.changeHeight = function(from, to) {
97
+ if (this._sourceHeights[from]) {
98
+ var oldHeight = this._height;
108
99
 
109
- Line.prototype._subtractHeight = function(height) {
110
- if (Object.keys(this._sources).length === 0) {
111
- this._height = this._peaks.options.emptyLineHeight;
112
- this._sourceHeights = {};
113
- }
114
- else {
115
- this._sourceHeights[height]--;
100
+ if (this._sourceHeights[to]) {
101
+ this._sourceHeights[to] += this._sourceHeights[from];
102
+ }
103
+ else {
104
+ this._sourceHeights[to] = this._sourceHeights[from];
105
+ }
116
106
 
117
- if (this._sourceHeights[height] === 0
118
- && height === this._height) {
119
- delete this._sourceHeights[height];
107
+ if (to > this._height) {
108
+ this._height = to;
109
+ }
110
+ else if (from === this._height) {
120
111
  this._height = 0;
121
- for (var sourceHeight in this._sourceHeights) {
122
- if (Utils.objectHasProperty(this._sourceHeights, sourceHeight)) {
123
- var parsedHeight = parseInt(sourceHeight, 10);
112
+ for (var height in this._sourceHeights) {
113
+ if (Utils.objectHasProperty(this._sourceHeights, height)) {
114
+ var parsedHeight = parseInt(height, 10);
124
115
 
125
- if (parsedHeight > this._height) {
126
- this._height = parsedHeight;
116
+ if (parsedHeight !== from) {
117
+ if (parsedHeight > this._height) {
118
+ this._height = parsedHeight;
119
+ }
127
120
  }
128
121
  }
129
122
  }
130
123
  }
124
+
125
+ if (this._height !== oldHeight) {
126
+ this._peaks.emit('line.heightChanged', this._position);
127
+ }
128
+
129
+ delete this._sourceHeights[from];
131
130
  }
132
131
  };
133
132
 
134
- Line.prototype.updateLineHeight = function(source, action) {
133
+ Line.prototype.updateLineHeight = function(sourceGroup, action) {
135
134
  var oldHeight = this._height;
136
- var sourceGroup = this._sourcesGroup[source.id];
137
135
  var sourceGroupHeight;
138
136
 
139
137
  switch (action) {
140
138
  case 'add':
141
- sourceGroupHeight = sourceGroup ?
142
- sourceGroup.getCurrentHeight() :
143
- SourceGroup.getHeights(source, this._peaks).current;
139
+ sourceGroupHeight = sourceGroup.getCurrentHeight();
144
140
 
145
- this._addHeight(sourceGroupHeight);
141
+ if (this._sourceHeights[sourceGroupHeight]) {
142
+ this._sourceHeights[sourceGroupHeight]++;
143
+ }
144
+ else {
145
+ this._sourceHeights[sourceGroupHeight] = 1;
146
+ if (sourceGroupHeight > this._height) {
147
+ this._height = sourceGroupHeight;
148
+ }
149
+ }
146
150
  break;
147
151
  case 'remove':
148
- sourceGroupHeight = sourceGroup ?
149
- sourceGroup.getCurrentHeight() :
150
- SourceGroup.getHeights(source, this._peaks).current;
152
+ if (Object.keys(this._sources).length === 0) {
153
+ this._height = this._peaks.options.emptyLineHeight;
154
+ this._sourceHeights = {};
155
+ }
156
+ else {
157
+ sourceGroupHeight = sourceGroup.getCurrentHeight();
151
158
 
152
- this._subtractHeight(sourceGroupHeight);
153
- break;
154
- default:
155
- // wrappingChanged
156
- var { unwrapped, wrapped } = sourceGroup ?
157
- sourceGroup.getHeights() :
158
- SourceGroup.getHeights(source, this._peaks);
159
+ this._sourceHeights[sourceGroupHeight]--;
159
160
 
160
- this._addHeight(source.wrapped ? wrapped : unwrapped);
161
- this._subtractHeight(source.wrapped ? unwrapped : wrapped);
161
+ if (this._sourceHeights[sourceGroupHeight] === 0
162
+ && sourceGroupHeight === this._height) {
163
+ delete this._sourceHeights[sourceGroupHeight];
164
+ this._height = 0;
165
+ for (var height in this._sourceHeights) {
166
+ if (Utils.objectHasProperty(this._sourceHeights, height)) {
167
+ var parsedHeight = parseInt(height, 10);
168
+
169
+ if (parsedHeight > this._height) {
170
+ this._height = parsedHeight;
171
+ }
172
+ }
173
+ }
174
+ }
175
+ }
176
+ break;
162
177
  }
163
178
 
164
179
  if (this._height !== oldHeight) {
@@ -175,16 +190,10 @@ define([
175
190
  layer.add(this._group);
176
191
  };
177
192
 
178
- /**
179
- * Adds a source to the line.
180
- * @param {Source} source - The source to add.
181
- * @param {SourceGroup} sourceGroup - The source group of the source (optional).
182
- * @returns {void}
183
- */
184
- Line.prototype.addSourceGroup = function(source, sourceGroup) {
185
- if (sourceGroup) {
186
- this._sourcesGroup[source.id] = sourceGroup;
187
- }
193
+ Line.prototype.addSourceGroup = function(sourceGroup) {
194
+ var source = sourceGroup.getSource();
195
+
196
+ this._sourcesGroup[source.id] = sourceGroup;
188
197
 
189
198
  if (!this._sources[source.id]) {
190
199
  var newSource = {
@@ -209,15 +218,15 @@ define([
209
218
  ? this._sources[currentSource.prevSourceId].source.endTime
210
219
  : 0;
211
220
 
212
- const { newStartTime, newEndTime } = this._canBePlacedBetween(
221
+ var newTimes = this._canBePlacedBetween(
213
222
  source.startTime,
214
223
  source.endTime,
215
224
  startLimit,
216
225
  currentSource.source.startTime
217
226
  );
218
227
 
219
- if (newStartTime !== null && newEndTime !== null) {
220
- source.updateTimes(newStartTime, newEndTime);
228
+ if (newTimes) {
229
+ source.updateTimes(newTimes.start, newTimes.end);
221
230
 
222
231
  if (currentSource.prevSourceId) {
223
232
  this._sources[currentSource.prevSourceId].nextSourceId = source.id;
@@ -256,10 +265,10 @@ define([
256
265
  this._sources[source.id] = newSource;
257
266
  }
258
267
 
259
- this.updateLineHeight(source, 'add');
268
+ this.updateLineHeight(sourceGroup, 'add');
260
269
  }
261
270
 
262
- if (sourceGroup && (!sourceGroup.getParent() || !sourceGroup.isDescendantOf(this._group))) {
271
+ if (!sourceGroup.getParent() || !sourceGroup.isDescendantOf(this._group)) {
263
272
  sourceGroup.addToGroup(this._group);
264
273
  }
265
274
  };
@@ -286,26 +295,32 @@ define([
286
295
 
287
296
  Line.prototype._canBePlacedBetween = function(startTime, endTime, startLimit, endLimit) {
288
297
  var timeWidth = Utils.roundTime(endTime - startTime);
289
- var newStartTime, newEndTime;
298
+ var newTimes = null;
290
299
 
291
300
  if ((!endLimit && startTime > startLimit) || (startTime > startLimit && endTime < endLimit)) {
292
301
  // Can be placed at its wanted position with wanted start/end time
293
- newStartTime = startTime;
294
- newEndTime = endTime;
302
+ newTimes = {
303
+ start: startTime,
304
+ end: endTime
305
+ };
295
306
  }
296
307
  else if (Utils.roundTime(endLimit - startLimit) >= timeWidth) {
297
308
  // Can be placed at its wanted position but not with its wanted start/end time
298
309
  if (startTime > startLimit) {
299
- newStartTime = Utils.roundTime(endLimit - timeWidth);
300
- newEndTime = endLimit;
310
+ newTimes = {
311
+ start: Utils.roundTime(endLimit - timeWidth),
312
+ end: endLimit
313
+ };
301
314
  }
302
315
  else {
303
- newStartTime = startLimit;
304
- newEndTime = Utils.roundTime(startLimit + timeWidth);
316
+ newTimes = {
317
+ start: startLimit,
318
+ end: Utils.roundTime(startLimit + timeWidth)
319
+ };
305
320
  }
306
321
  }
307
322
 
308
- return { newStartTime, newEndTime };
323
+ return newTimes;
309
324
  };
310
325
 
311
326
  Line.prototype.removeSourceGroup = function(source, isPermanent) {
@@ -314,32 +329,23 @@ define([
314
329
  delete this._sourcesGroup[source.id];
315
330
 
316
331
  if (isPermanent) {
317
- var sourceData = this._sources[source.id];
318
-
319
- delete this._sources[source.id];
320
-
321
- if (Object.keys(this._sources).length === 0) {
322
- setTimeout(function() {
323
- this._peaks.emit('line.remove', this._position);
324
- }.bind(this), 0);
325
- return sourceGroup;
326
- }
327
-
328
- if (sourceData.prevSourceId) {
329
- this._sources[sourceData.prevSourceId].nextSourceId
330
- = sourceData.nextSourceId;
332
+ if (this._sources[source.id].prevSourceId) {
333
+ this._sources[this._sources[source.id].prevSourceId].nextSourceId
334
+ = this._sources[source.id].nextSourceId;
331
335
  }
332
336
 
333
- if (sourceData.nextSourceId) {
334
- this._sources[sourceData.nextSourceId].prevSourceId
335
- = sourceData.prevSourceId;
337
+ if (this._sources[source.id].nextSourceId) {
338
+ this._sources[this._sources[source.id].nextSourceId].prevSourceId
339
+ = this._sources[source.id].prevSourceId;
336
340
  }
337
341
 
338
342
  if (this._firstSourceId === source.id) {
339
- this._firstSourceId = sourceData.nextSourceId;
343
+ this._firstSourceId = this._sources[source.id].nextSourceId;
340
344
  }
341
345
 
342
- this.updateLineHeight(source, 'remove');
346
+ delete this._sources[source.id];
347
+
348
+ this.updateLineHeight(sourceGroup, 'remove');
343
349
  }
344
350
 
345
351
  return sourceGroup;
@@ -369,116 +375,126 @@ define([
369
375
  this._group.y(this._group.y() + dy);
370
376
  };
371
377
 
372
- Line.prototype.manageOrder = function(sources, startTime, endTime) {
373
- const firstSource = sources[0];
374
- const lastSource = sources[sources.length - 1];
375
- const cursorTime = this._view.pixelsToTime(this._view.getPointerPosition().x);
376
- var newStartTime = startTime;
377
- var newEndTime = endTime;
378
+ Line.prototype.manageSourceOrder = function(source, newTimes) {
379
+ var cursorTime = this._view.pixelsToTime(this._view.getPointerPosition().x);
378
380
  var tmpTimes;
379
381
 
380
- var sourceDuration = Utils.roundTime(endTime - startTime);
382
+ var sourceDuration = source.endTime - source.startTime;
381
383
 
382
- if (typeof newStartTime === 'number' && typeof newEndTime === 'number') {
383
- if (this._sources[firstSource.id].prevSourceId) {
384
+ if (newTimes.start !== null && newTimes.end !== null) {
385
+ if (this._sources[source.id].prevSourceId) {
384
386
  // there is another source to the left
385
- var previousStartTime = this._sources[this._sources[firstSource.id].prevSourceId].source.startTime;
387
+ var previousStartTime = this._sources[this._sources[source.id].prevSourceId].source.startTime;
386
388
 
387
- if (Utils.roundTime(cursorTime + this._view.getTimeOffset()) < previousStartTime) {
389
+ if (cursorTime + this._view.getTimeOffset() < previousStartTime) {
388
390
  // we want to change order
389
- tmpTimes = this._changeSourcesPosition(
390
- sources,
391
+ tmpTimes = this._changeSourcePosition(
392
+ source,
391
393
  sourceDuration,
392
394
  cursorTime + this._view.getTimeOffset()
393
395
  );
394
396
 
395
- if (typeof tmpTimes.newStartTime === 'number' && typeof tmpTimes.newEndTime === 'number') {
396
- newStartTime = tmpTimes.newStartTime;
397
- newEndTime = tmpTimes.newEndTime;
397
+ if (tmpTimes) {
398
+ newTimes.start = tmpTimes.start;
399
+ newTimes.end = tmpTimes.end;
398
400
  }
399
401
  }
400
402
  }
401
403
 
402
- if (this._sources[lastSource.id].nextSourceId) {
404
+ if (this._sources[source.id].nextSourceId) {
403
405
  // there is another source to the right
404
- var nextEndTime = this._sources[this._sources[lastSource.id].nextSourceId].source.endTime;
406
+ var nextEndTime = this._sources[this._sources[source.id].nextSourceId].source.endTime;
405
407
 
406
- if (Utils.roundTime(cursorTime + this._view.getTimeOffset()) > nextEndTime) {
408
+ if (cursorTime + this._view.getTimeOffset() > nextEndTime) {
407
409
  // we want to change order
408
- tmpTimes = this._changeSourcesPosition(
409
- sources,
410
+ tmpTimes = this._changeSourcePosition(
411
+ source,
410
412
  sourceDuration,
411
413
  cursorTime + this._view.getTimeOffset()
412
414
  );
413
415
 
414
- if (typeof tmpTimes.newStartTime === 'number' && typeof tmpTimes.newEndTime === 'number') {
415
- newStartTime = tmpTimes.newStartTime;
416
- newEndTime = tmpTimes.newEndTime;
416
+ if (tmpTimes) {
417
+ newTimes.start = tmpTimes.start;
418
+ newTimes.end = tmpTimes.end;
417
419
  }
418
420
  }
419
421
  }
420
422
  }
421
423
 
422
- return { newStartTime, newEndTime };
424
+ if (newTimes.start) {
425
+ newTimes.start = Utils.roundTime(newTimes.start);
426
+ }
427
+ if (newTimes.end) {
428
+ newTimes.end = Utils.roundTime(newTimes.end);
429
+ }
430
+
431
+ return newTimes;
423
432
  };
424
433
 
425
- Line.prototype._changeSourcesPosition = function(sources, sourceDuration, time) {
426
- var currentRange = {
427
- start: null,
428
- end: null
429
- };
430
- var startLimit = null;
431
- var endLimit = null;
434
+ Line.prototype._changeSourcePosition = function(source, sourceDuration, time) {
435
+ if (source.orderable && this._firstSourceId) {
436
+ var currentRange = {
437
+ start: null,
438
+ end: null
439
+ };
440
+ var startLimit = null;
441
+ var endLimit = null;
432
442
 
433
- let newStartTime, newEndTime;
443
+ do {
444
+ if (!currentRange.end) {
445
+ currentRange.end = this._sources[this._firstSourceId];
446
+ }
447
+ else {
448
+ currentRange.start = currentRange.end;
449
+ currentRange.end = this._sources[currentRange.start.nextSourceId];
450
+ }
434
451
 
435
- do {
436
- if (!currentRange.end) {
437
- currentRange.end = this._sources[this._firstSourceId];
438
- }
439
- else {
440
- currentRange.start = currentRange.end;
441
- currentRange.end = this._sources[currentRange.start.nextSourceId];
442
- }
452
+ if (currentRange.start) {
453
+ startLimit = currentRange.start.source.endTime;
454
+ }
455
+ else {
456
+ startLimit = 0;
457
+ }
443
458
 
444
- if (currentRange.start) {
445
- startLimit = currentRange.start.source.endTime;
446
- }
447
- else {
448
- startLimit = 0;
449
- }
459
+ if (currentRange.end) {
460
+ endLimit = currentRange.end.source.startTime;
461
+ }
462
+ else {
463
+ endLimit = null;
464
+ }
450
465
 
451
- if (currentRange.end) {
452
- endLimit = currentRange.end.source.startTime;
453
- }
454
- else {
455
- endLimit = null;
456
- }
466
+ if (time > startLimit && (endLimit === null || time < endLimit)) {
467
+ var newTimes = this._canBePlacedBetween(
468
+ time,
469
+ time + sourceDuration,
470
+ startLimit,
471
+ endLimit
472
+ );
457
473
 
458
- if (time > startLimit && (endLimit === null || time < endLimit)) {
459
- ({ newStartTime, newEndTime } = this._canBePlacedBetween(
460
- time,
461
- time + sourceDuration,
462
- startLimit,
463
- endLimit
464
- ));
474
+ if (newTimes) {
475
+ if (newTimes.start) {
476
+ newTimes.start = Utils.roundTime(newTimes.start);
477
+ }
478
+ if (newTimes.end) {
479
+ newTimes.end = Utils.roundTime(newTimes.end);
480
+ }
465
481
 
466
- if (typeof newStartTime === 'number' && typeof newEndTime === 'number') {
467
- let prevSourceId = currentRange.start
468
- ? currentRange.start.source.id
469
- : null;
482
+ source.updateTimes(
483
+ newTimes.start,
484
+ newTimes.end
485
+ );
486
+ var prevSourceId = currentRange.start
487
+ ? currentRange.start.source.id
488
+ : null;
470
489
 
471
- sources.forEach(function(source) {
472
490
  this._moveSource(this._sources[source.id].source, prevSourceId);
473
- prevSourceId = source.id;
474
- }.bind(this));
491
+ return newTimes;
492
+ }
475
493
  }
494
+ } while (currentRange.end);
495
+ }
476
496
 
477
- return { newStartTime, newEndTime };
478
- }
479
- } while (currentRange.end);
480
-
481
- return { newStartTime, newEndTime };
497
+ return null;
482
498
  };
483
499
 
484
500
  Line.prototype._moveSource = function(source, prevSourceId) {
@@ -519,21 +535,26 @@ define([
519
535
  this._sources[source.id] = sourceObj;
520
536
  };
521
537
 
522
- Line.prototype.manageCollision = function(sources, newStartTime, newEndTime) {
523
- var originalStartTime = newStartTime;
524
- var originalEndTime = newEndTime;
538
+ Line.prototype.manageCollision = function(source, newTimes) {
539
+ var originalStartTime = null;
540
+ var originalEndTime = null;
541
+ var newStartTime = null;
542
+ var newEndTime = null;
525
543
  var startLimited = false;
526
544
  var endLimited = false;
527
- const firstSource = sources[0];
528
- const lastSource = sources[sources.length - 1];
529
545
 
530
- if (typeof newStartTime === 'number') {
546
+ newTimes.updateTimelineLength = false;
547
+
548
+ if (newTimes.start !== null) {
531
549
  // startMarker changed
532
- if (firstSource.startTime > newStartTime) {
550
+ originalStartTime = newTimes.start;
551
+ newStartTime = originalStartTime;
552
+
553
+ if (source.startTime > newStartTime) {
533
554
  // startMarker moved to the left
534
- if (this._sources[firstSource.id].prevSourceId) {
555
+ if (this._sources[source.id].prevSourceId) {
535
556
  // there is another source to the left
536
- var previousSource = this._sources[this._sources[firstSource.id].prevSourceId]
557
+ var previousSource = this._sources[this._sources[source.id].prevSourceId]
537
558
  .source;
538
559
 
539
560
  if (newStartTime < previousSource.endTime) {
@@ -551,13 +572,16 @@ define([
551
572
  }
552
573
  }
553
574
 
554
- if (typeof newEndTime === 'number') {
575
+ if (newTimes.end !== null) {
555
576
  // endMarker changed
556
- if (lastSource.endTime < newEndTime) {
577
+ originalEndTime = newTimes.end;
578
+ newEndTime = originalEndTime;
579
+
580
+ if (source.endTime < newEndTime) {
557
581
  // endMarker moved to the right
558
- if (this._sources[lastSource.id].nextSourceId) {
582
+ if (this._sources[source.id].nextSourceId) {
559
583
  // there is another source to the right
560
- var nextSource = this._sources[this._sources[lastSource.id].nextSourceId]
584
+ var nextSource = this._sources[this._sources[source.id].nextSourceId]
561
585
  .source;
562
586
 
563
587
  if (newEndTime > nextSource.startTime) {
@@ -570,7 +594,7 @@ define([
570
594
  }
571
595
 
572
596
  // Update the other edge if dragging and collision
573
- if (typeof newStartTime === 'number' && typeof newEndTime === 'number') {
597
+ if (newStartTime !== null && newEndTime !== null) {
574
598
  var timeWidth = originalEndTime - originalStartTime;
575
599
 
576
600
  if (startLimited) {
@@ -583,29 +607,40 @@ define([
583
607
  }
584
608
 
585
609
  // Check for minimal size of source
586
- // We assume that only 1 source can be resized at a time
587
- if (typeof newStartTime === 'number' && typeof newEndTime !== 'number') {
588
- if (Utils.roundTime(sources[0].endTime - newStartTime) < sources[0].minSize) {
589
- newStartTime = Utils.roundTime(sources[0].endTime - sources[0].minSize);
610
+ if (newStartTime !== null && newEndTime === null) {
611
+ if (Utils.roundTime(source.endTime - newStartTime) < source.minSize) {
612
+ newStartTime = Utils.roundTime(source.endTime - source.minSize);
590
613
  }
591
614
  }
592
- else if (typeof newEndTime === 'number' && typeof newStartTime !== 'number') {
593
- if (Utils.roundTime(newEndTime - sources[0].startTime) < sources[0].minSize) {
594
- newEndTime = Utils.roundTime(sources[0].startTime + sources[0].minSize);
615
+ else if (newEndTime !== null && newStartTime === null) {
616
+ if (Utils.roundTime(newEndTime - source.startTime) < source.minSize) {
617
+ newEndTime = Utils.roundTime(source.startTime + source.minSize);
595
618
  }
596
619
  }
597
620
  else {
598
- if (Utils.roundTime(newEndTime - newStartTime) < sources[0].minSize) {
599
- if (sources[0].endTime !== newEndTime) {
600
- newEndTime = Utils.roundTime(newStartTime + sources[0].minSize);
621
+ if (Utils.roundTime(newEndTime - newStartTime) < source.minSize) {
622
+ if (source.endTime !== newEndTime) {
623
+ newEndTime = Utils.roundTime(newStartTime + source.minSize);
601
624
  }
602
- if (sources[0].startTime !== newStartTime) {
603
- newStartTime = Utils.roundTime(newEndTime - sources[0].minSize);
625
+ if (source.startTime !== newStartTime) {
626
+ newStartTime = Utils.roundTime(newEndTime - source.minSize);
604
627
  }
605
628
  }
606
629
  }
607
630
 
608
- return { newStartTime, newEndTime };
631
+ if (newStartTime !== null && newStartTime !== originalStartTime) {
632
+ newTimes.start = newStartTime;
633
+ }
634
+
635
+ if (newEndTime !== null && newEndTime !== originalEndTime) {
636
+ newTimes.end = newEndTime;
637
+
638
+ if (this._sources[source.id].nextSourceId === null) {
639
+ newTimes.updateTimelineLength = true;
640
+ }
641
+ }
642
+
643
+ return newTimes;
609
644
  };
610
645
 
611
646
  Line.prototype.getSourcesAfter = function(time) {
@@ -630,38 +665,6 @@ define([
630
665
  return sources;
631
666
  };
632
667
 
633
- Line.prototype.getSourcesAround = function(time) {
634
- var left = null;
635
- var right = null;
636
- var overlapping = null;
637
- var currentId = this._firstSourceId;
638
-
639
- while (currentId) {
640
- var lineSource = this._sources[currentId];
641
- var source = lineSource.source;
642
-
643
- if (time < source.startTime) {
644
- right = source;
645
- break;
646
- }
647
- else if (time >= source.startTime && time <= source.endTime) {
648
- overlapping = source;
649
- break;
650
- }
651
- else {
652
- left = source;
653
- }
654
- currentId = lineSource.nextSourceId;
655
- }
656
-
657
- if (overlapping) {
658
- return { overlapping: overlapping };
659
- }
660
- else {
661
- return { left: left, right: right };
662
- }
663
- };
664
-
665
668
  Line.prototype.updatePosition = function(pos) {
666
669
  for (var sourceId in this._sources) {
667
670
  if (Utils.objectHasProperty(this._sources, sourceId)) {