@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.
package/src/lines.js CHANGED
@@ -22,15 +22,12 @@ define([
22
22
  this._peaks = peaks;
23
23
  this._view = view;
24
24
  this._layer = layer;
25
+ this._linesBySourceId = {};
25
26
  this._linesByPosition = {};
26
27
  this._autoAddToLayer = false;
27
28
  this._areSourceInteractionsAllowed = true;
28
29
  this._areSegmentInteractionsAllowed = true;
29
30
 
30
- this._automaticallyCreatedLineId = null;
31
- this._automaticLineCreationPosition = null;
32
- this._automaticLineCreationTimeout = null;
33
-
34
31
  this._segmentsGroups = {};
35
32
  this._segmentsGroupToLine = {};
36
33
 
@@ -43,11 +40,9 @@ define([
43
40
  );
44
41
 
45
42
  this._peaks.on('line.heightChanged', this._onLineHeightChanged.bind(this));
43
+ this._peaks.on('line.add', this._onLineAdd.bind(this));
46
44
  this._peaks.on('line.remove', this._onLineRemove.bind(this));
47
45
 
48
- this._peaks.on('sources.show', this._onSourcesWrappingChanged.bind(this));
49
- this._peaks.on('sources.hide', this._onSourcesWrappingChanged.bind(this));
50
-
51
46
  this._peaks.on('segment.updated', this._onSegmentsUpdate.bind(this));
52
47
  this._peaks.on('segments.add', this._onSegmentsAdd.bind(this));
53
48
  this._peaks.on('segments.remove', this._onSegmentsRemove.bind(this));
@@ -103,27 +98,38 @@ define([
103
98
  this._view.updateTimeline();
104
99
  };
105
100
 
106
- Lines.prototype._onLineRemove = function(position) {
107
- this._removeLine(position);
101
+ Lines.prototype._onLineAdd = function(position) {
102
+ this._createLine(position);
103
+ this._setInteractions(position);
108
104
  this._updateLinesPosition(position);
109
105
  };
110
106
 
111
- Lines.prototype._onSourcesWrappingChanged = function(sources) {
112
- sources.forEach(function(source) {
113
- if (this._linesByPosition[source.position]) {
114
- this._linesByPosition[source.position].updateLineHeight(source, 'wrappingChanged');
107
+ Lines.prototype._onLineRemove = function(position) {
108
+ var oldLine = this.removeLine(position);
109
+ var lineNewY = oldLine.getY();
110
+
111
+ this._updateLinesPosition(position, lineNewY);
112
+ };
113
+
114
+ Lines.prototype.changeLineHeight = function(from, to) {
115
+ for (var position in this._linesByPosition) {
116
+ if (Utils.objectHasProperty(this._linesByPosition, position)) {
117
+ if (!this._linesByPosition[position].isSegmentsLine()) {
118
+ this._linesByPosition[position].changeHeight(from, to);
119
+ }
115
120
  }
116
- }.bind(this));
121
+ }
117
122
  };
118
123
 
119
- Lines.prototype.addSourceGroup = function(source, sourceGroup, position) {
124
+ Lines.prototype.addSourceGroup = function(sourceGroup, position) {
120
125
  if (!this._linesByPosition[position] || this._linesByPosition[position].isSegmentsLine()) {
121
126
  this._createLine(position);
122
127
  this._setInteractions(position);
123
128
  }
124
129
 
125
- source.position = position;
126
- this._linesByPosition[position].addSourceGroup(source, sourceGroup);
130
+ sourceGroup.getSource().position = position;
131
+ this._linesByPosition[position].addSourceGroup(sourceGroup);
132
+ this._linesBySourceId[sourceGroup.getSource().id] = this._linesByPosition[position];
127
133
  };
128
134
 
129
135
  Lines.prototype.addSegments = function(lineId, position) {
@@ -140,37 +146,30 @@ define([
140
146
  };
141
147
 
142
148
  Lines.prototype.removeSourceGroup = function(source, isPermanent) {
143
- if (!this._linesByPosition[source.position]) {
144
- return null;
145
- }
146
-
147
149
  var sourceGroup = this._linesByPosition[source.position].removeSourceGroup(source, isPermanent);
148
150
 
149
151
  if (isPermanent) {
152
+ delete this._linesBySourceId[source.id];
150
153
  this._updateLinesPosition(source.position);
151
154
  }
152
155
 
153
156
  return sourceGroup;
154
157
  };
155
158
 
156
- Lines.prototype._removeLine = function(pos) {
159
+ Lines.prototype.removeLine = function(pos) {
157
160
  var oldLine = this._linesByPosition[pos];
158
- var lineId = oldLine.getId();
159
161
 
160
- if (this._automaticallyCreatedLineId === lineId) {
161
- this._automaticallyCreatedLineId = null;
162
- }
163
162
  oldLine.destroy();
164
163
 
165
164
  delete this._linesByPosition[pos];
166
165
 
167
- this._lineIndicator.removeIndicator(lineId, false);
166
+ this._lineIndicator.removeIndicator(oldLine.getId(), false);
168
167
 
169
168
  return oldLine;
170
169
  };
171
170
 
172
171
  Lines.prototype.isLineVisible = function(position) {
173
- return this._linesByPosition[position] ? this._linesByPosition[position].isVisible() : false;
172
+ return this._linesByPosition[position].isVisible();
174
173
  };
175
174
 
176
175
  Lines.prototype.getVisibleLines = function() {
@@ -208,22 +207,16 @@ define([
208
207
  this._updateLinesPosition(position);
209
208
  };
210
209
 
211
- Lines.prototype._updateLinesPosition = function(position) {
210
+ Lines.prototype._updateLinesPosition = function(position, forceNewY) {
212
211
  var line = this._linesByPosition[position];
213
212
  var dy = null;
214
213
  var newY;
215
214
 
216
- if (line) {
217
- newY = line.getY() + line.lineHeight() + this._peaks.options.interline;
215
+ if (forceNewY) {
216
+ newY = forceNewY;
218
217
  }
219
218
  else {
220
- var previousLine;
221
-
222
- while ((previousLine === undefined || previousLine === null) && position > 0) {
223
- previousLine = this._linesByPosition[--position];
224
- }
225
-
226
- newY = previousLine ? previousLine.getY() + previousLine.lineHeight() + this._peaks.options.interline : 0;
219
+ newY = line.getY() + line.lineHeight() + this._peaks.options.interline;
227
220
  }
228
221
 
229
222
  for (var pos in this._linesByPosition) {
@@ -242,7 +235,8 @@ define([
242
235
 
243
236
  this._lineIndicator.updateIndicators();
244
237
  this._lineIndicator.draw();
245
- this._view.refresh();
238
+
239
+ this._view.drawSourcesLayer();
246
240
  };
247
241
 
248
242
  Lines.prototype.setOffsetY = function(frameOffset) {
@@ -288,112 +282,25 @@ define([
288
282
  return length;
289
283
  };
290
284
 
291
- Lines.prototype.stopAutomaticLineCreation = function() {
292
- if (this._automaticLineCreationTimeout) {
293
- clearTimeout(this._automaticLineCreationTimeout);
294
- }
295
- this._automaticLineCreationTimeout = null;
296
- this._automaticLineCreationPosition = null;
297
- this._automaticallyCreatedLineId = null;
298
- };
299
-
300
- Lines.prototype.manageAutomaticLineCreation = function(newLinePosition, initialPosition, sources) {
301
- if (this._automaticallyCreatedLineId !== null) {
302
- return;
303
- }
304
- else if (
305
- this._automaticLineCreationPosition !== null
306
- && this._automaticLineCreationPosition !== newLinePosition
307
- ) {
308
- this.stopAutomaticLineCreation();
309
- }
310
-
311
- if (this._automaticLineCreationTimeout) {
312
- return;
313
- }
314
-
315
- this._automaticLineCreationPosition = newLinePosition;
316
- this._automaticLineCreationTimeout = setTimeout(function() {
317
- this._automaticLineCreationTimeout = null;
318
-
319
- var currentLine = this._linesByPosition[initialPosition];
320
-
321
- if (currentLine.countRemainingElements() === sources.length) {
322
- this.stopAutomaticLineCreation();
323
- return;
324
- }
325
-
326
- this._automaticallyCreatedLineId = this._createLine(newLinePosition);
327
- this._setInteractions(newLinePosition);
328
- this.moveSourcesToPosition(sources, currentLine.getPosition(), newLinePosition);
329
- }.bind(this), this._peaks.options.automaticLineCreationDelay);
330
- };
331
-
332
- Lines.prototype.manageVerticalPosition = function(sources, startTime, endTime, mouseX, mouseY) {
333
- if (mouseX === null || mouseX === undefined) {
334
- return;
335
- }
336
-
337
- const position = sources[0].position;
338
- const linePos = this.getLinesUnderY(mouseY);
285
+ Lines.prototype.manageVerticalPosition = function(source, newY) {
286
+ if (newY !== null && newY !== undefined) {
287
+ var pos = this.getLineOnPosition(newY);
339
288
 
340
- if (linePos[0] !== linePos[1]) {
341
- this.manageAutomaticLineCreation(linePos[0] + 1, position, sources);
342
- }
343
- else {
344
- this.stopAutomaticLineCreation();
345
-
346
- if (
347
- mouseX !== null && mouseX !== undefined
348
- && linePos[0] !== position
349
- && !this._linesByPosition[linePos[0]].isSegmentsLine()
350
- ) {
351
- var mouseTime = this._view.pixelsToTime(mouseX + this._view.getFrameOffset());
352
- var sourceDuration = Utils.roundTime(endTime - startTime);
353
-
354
- if (this._hasSpaceForSourceAt(linePos[0], mouseTime, sourceDuration)) {
355
- this.moveSourcesToPosition(sources, position, linePos[0]);
356
- }
289
+ if (pos[0] === pos[1]
290
+ && pos[0] !== source.position
291
+ && !this._linesByPosition[pos[0]].isSegmentsLine()) {
292
+ this.moveSourceToPosition(source, pos[0]);
357
293
  }
358
294
  }
359
295
  };
360
296
 
361
- Lines.prototype._hasSpaceForSourceAt = function(linePosition, mouseTime, sourceDuration) {
362
- var line = this._linesByPosition[linePosition];
363
-
364
- if (!line || line.isSegmentsLine()) {
365
- return false;
366
- }
367
-
368
- var sourcesAround = line.getSourcesAround(mouseTime);
369
-
370
- if (sourcesAround.overlapping) {
371
- return false;
372
- }
373
- else if (!sourcesAround.right) {
374
- return true;
375
- }
376
- else {
377
- var leftLimit = sourcesAround.left ? sourcesAround.left.endTime : 0;
378
- var rightLimit = sourcesAround.right.startTime;
379
-
380
- return sourceDuration <= Utils.roundTime(rightLimit - leftLimit);
381
- }
382
- };
383
-
384
297
  Lines.prototype.getLineByPosition = function(pos) {
385
298
  return this._linesByPosition[pos];
386
299
  };
387
300
 
388
- Lines.prototype.getLastPosition = function() {
389
- var keys = Object.keys(this._linesByPosition);
390
-
391
- return keys.pop();
392
- };
393
-
394
- Lines.prototype.getLinesUnderY = function(y) {
301
+ Lines.prototype.getLineOnPosition = function(y) {
395
302
  var height;
396
- var pos = [-1, this.getLastPosition() + 1];
303
+ var pos = [-1, Number.MAX_VALUE];
397
304
 
398
305
  for (var position in this._linesByPosition) {
399
306
  if (Utils.objectHasProperty(this._linesByPosition, position)) {
@@ -412,18 +319,16 @@ define([
412
319
  return pos;
413
320
  };
414
321
 
415
- Lines.prototype.moveSourcesToPosition = function(sources, initialPosition, targetPosition) {
416
- sources.forEach(function(source) {
417
- var sourceGroup = this._linesByPosition[initialPosition].removeSourceGroup(source, true);
322
+ Lines.prototype.moveSourceToPosition = function(source, pos) {
323
+ var sourceGroup = this._linesByPosition[source.position].removeSourceGroup(source, true);
418
324
 
419
- if (sourceGroup) {
420
- sourceGroup.moveTo(this._linesByPosition[targetPosition].getKonvaGroup());
421
- }
325
+ delete this._linesBySourceId[source.id];
326
+
327
+ sourceGroup.moveTo(this._linesByPosition[pos].getKonvaGroup());
422
328
 
423
- this.addSourceGroup(source, sourceGroup, targetPosition);
424
- }.bind(this));
329
+ this._updateLinesPosition(source.position);
425
330
 
426
- this._updateLinesPosition(initialPosition);
331
+ this.addSourceGroup(sourceGroup, pos);
427
332
  };
428
333
 
429
334
  Lines.prototype._getNextLineId = function() {
@@ -443,17 +348,9 @@ define([
443
348
  y += this._linesByPosition[pos].lineHeight() + this._peaks.options.interline;
444
349
  }
445
350
  else {
446
- // This code assumes that lines are ordered in ascending order of position
447
- // This is the case as the keys are integers
448
- if (Utils.objectHasProperty(this._linesByPosition, position)) {
449
- var newPosition = currentPos + 1;
450
-
451
- this._linesByPosition[currentPos].updatePosition(newPosition);
452
- newLinesByPosition[newPosition] = this._linesByPosition[currentPos];
453
-
454
- if (!this._linesByPosition[newPosition]) {
455
- break;
456
- }
351
+ if (this._linesByPosition[position]) {
352
+ this._linesByPosition[currentPos].updatePosition(currentPos + 1);
353
+ newLinesByPosition[currentPos + 1] = this._linesByPosition[currentPos];
457
354
  }
458
355
  }
459
356
  }
@@ -469,8 +366,6 @@ define([
469
366
 
470
367
  newLinesByPosition[position] = line;
471
368
  this._linesByPosition = newLinesByPosition;
472
-
473
- return line.getId();
474
369
  };
475
370
 
476
371
  Lines.prototype.updateSegments = function(frameStartTime, frameEndTime) {
@@ -481,13 +376,12 @@ define([
481
376
  }
482
377
  };
483
378
 
484
- Lines.prototype.manageCollision = function(sources, newStartTime, newEndTime) {
485
- return this._linesByPosition[sources[0].position].manageCollision(sources, newStartTime, newEndTime);
379
+ Lines.prototype.manageCollision = function(source, newTimes) {
380
+ return this._linesBySourceId[source.id].manageCollision(source, newTimes);
486
381
  };
487
382
 
488
- Lines.prototype.manageOrder = function(sources, startTime, endTime) {
489
- // Assuming all ordered elements have the same position
490
- return this._linesByPosition[sources[0].position].manageOrder(sources, startTime, endTime);
383
+ Lines.prototype.manageSourceOrder = function(source, newTimes) {
384
+ return this._linesBySourceId[source.id].manageSourceOrder(source, newTimes);
491
385
  };
492
386
 
493
387
  Lines.prototype._setInteractions = function(position) {
package/src/main.js CHANGED
@@ -409,13 +409,7 @@ define([
409
409
  * Indicates whether or not sources can be dragged
410
410
  * from one line to another
411
411
  */
412
- canMoveSourcesBetweenLines: true,
413
-
414
- /**
415
- * Delay in milliseconds before a new line is created
416
- * when dragging a source between 2 lines.
417
- */
418
- automaticLineCreationDelay: 100
412
+ canMoveSourcesBetweenLines: true
419
413
  };
420
414
 
421
415
  /**
@@ -777,6 +771,13 @@ define([
777
771
  window.removeEventListener('resize', this._onResize);
778
772
  };
779
773
 
774
+ Peaks.prototype.setLineHeight = function(newLineHeight) {
775
+ var oldHeight = this.options.lineHeight;
776
+
777
+ this.options.lineHeight = newLineHeight;
778
+ this.emit('options.set.line_height', oldHeight);
779
+ };
780
+
780
781
  Peaks.prototype.zoomIn = function() {
781
782
  this.view.setZoom(
782
783
  this.view.getTimeToPixelsScale() + Math.floor(this.view.getTimeToPixelsScale() / 10) + 1
@@ -72,10 +72,6 @@ define([
72
72
  return Object.keys(this._segments).length === 0;
73
73
  };
74
74
 
75
- SegmentsGroup.prototype.countRemainingElements = function() {
76
- return Object.keys(this._segments).length;
77
- };
78
-
79
75
  /**
80
76
  * Adds the group to the given {Konva.Group}.
81
77
  *
@@ -47,13 +47,15 @@ define([
47
47
  var self = this;
48
48
 
49
49
  this._x = this._view.timeToPixels(source.startTime);
50
+ this._roundedX = Math.round(this._x);
50
51
  this._width = this._view.timeToPixels(source.endTime - source.startTime);
51
- var heights = SourceGroup.getHeights(source, peaks);
52
-
53
- this._unwrappedHeight = heights.unwrapped;
54
- this._wrappedHeight = heights.wrapped;
55
- this._height = heights.current;
52
+ this._roundedWidth = Math.round(this._width);
53
+ this._unwrappedHeight = source.binaryHeight && source.previewHeight ?
54
+ source.binaryHeight + source.previewHeight :
55
+ this._peaks.options.lineHeight;
56
+ this._wrappedHeight = this._peaks.options.wrappedLineHeight;
56
57
  this._borderWidth = this._source.borderWidth || 0;
58
+ this._height = this._unwrappedHeight;
57
59
  this._currentTimeToPixelsScaleUsed = this._view.getTimeToPixelsScale();
58
60
  this._selected = this._source.selected;
59
61
  this._isDragged = false;
@@ -79,6 +81,7 @@ define([
79
81
 
80
82
  this._cursor = null;
81
83
  this._group.on('mouseenter', function() {
84
+ self._setHovered(true);
82
85
  self._view.setHoveredElement(self);
83
86
  if (!self._source.loading) {
84
87
  self._showButtons();
@@ -86,6 +89,7 @@ define([
86
89
  });
87
90
 
88
91
  this._group.on('mouseleave', function() {
92
+ self._setHovered(false);
89
93
  self._view.setHoveredElement(null);
90
94
  self._hideButtons();
91
95
  });
@@ -133,6 +137,11 @@ define([
133
137
  this.setLoadingState(this._source.loading);
134
138
  }
135
139
 
140
+ SourceGroup.prototype._setHovered = function(newValue) {
141
+ this._hovered = newValue;
142
+ this._group.draw();
143
+ };
144
+
136
145
  SourceGroup.prototype._onDragStart = function(element) {
137
146
  this._isDragged = true;
138
147
  this._layer.onSourcesGroupDragStart(element);
@@ -172,8 +181,8 @@ define([
172
181
 
173
182
  this._view.updateWithAutoScroll(
174
183
  function() {
175
- if (this._layer.manageSourceMovements(
176
- [this._source],
184
+ if (this._layer.updateSource(
185
+ this._source,
177
186
  leftHandle ? start + diff + timeOffsetDiff : null,
178
187
  leftHandle ? null : end + diff + timeOffsetDiff
179
188
  )) {
@@ -182,6 +191,10 @@ define([
182
191
  }.bind(this)
183
192
  );
184
193
 
194
+ this._view.setTimelineLength(
195
+ this._view.timeToPixels(this._source.endTime) + this._view.getWidth()
196
+ );
197
+
185
198
  return {
186
199
  x: draggedElement.absolutePosition().x,
187
200
  y: draggedElement.absolutePosition().y
@@ -197,11 +210,13 @@ define([
197
210
  this._group.x(startPixel - frameOffset);
198
211
 
199
212
  this._x = startPixel;
213
+ this._roundedX = Math.round(this._x);
200
214
 
201
215
  const newWidth = endPixel - startPixel;
202
216
 
203
217
  if (newWidth !== this._width) {
204
218
  this._width = newWidth;
219
+ this._roundedWidth = Math.round(this._width);
205
220
 
206
221
  // the zoom was changed
207
222
  if (newTimeToPixelsScale !== this._currentTimeToPixelsScaleUsed) {
@@ -269,13 +284,11 @@ define([
269
284
  start: this._source.startTime,
270
285
  end: this._source.endTime
271
286
  };
272
- this._isDragged = true;
273
287
 
274
288
  this._hideButtons();
275
289
  };
276
290
 
277
291
  SourceGroup.prototype._onHandleDragEnd = function() {
278
- this._isDragged = false;
279
292
  this._showButtons();
280
293
  };
281
294
 
@@ -380,7 +393,7 @@ define([
380
393
  Math.max(
381
394
  1,
382
395
  Math.min(
383
- this._width / 2,
396
+ this._roundedWidth / 2,
384
397
  Math.min(
385
398
  CORNER_RADIUS,
386
399
  this._height / 2
@@ -389,66 +402,76 @@ define([
389
402
  );
390
403
  var x = Math.max(
391
404
  0,
392
- this._view.getFrameOffset() - this._x - 2 * radius
405
+ this._view.getFrameOffset() - this._roundedX - radius
393
406
  );
394
407
  var width = Math.min(
395
- this._width - x,
396
- this._view.getWidth() + 4 * radius - Math.max(
408
+ this._roundedWidth - x,
409
+ this._view.getWidth() + radius - Math.max(
397
410
  0,
398
- this._x - this._view.getFrameOffset()
411
+ this._roundedX - this._view.getFrameOffset()
399
412
  )
400
413
  );
401
414
  var xWidth = x + width;
402
415
 
403
- if (width > 0) {
404
- ctx.beginPath();
405
- ctx.moveTo(x + radius, offset);
406
- ctx.lineTo(xWidth - radius, offset);
407
- ctx.quadraticCurveTo(xWidth - offset, offset, xWidth - offset, radius);
408
- ctx.lineTo(xWidth - offset, this._height - radius);
409
- ctx.quadraticCurveTo(
410
- xWidth - offset,
411
- this._height - offset,
412
- xWidth - radius,
413
- this._height - offset
414
- );
415
- ctx.lineTo(x + radius, this._height - offset);
416
- ctx.quadraticCurveTo(x + offset, this._height - offset, x + offset, this._height - radius);
417
- ctx.lineTo(x + offset, radius);
418
- ctx.quadraticCurveTo(x + offset, offset, x + radius, offset);
419
- ctx.closePath();
420
-
421
- if (fill) {
422
- if (this._source.shouldShowWarning()) {
423
- var gradient = ctx.createLinearGradient(0, 0, this._width, 0);
416
+ ctx.beginPath();
417
+ ctx.moveTo(x + radius, offset);
418
+ ctx.lineTo(xWidth - radius, offset);
419
+ ctx.quadraticCurveTo(xWidth - offset, offset, xWidth - offset, radius);
420
+ ctx.lineTo(xWidth - offset, this._height - radius);
421
+ ctx.quadraticCurveTo(
422
+ xWidth - offset,
423
+ this._height - offset,
424
+ xWidth - radius,
425
+ this._height - offset
426
+ );
427
+ ctx.lineTo(x + radius, this._height - offset);
428
+ ctx.quadraticCurveTo(x + offset, this._height - offset, x + offset, this._height - radius);
429
+ ctx.lineTo(x + offset, radius);
430
+ ctx.quadraticCurveTo(x + offset, offset, x + radius, offset);
431
+ ctx.closePath();
424
432
 
425
- if (this._source.mediaEndTime < this._source.duration) {
426
- var rightStopPosition = Math.max(1 - (this._source.warningWidth / this._width), 0.5);
433
+ if (fill) {
434
+ var backgroundColor;
427
435
 
428
- gradient.addColorStop(rightStopPosition, this._source.backgroundColor);
429
- gradient.addColorStop(1, this._source.warningColor);
430
- }
436
+ if (this._selected) {
437
+ backgroundColor = this._source.selectedBackgroundColor;
438
+ }
439
+ else if (this._hovered) {
440
+ backgroundColor = this._source.hoverBackgroundColor;
441
+ }
442
+ else {
443
+ backgroundColor = this._source.backgroundColor;
444
+ }
431
445
 
432
- if (this._source.mediaStartTime > 0) {
433
- var leftStopPosition = Math.min(this._source.warningWidth / this._width, 0.5);
446
+ if (this._source.shouldShowWarning()) {
447
+ var gradient = ctx.createLinearGradient(0, 0, this._roundedWidth, 0);
434
448
 
435
- gradient.addColorStop(0, this._source.warningColor);
436
- gradient.addColorStop(leftStopPosition, this._source.backgroundColor);
437
- }
449
+ if (this._source.mediaEndTime < this._source.duration) {
450
+ var rightStopPosition = Math.max(1 - (this._source.warningWidth / this._roundedWidth), 0.5);
438
451
 
439
- ctx.fillStyle = gradient;
440
- ctx.fill();
452
+ gradient.addColorStop(rightStopPosition, backgroundColor);
453
+ gradient.addColorStop(1, this._source.warningColor);
441
454
  }
442
- else {
443
- ctx.fillStyle = this._source.backgroundColor;
444
- ctx.fill();
455
+
456
+ if (this._source.mediaStartTime > 0) {
457
+ var leftStopPosition = Math.min(this._source.warningWidth / this._roundedWidth, 0.5);
458
+
459
+ gradient.addColorStop(0, this._source.warningColor);
460
+ gradient.addColorStop(leftStopPosition, backgroundColor);
445
461
  }
446
- }
447
462
 
448
- if (shape) {
449
- ctx.fillStrokeShape(shape);
463
+ ctx.fillStyle = gradient;
464
+ ctx.fill();
465
+ }
466
+ else {
467
+ ctx.fillStyle = backgroundColor;
468
+ ctx.fill();
450
469
  }
451
470
  }
471
+
472
+ if (shape) {
473
+ ctx.fillStrokeShape(shape);
474
+ }
452
475
  };
453
476
 
454
477
  SourceGroup.prototype._addUnwrap = function(forceCreate) {
@@ -878,7 +901,7 @@ define([
878
901
  this._selected = this._source.selected;
879
902
  if (this._border) {
880
903
  if (this._selected) {
881
- this._border.fill(this._source.selectedColor);
904
+ this._border.fill(this._source.selectedBorderColor);
882
905
  this._borderWidth = this._peaks.options.sourceSelectedBorderWidth;
883
906
  }
884
907
  else {
@@ -895,7 +918,7 @@ define([
895
918
 
896
919
  if (unwrap_background) {
897
920
  if (this._selected) {
898
- unwrap_background.stroke(this._source.selectedColor);
921
+ unwrap_background.stroke(this._source.selectedBorderColor);
899
922
  unwrap_background.strokeWidth(this._peaks.options.sourceSelectedBorderWidth);
900
923
  }
901
924
  else {
@@ -912,7 +935,7 @@ define([
912
935
 
913
936
  if (wrap_background) {
914
937
  if (this._selected) {
915
- wrap_background.stroke(this._source.selectedColor);
938
+ wrap_background.stroke(this._source.selectedBorderColor);
916
939
  wrap_background.strokeWidth(this._peaks.options.sourceSelectedBorderWidth);
917
940
  }
918
941
  else {
@@ -1113,14 +1136,6 @@ define([
1113
1136
  return this._height;
1114
1137
  };
1115
1138
 
1116
- SourceGroup.prototype.getHeights = function() {
1117
- return {
1118
- unwrapped: this._unwrappedHeight,
1119
- wrapped: this._wrappedHeight,
1120
- current: this._height
1121
- };
1122
- };
1123
-
1124
1139
  SourceGroup.prototype.setVisible = function(boolean) {
1125
1140
  this._group.visible(boolean);
1126
1141
  };
@@ -1621,25 +1636,5 @@ define([
1621
1636
  this._group.destroy();
1622
1637
  };
1623
1638
 
1624
- /**
1625
- * Static method to get height for a source
1626
- * @param {Source} source - The source object
1627
- * @param {Object} peaks - The peaks instance (for options)
1628
- * @returns {number} The calculated height
1629
- */
1630
- SourceGroup.getHeights = function(source, peaks) {
1631
- var unwrappedHeight = source.binaryHeight && source.previewHeight ?
1632
- source.binaryHeight + source.previewHeight :
1633
- peaks.options.lineHeight;
1634
- var wrappedHeight = peaks.options.wrappedLineHeight;
1635
- var height = source.wrapped ? wrappedHeight : unwrappedHeight;
1636
-
1637
- return {
1638
- unwrapped: unwrappedHeight,
1639
- wrapped: wrappedHeight,
1640
- current: height
1641
- };
1642
- };
1643
-
1644
1639
  return SourceGroup;
1645
1640
  });