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