@checksub_team/peaks_timeline 1.16.0-alpha.2 → 1.16.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 +444 -470
- package/src/line-indicator.js +10 -0
- package/src/line.js +225 -222
- package/src/lines.js +56 -162
- package/src/main.js +8 -7
- package/src/segments-group.js +0 -4
- package/src/source-group.js +74 -84
- package/src/source.js +64 -18
- package/src/sources-layer.js +118 -92
- package/src/timeline-sources.js +12 -10
- package/src/timeline-zoomview.js +0 -4
package/src/line-indicator.js
CHANGED
|
@@ -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(
|
|
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.
|
|
54
|
+
Line.prototype.isEmpty = function() {
|
|
56
55
|
return this.isSegmentsLine() ?
|
|
57
|
-
this._segmentsGroup.
|
|
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.
|
|
98
|
-
if (this._sourceHeights[
|
|
99
|
-
this.
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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.
|
|
118
|
-
|
|
119
|
-
|
|
107
|
+
if (to > this._height) {
|
|
108
|
+
this._height = to;
|
|
109
|
+
}
|
|
110
|
+
else if (from === this._height) {
|
|
120
111
|
this._height = 0;
|
|
121
|
-
for (var
|
|
122
|
-
if (Utils.objectHasProperty(this._sourceHeights,
|
|
123
|
-
var parsedHeight = parseInt(
|
|
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
|
|
126
|
-
this._height
|
|
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(
|
|
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.
|
|
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
|
-
|
|
149
|
-
|
|
150
|
-
|
|
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
|
-
|
|
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
|
-
|
|
161
|
-
|
|
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
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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
|
-
|
|
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 (
|
|
220
|
-
source.updateTimes(
|
|
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(
|
|
268
|
+
this.updateLineHeight(sourceGroup, 'add');
|
|
260
269
|
}
|
|
261
270
|
|
|
262
|
-
if (
|
|
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
|
|
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
|
-
|
|
294
|
-
|
|
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
|
-
|
|
300
|
-
|
|
310
|
+
newTimes = {
|
|
311
|
+
start: Utils.roundTime(endLimit - timeWidth),
|
|
312
|
+
end: endLimit
|
|
313
|
+
};
|
|
301
314
|
}
|
|
302
315
|
else {
|
|
303
|
-
|
|
304
|
-
|
|
316
|
+
newTimes = {
|
|
317
|
+
start: startLimit,
|
|
318
|
+
end: Utils.roundTime(startLimit + timeWidth)
|
|
319
|
+
};
|
|
305
320
|
}
|
|
306
321
|
}
|
|
307
322
|
|
|
308
|
-
return
|
|
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
|
-
|
|
318
|
-
|
|
319
|
-
|
|
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 (
|
|
334
|
-
this._sources[
|
|
335
|
-
=
|
|
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 =
|
|
343
|
+
this._firstSourceId = this._sources[source.id].nextSourceId;
|
|
340
344
|
}
|
|
341
345
|
|
|
342
|
-
this.
|
|
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.
|
|
373
|
-
|
|
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 =
|
|
382
|
+
var sourceDuration = source.endTime - source.startTime;
|
|
381
383
|
|
|
382
|
-
if (
|
|
383
|
-
if (this._sources[
|
|
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[
|
|
387
|
+
var previousStartTime = this._sources[this._sources[source.id].prevSourceId].source.startTime;
|
|
386
388
|
|
|
387
|
-
if (
|
|
389
|
+
if (cursorTime + this._view.getTimeOffset() < previousStartTime) {
|
|
388
390
|
// we want to change order
|
|
389
|
-
tmpTimes = this.
|
|
390
|
-
|
|
391
|
+
tmpTimes = this._changeSourcePosition(
|
|
392
|
+
source,
|
|
391
393
|
sourceDuration,
|
|
392
394
|
cursorTime + this._view.getTimeOffset()
|
|
393
395
|
);
|
|
394
396
|
|
|
395
|
-
if (
|
|
396
|
-
|
|
397
|
-
|
|
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[
|
|
404
|
+
if (this._sources[source.id].nextSourceId) {
|
|
403
405
|
// there is another source to the right
|
|
404
|
-
var nextEndTime = this._sources[this._sources[
|
|
406
|
+
var nextEndTime = this._sources[this._sources[source.id].nextSourceId].source.endTime;
|
|
405
407
|
|
|
406
|
-
if (
|
|
408
|
+
if (cursorTime + this._view.getTimeOffset() > nextEndTime) {
|
|
407
409
|
// we want to change order
|
|
408
|
-
tmpTimes = this.
|
|
409
|
-
|
|
410
|
+
tmpTimes = this._changeSourcePosition(
|
|
411
|
+
source,
|
|
410
412
|
sourceDuration,
|
|
411
413
|
cursorTime + this._view.getTimeOffset()
|
|
412
414
|
);
|
|
413
415
|
|
|
414
|
-
if (
|
|
415
|
-
|
|
416
|
-
|
|
416
|
+
if (tmpTimes) {
|
|
417
|
+
newTimes.start = tmpTimes.start;
|
|
418
|
+
newTimes.end = tmpTimes.end;
|
|
417
419
|
}
|
|
418
420
|
}
|
|
419
421
|
}
|
|
420
422
|
}
|
|
421
423
|
|
|
422
|
-
|
|
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.
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
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
|
-
|
|
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
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
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
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
459
|
+
if (currentRange.end) {
|
|
460
|
+
endLimit = currentRange.end.source.startTime;
|
|
461
|
+
}
|
|
462
|
+
else {
|
|
463
|
+
endLimit = null;
|
|
464
|
+
}
|
|
450
465
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
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
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
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
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
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
|
-
|
|
474
|
-
}
|
|
491
|
+
return newTimes;
|
|
492
|
+
}
|
|
475
493
|
}
|
|
494
|
+
} while (currentRange.end);
|
|
495
|
+
}
|
|
476
496
|
|
|
477
|
-
|
|
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(
|
|
523
|
-
var originalStartTime =
|
|
524
|
-
var originalEndTime =
|
|
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
|
-
|
|
546
|
+
newTimes.updateTimelineLength = false;
|
|
547
|
+
|
|
548
|
+
if (newTimes.start !== null) {
|
|
531
549
|
// startMarker changed
|
|
532
|
-
|
|
550
|
+
originalStartTime = newTimes.start;
|
|
551
|
+
newStartTime = originalStartTime;
|
|
552
|
+
|
|
553
|
+
if (source.startTime > newStartTime) {
|
|
533
554
|
// startMarker moved to the left
|
|
534
|
-
if (this._sources[
|
|
555
|
+
if (this._sources[source.id].prevSourceId) {
|
|
535
556
|
// there is another source to the left
|
|
536
|
-
var previousSource = this._sources[this._sources[
|
|
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 (
|
|
575
|
+
if (newTimes.end !== null) {
|
|
555
576
|
// endMarker changed
|
|
556
|
-
|
|
577
|
+
originalEndTime = newTimes.end;
|
|
578
|
+
newEndTime = originalEndTime;
|
|
579
|
+
|
|
580
|
+
if (source.endTime < newEndTime) {
|
|
557
581
|
// endMarker moved to the right
|
|
558
|
-
if (this._sources[
|
|
582
|
+
if (this._sources[source.id].nextSourceId) {
|
|
559
583
|
// there is another source to the right
|
|
560
|
-
var nextSource = this._sources[this._sources[
|
|
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 (
|
|
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
|
-
|
|
587
|
-
|
|
588
|
-
|
|
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 (
|
|
593
|
-
if (Utils.roundTime(newEndTime -
|
|
594
|
-
newEndTime = Utils.roundTime(
|
|
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) <
|
|
599
|
-
if (
|
|
600
|
-
newEndTime = Utils.roundTime(newStartTime +
|
|
621
|
+
if (Utils.roundTime(newEndTime - newStartTime) < source.minSize) {
|
|
622
|
+
if (source.endTime !== newEndTime) {
|
|
623
|
+
newEndTime = Utils.roundTime(newStartTime + source.minSize);
|
|
601
624
|
}
|
|
602
|
-
if (
|
|
603
|
-
newStartTime = Utils.roundTime(newEndTime -
|
|
625
|
+
if (source.startTime !== newStartTime) {
|
|
626
|
+
newStartTime = Utils.roundTime(newEndTime - source.minSize);
|
|
604
627
|
}
|
|
605
628
|
}
|
|
606
629
|
}
|
|
607
630
|
|
|
608
|
-
|
|
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)) {
|