@checksub_team/peaks_timeline 1.15.6 → 1.15.8-alpha.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checksub_team/peaks_timeline",
3
- "version": "1.15.6",
3
+ "version": "1.15.8-alpha.0",
4
4
  "description": "JavaScript UI component for displaying audio waveforms",
5
5
  "main": "./peaks.js",
6
6
  "types": "./peaks.js.d.ts",
package/peaks.js CHANGED
@@ -15105,7 +15105,7 @@ module.exports = function (Konva, Utils) {
15105
15105
  var startLimit = currentSource.prevSourceId ? this._sources[currentSource.prevSourceId].source.endTime : 0;
15106
15106
  var newTimes = this._canBePlacedBetween(source.startTime, source.endTime, startLimit, currentSource.source.startTime);
15107
15107
  if (newTimes) {
15108
- source.updateTimes(newTimes.startTime, newTimes.endTime);
15108
+ source.updateTimes(newTimes.start, newTimes.end);
15109
15109
  if (currentSource.prevSourceId) {
15110
15110
  this._sources[currentSource.prevSourceId].nextSourceId = source.id;
15111
15111
  newSource.prevSourceId = currentSource.prevSourceId;
@@ -15153,23 +15153,23 @@ module.exports = function (Konva, Utils) {
15153
15153
  }
15154
15154
  };
15155
15155
  Line.prototype._canBePlacedBetween = function (startTime, endTime, startLimit, endLimit) {
15156
- var timeWidth = endTime - startTime;
15156
+ var timeWidth = Utils.roundTime(endTime - startTime);
15157
15157
  var newTimes = null;
15158
15158
  if (!endLimit && startTime > startLimit || startTime > startLimit && endTime < endLimit) {
15159
15159
  newTimes = {
15160
- startTime: startTime,
15161
- endTime: endTime
15160
+ start: startTime,
15161
+ end: endTime
15162
15162
  };
15163
- } else if (endLimit - startLimit >= timeWidth) {
15163
+ } else if (Utils.roundTime(endLimit - startLimit) >= timeWidth) {
15164
15164
  if (startTime > startLimit) {
15165
15165
  newTimes = {
15166
- startTime: endLimit - timeWidth,
15167
- endTime: endLimit
15166
+ start: Utils.roundTime(endLimit - timeWidth),
15167
+ end: endLimit
15168
15168
  };
15169
15169
  } else {
15170
15170
  newTimes = {
15171
- startTime: startLimit,
15172
- endTime: startLimit + timeWidth
15171
+ start: startLimit,
15172
+ end: Utils.roundTime(startLimit + timeWidth)
15173
15173
  };
15174
15174
  }
15175
15175
  }
@@ -15212,39 +15212,41 @@ module.exports = function (Konva, Utils) {
15212
15212
  this._y += dy;
15213
15213
  this._group.y(this._group.y() + dy);
15214
15214
  };
15215
- Line.prototype.manageSourceOrder = function (source, newStartX, newEndX) {
15216
- var cursorX = this._view.getPointerPosition().x;
15217
- var tmpXs;
15218
- var newXs = {
15219
- startX: newStartX,
15220
- endX: newEndX
15221
- };
15222
- var sourceWidth = this._view.timeToPixels(source.endTime - source.startTime);
15223
- if (newStartX !== null && newEndX !== null) {
15215
+ Line.prototype.manageSourceOrder = function (source, newTimes) {
15216
+ var cursorTime = this._view.pixelsToTime(this._view.getPointerPosition().x);
15217
+ var tmpTimes;
15218
+ var sourceDuration = source.endTime - source.startTime;
15219
+ if (newTimes.start !== null && newTimes.end !== null) {
15224
15220
  if (this._sources[source.id].prevSourceId) {
15225
- var previousStartX = this._view.timeToPixels(this._sources[this._sources[source.id].prevSourceId].source.startTime);
15226
- if (cursorX + this._view.getFrameOffset() < previousStartX) {
15227
- tmpXs = this._changeSourcePosition(source, sourceWidth, cursorX + this._view.getFrameOffset());
15228
- if (tmpXs) {
15229
- newXs.startX = tmpXs.startTime;
15230
- newXs.endX = tmpXs.endTime;
15221
+ var previousStartTime = this._sources[this._sources[source.id].prevSourceId].source.startTime;
15222
+ if (cursorTime + this._view.getTimeOffset() < previousStartTime) {
15223
+ tmpTimes = this._changeSourcePosition(source, sourceDuration, cursorTime + this._view.getTimeOffset());
15224
+ if (tmpTimes) {
15225
+ newTimes.start = tmpTimes.start;
15226
+ newTimes.end = tmpTimes.end;
15231
15227
  }
15232
15228
  }
15233
15229
  }
15234
15230
  if (this._sources[source.id].nextSourceId) {
15235
- var nextEndX = this._view.timeToPixels(this._sources[this._sources[source.id].nextSourceId].source.endTime);
15236
- if (cursorX + this._view.getFrameOffset() > nextEndX) {
15237
- tmpXs = this._changeSourcePosition(source, sourceWidth, cursorX + this._view.getFrameOffset());
15238
- if (tmpXs) {
15239
- newXs.startX = tmpXs.startTime;
15240
- newXs.endX = tmpXs.endTime;
15231
+ var nextEndTime = this._sources[this._sources[source.id].nextSourceId].source.endTime;
15232
+ if (cursorTime + this._view.getTimeOffset() > nextEndTime) {
15233
+ tmpTimes = this._changeSourcePosition(source, sourceDuration, cursorTime + this._view.getTimeOffset());
15234
+ if (tmpTimes) {
15235
+ newTimes.start = tmpTimes.start;
15236
+ newTimes.end = tmpTimes.end;
15241
15237
  }
15242
15238
  }
15243
15239
  }
15244
15240
  }
15245
- return newXs;
15241
+ if (newTimes.start) {
15242
+ newTimes.start = Utils.roundTime(newTimes.start);
15243
+ }
15244
+ if (newTimes.end) {
15245
+ newTimes.end = Utils.roundTime(newTimes.end);
15246
+ }
15247
+ return newTimes;
15246
15248
  };
15247
- Line.prototype._changeSourcePosition = function (source, sourceWidth, x) {
15249
+ Line.prototype._changeSourcePosition = function (source, sourceDuration, time) {
15248
15250
  if (source.orderable && this._firstSourceId) {
15249
15251
  var currentRange = {
15250
15252
  start: null,
@@ -15260,19 +15262,25 @@ module.exports = function (Konva, Utils) {
15260
15262
  currentRange.end = this._sources[currentRange.start.nextSourceId];
15261
15263
  }
15262
15264
  if (currentRange.start) {
15263
- startLimit = this._view.timeToPixels(currentRange.start.source.endTime);
15265
+ startLimit = currentRange.start.source.endTime;
15264
15266
  } else {
15265
15267
  startLimit = 0;
15266
15268
  }
15267
15269
  if (currentRange.end) {
15268
- endLimit = this._view.timeToPixels(currentRange.end.source.startTime);
15270
+ endLimit = currentRange.end.source.startTime;
15269
15271
  } else {
15270
15272
  endLimit = null;
15271
15273
  }
15272
- if (x > startLimit && (endLimit === null || x < endLimit)) {
15273
- var newTimes = this._canBePlacedBetween(x, x + sourceWidth, startLimit, endLimit);
15274
+ if (time > startLimit && (endLimit === null || time < endLimit)) {
15275
+ var newTimes = this._canBePlacedBetween(time, time + sourceDuration, startLimit, endLimit);
15274
15276
  if (newTimes) {
15275
- source.updateTimes(this._view.pixelsToTime(newTimes.startTime), this._view.pixelsToTime(newTimes.endTime));
15277
+ if (newTimes.start) {
15278
+ newTimes.start = Utils.roundTime(newTimes.start);
15279
+ }
15280
+ if (newTimes.end) {
15281
+ newTimes.end = Utils.roundTime(newTimes.end);
15282
+ }
15283
+ source.updateTimes(newTimes.start, newTimes.end);
15276
15284
  var prevSourceId = currentRange.start ? currentRange.start.source.id : null;
15277
15285
  this._moveSource(this._sources[source.id].source, prevSourceId);
15278
15286
  return newTimes;
@@ -15308,20 +15316,16 @@ module.exports = function (Konva, Utils) {
15308
15316
  }
15309
15317
  this._sources[source.id] = sourceObj;
15310
15318
  };
15311
- Line.prototype.manageCollision = function (source, newStartX, newEndX) {
15319
+ Line.prototype.manageCollision = function (source, newTimes) {
15312
15320
  var originalStartTime = null;
15313
15321
  var originalEndTime = null;
15314
15322
  var newStartTime = null;
15315
15323
  var newEndTime = null;
15316
15324
  var startLimited = false;
15317
15325
  var endLimited = false;
15318
- var newXs = {
15319
- startX: newStartX,
15320
- endX: newEndX,
15321
- updateTimelineLength: false
15322
- };
15323
- if (newStartX !== null) {
15324
- originalStartTime = this._view.pixelsToTime(newStartX);
15326
+ newTimes.updateTimelineLength = false;
15327
+ if (newTimes.start !== null) {
15328
+ originalStartTime = newTimes.start;
15325
15329
  newStartTime = originalStartTime;
15326
15330
  if (source.startTime > newStartTime) {
15327
15331
  if (this._sources[source.id].prevSourceId) {
@@ -15338,8 +15342,8 @@ module.exports = function (Konva, Utils) {
15338
15342
  }
15339
15343
  }
15340
15344
  }
15341
- if (newEndX !== null) {
15342
- originalEndTime = this._view.pixelsToTime(newEndX);
15345
+ if (newTimes.end !== null) {
15346
+ originalEndTime = newTimes.end;
15343
15347
  newEndTime = originalEndTime;
15344
15348
  if (source.endTime < newEndTime) {
15345
15349
  if (this._sources[source.id].nextSourceId) {
@@ -15352,42 +15356,42 @@ module.exports = function (Konva, Utils) {
15352
15356
  }
15353
15357
  }
15354
15358
  if (newStartTime !== null && newEndTime !== null) {
15355
- var timeWidth = Utils.roundTime(originalEndTime - originalStartTime);
15359
+ var timeWidth = originalEndTime - originalStartTime;
15356
15360
  if (startLimited) {
15357
- newEndTime = newStartTime + timeWidth;
15361
+ newEndTime = Utils.roundTime(newStartTime + timeWidth);
15358
15362
  }
15359
15363
  if (endLimited) {
15360
- newStartTime = newEndTime - timeWidth;
15364
+ newStartTime = Utils.roundTime(newEndTime - timeWidth);
15361
15365
  }
15362
15366
  }
15363
15367
  if (newStartTime !== null && newEndTime === null) {
15364
- if (source.endTime - newStartTime < source.minSize) {
15365
- newStartTime = source.endTime - source.minSize;
15368
+ if (Utils.roundTime(source.endTime - newStartTime) < source.minSize) {
15369
+ newStartTime = Utils.roundTime(source.endTime - source.minSize);
15366
15370
  }
15367
15371
  } else if (newEndTime !== null && newStartTime === null) {
15368
- if (newEndTime - source.startTime < source.minSize) {
15369
- newEndTime = source.startTime + source.minSize;
15372
+ if (Utils.roundTime(newEndTime - source.startTime) < source.minSize) {
15373
+ newEndTime = Utils.roundTime(source.startTime + source.minSize);
15370
15374
  }
15371
15375
  } else {
15372
- if (newEndTime - newStartTime < source.minSize) {
15376
+ if (Utils.roundTime(newEndTime - newStartTime) < source.minSize) {
15373
15377
  if (source.endTime !== newEndTime) {
15374
- newEndTime = newStartTime + source.minSize;
15378
+ newEndTime = Utils.roundTime(newStartTime + source.minSize);
15375
15379
  }
15376
15380
  if (source.startTime !== newStartTime) {
15377
- newStartTime = newEndTime - source.minSize;
15381
+ newStartTime = Utils.roundTime(newEndTime - source.minSize);
15378
15382
  }
15379
15383
  }
15380
15384
  }
15381
15385
  if (newStartTime !== null && newStartTime !== originalStartTime) {
15382
- newXs.startX = this._view.timeToPixels(newStartTime);
15386
+ newTimes.start = newStartTime;
15383
15387
  }
15384
15388
  if (newEndTime !== null && newEndTime !== originalEndTime) {
15385
- newXs.endX = this._view.timeToPixels(newEndTime);
15389
+ newTimes.end = newEndTime;
15386
15390
  if (this._sources[source.id].nextSourceId === null) {
15387
- newXs.updateTimelineLength = true;
15391
+ newTimes.updateTimelineLength = true;
15388
15392
  }
15389
15393
  }
15390
- return newXs;
15394
+ return newTimes;
15391
15395
  };
15392
15396
  Line.prototype.getSourcesAfter = function (time) {
15393
15397
  const sources = [];
@@ -15699,11 +15703,11 @@ module.exports = function (SegmentsGroup, Line, LineIndicator, Utils) {
15699
15703
  }
15700
15704
  }
15701
15705
  };
15702
- Lines.prototype.manageCollision = function (source, newStartX, newEndX) {
15703
- return this._linesBySourceId[source.id].manageCollision(source, newStartX, newEndX);
15706
+ Lines.prototype.manageCollision = function (source, newTimes) {
15707
+ return this._linesBySourceId[source.id].manageCollision(source, newTimes);
15704
15708
  };
15705
- Lines.prototype.manageSourceOrder = function (source, newStartX, newEndX) {
15706
- return this._linesBySourceId[source.id].manageSourceOrder(source, newStartX, newEndX);
15709
+ Lines.prototype.manageSourceOrder = function (source, newTimes) {
15710
+ return this._linesBySourceId[source.id].manageSourceOrder(source, newTimes);
15707
15711
  };
15708
15712
  Lines.prototype._setInteractions = function (position) {
15709
15713
  var line = this._linesByPosition[position];
@@ -18164,8 +18168,11 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Loader, Konva)
18164
18168
  this._rightHandle.x(this._width - handleWidth);
18165
18169
  };
18166
18170
  SourceGroup.prototype._onSourceGroupHandleDrag = function (draggedElement, dragPos, leftHandle) {
18171
+ const diff = this._view.pixelsToTime(dragPos.x - this._mouseDownX);
18172
+ const timeOffsetDiff = this._view.getTimeOffset() - this._initialTimeOffset;
18173
+ const {start, end} = this._initialTimes;
18167
18174
  this._view.updateWithAutoScroll(function () {
18168
- if (this._layer.updateSource(this._source, leftHandle ? dragPos.x + this._view.getFrameOffset() : null, leftHandle ? null : dragPos.x + draggedElement.width() + this._view.getFrameOffset())) {
18175
+ if (this._layer.updateSource(this._source, leftHandle ? start + diff + timeOffsetDiff : null, leftHandle ? null : end + diff + timeOffsetDiff)) {
18169
18176
  this._layer.draw();
18170
18177
  }
18171
18178
  }.bind(this));
@@ -18230,6 +18237,18 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Loader, Konva)
18230
18237
  this._rightHandle.height(this._unwrappedHeight);
18231
18238
  }
18232
18239
  };
18240
+ SourceGroup.prototype._onHandleDragStart = function () {
18241
+ this._initialTimeOffset = this._view.getTimeOffset();
18242
+ this._mouseDownX = this._view.getPointerPosition().x;
18243
+ this._initialTimes = {
18244
+ start: this._source.startTime,
18245
+ end: this._source.endTime
18246
+ };
18247
+ this._hideButtons();
18248
+ };
18249
+ SourceGroup.prototype._onHandleDragEnd = function () {
18250
+ this._showButtons();
18251
+ };
18233
18252
  SourceGroup.prototype._addHandles = function (forceCreate) {
18234
18253
  var self = this;
18235
18254
  var handleWidth = Math.min(this._peaks.options.sourceHandleWidth, this._width / 2);
@@ -18244,12 +18263,8 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Loader, Konva)
18244
18263
  return self._onSourceGroupHandleDrag(this, pos, true);
18245
18264
  }
18246
18265
  });
18247
- this._leftHandle.on('dragstart', function () {
18248
- self._hideButtons();
18249
- });
18250
- this._leftHandle.on('dragend', function () {
18251
- self._showButtons();
18252
- });
18266
+ this._leftHandle.on('dragstart', this._onHandleDragStart.bind(this));
18267
+ this._leftHandle.on('dragend', this._onHandleDragEnd.bind(this));
18253
18268
  if (this._source.resizable) {
18254
18269
  this._leftHandle.on('mouseover', function () {
18255
18270
  self._cursor = 'ew-resize';
@@ -18270,12 +18285,8 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Loader, Konva)
18270
18285
  return self._onSourceGroupHandleDrag(this, pos, false);
18271
18286
  }
18272
18287
  });
18273
- this._rightHandle.on('dragstart', function () {
18274
- self._hideButtons();
18275
- });
18276
- this._rightHandle.on('dragend', function () {
18277
- self._showButtons();
18278
- });
18288
+ this._rightHandle.on('dragstart', this._onHandleDragStart.bind(this));
18289
+ this._rightHandle.on('dragend', this._onHandleDragEnd.bind(this));
18279
18290
  if (this._source.resizable) {
18280
18291
  this._rightHandle.on('mouseover', function () {
18281
18292
  self._cursor = 'ew-resize';
@@ -20434,9 +20445,9 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
20434
20445
  }
20435
20446
  };
20436
20447
  SourcesLayer.prototype.onSourcesGroupDragStart = function (element) {
20437
- this._initialFrameOffset = this._view.getFrameOffset();
20448
+ this._initialTimeOffset = this._view.getTimeOffset();
20438
20449
  this._mouseDownX = this._view.getPointerPosition().x;
20439
- this._selectedElements = {};
20450
+ this._activeElements = {};
20440
20451
  const draggedElementId = element.currentTarget.attrs.sourceId;
20441
20452
  const shouldDragSelectedElements = Object.keys(this._view.getSelectedElements()).includes(draggedElementId);
20442
20453
  this._nonSelectedElement = shouldDragSelectedElements ? null : [this._sourcesGroup[draggedElementId].getSource()];
@@ -20451,33 +20462,33 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
20451
20462
  }.bind(this));
20452
20463
  this._view.drawSourcesLayer();
20453
20464
  this._view.updateTimelineLength();
20454
- this._selectedElements = {};
20465
+ this._activeElements = {};
20455
20466
  this._peaks.emit('sources.updated', updatedSources);
20456
20467
  };
20457
20468
  SourcesLayer.prototype.onSourcesGroupDrag = function (draggedElement) {
20458
- this._view.updateWithAutoScroll(this._updateSourcesGroup.bind(this));
20469
+ this._view.updateWithAutoScroll(this._dragSourcesGroup.bind(this));
20459
20470
  return {
20460
20471
  x: draggedElement.absolutePosition().x,
20461
20472
  y: draggedElement.absolutePosition().y
20462
20473
  };
20463
20474
  };
20464
- SourcesLayer.prototype._updateSourcesGroup = function () {
20475
+ SourcesLayer.prototype._dragSourcesGroup = function () {
20465
20476
  var mousePos = Math.min(this._view.getWidth() - this._peaks.options.autoScrollThreshold * this._view.getWidth(), Math.max(0, this._view.getPointerPosition().x));
20466
- const diff = mousePos - this._mouseDownX;
20467
- const currentFrameOffset = this._view.getFrameOffset();
20477
+ const diff = this._view.pixelsToTime(mousePos - this._mouseDownX);
20478
+ const timeOffsetDiff = this._view.getTimeOffset() - this._initialTimeOffset;
20468
20479
  const mousePosY = this._view.getPointerPosition().y;
20469
20480
  var newEnd = 0;
20470
20481
  var shouldRedraw = false;
20471
20482
  (this._nonSelectedElement || Object.values(this._view.getSelectedElements())).forEach(function (source) {
20472
- if (!this._selectedElements[source.id]) {
20473
- this._selectedElements[source.id] = {
20474
- startX: this._view.timeToPixels(source.startTime),
20475
- endX: this._view.timeToPixels(source.endTime)
20483
+ if (!this._activeElements[source.id]) {
20484
+ this._activeElements[source.id] = {
20485
+ initialStartTime: source.startTime,
20486
+ initialEndTime: source.endTime
20476
20487
  };
20477
20488
  }
20478
- const {startX, endX} = this._selectedElements[source.id];
20489
+ const {initialStartTime, initialEndTime} = this._activeElements[source.id];
20479
20490
  newEnd = Math.max(newEnd, source.endTime);
20480
- shouldRedraw = this.updateSource(source, startX + diff + (currentFrameOffset - this._initialFrameOffset), endX + diff + (currentFrameOffset - this._initialFrameOffset), mousePosY) || shouldRedraw;
20491
+ shouldRedraw = this.updateSource(source, initialStartTime + diff + timeOffsetDiff, initialEndTime + diff + timeOffsetDiff, mousePosY) || shouldRedraw;
20481
20492
  }.bind(this));
20482
20493
  if (shouldRedraw) {
20483
20494
  this.draw();
@@ -20491,18 +20502,18 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
20491
20502
  return positions[source.position];
20492
20503
  });
20493
20504
  };
20494
- SourcesLayer.prototype.updateSource = function (source, newStartX, newEndX, newY) {
20495
- var newXs = {
20496
- startX: newStartX,
20497
- endX: newEndX
20505
+ SourcesLayer.prototype.updateSource = function (source, startTime, endTime, newY) {
20506
+ var newTimes = {
20507
+ start: startTime,
20508
+ end: endTime
20498
20509
  };
20499
20510
  if (this._peaks.options.canMoveSourcesBetweenLines) {
20500
20511
  this.manageVerticalPosition(source, newY);
20501
20512
  }
20502
- newXs = this.manageSourceOrder(source, newStartX, newEndX);
20503
- newXs = this.manageCollision(source, newXs.startX, newXs.endX);
20504
- source.updateTimes(newXs.startX !== null ? this._view.pixelsToTime(newXs.startX) : null, newXs.endX !== null ? this._view.pixelsToTime(newXs.endX) : null);
20505
- if (newXs) {
20513
+ newTimes = this.manageSourceOrder(source, newTimes);
20514
+ newTimes = this.manageCollision(source, newTimes);
20515
+ source.updateTimes(newTimes.start, newTimes.end);
20516
+ if (newTimes) {
20506
20517
  this._updateSource(source);
20507
20518
  return true;
20508
20519
  }
@@ -20511,11 +20522,11 @@ module.exports = function (SourceGroup, Lines, DataRetriever, Utils, Invoker, Ko
20511
20522
  SourcesLayer.prototype.manageVerticalPosition = function (source, newY) {
20512
20523
  return this._lines.manageVerticalPosition(source, newY);
20513
20524
  };
20514
- SourcesLayer.prototype.manageSourceOrder = function (source, newStartX, newEndX) {
20515
- return this._lines.manageSourceOrder(source, newStartX, newEndX);
20525
+ SourcesLayer.prototype.manageSourceOrder = function (source, newTimes) {
20526
+ return this._lines.manageSourceOrder(source, newTimes);
20516
20527
  };
20517
- SourcesLayer.prototype.manageCollision = function (source, newStartX, newEndX) {
20518
- return this._lines.manageCollision(source, newStartX, newEndX);
20528
+ SourcesLayer.prototype.manageCollision = function (source, newTimes) {
20529
+ return this._lines.manageCollision(source, newTimes);
20519
20530
  };
20520
20531
  SourcesLayer.prototype._updateSource = function (source) {
20521
20532
  var sourceGroup = this._findOrAddSourceGroup(source);
@@ -21608,6 +21619,9 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
21608
21619
  };
21609
21620
  TimelineZoomView.prototype.setZoom = function (newScale) {
21610
21621
  newScale = Math.min(Math.max(this._options.zoomRange[0], newScale), this._options.zoomRange[1]);
21622
+ if (newScale === this._timeToPixelsScale) {
21623
+ return false;
21624
+ }
21611
21625
  var currentTime = this._peaks.player.getCurrentTime();
21612
21626
  var apexTime;
21613
21627
  var playheadOffsetPixels = this._playheadLayer.getPlayheadOffset();
@@ -21621,10 +21635,12 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
21621
21635
  this._timeToPixelsScale = newScale;
21622
21636
  var apexPixel = this.timeToPixels(apexTime);
21623
21637
  this.setFrameOffset(apexPixel - playheadOffsetPixels);
21638
+ this.overrideInteractions(true, true);
21624
21639
  this.updateTimeline(this._frameOffset, undefined, undefined, true);
21625
21640
  this._sourcesLayer.rescale(true);
21626
21641
  this._playheadLayer.updatePlayheadTime(currentTime);
21627
21642
  this._peaks.emit('zoom.update', newScale, prevScale);
21643
+ this.overrideInteractions(false, true);
21628
21644
  return true;
21629
21645
  };
21630
21646
  TimelineZoomView.prototype.getTimelineLength = function () {
@@ -21655,7 +21671,7 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
21655
21671
  this.updateTimeline(this.timeToPixels(time));
21656
21672
  };
21657
21673
  TimelineZoomView.prototype.timeToPixels = function (time) {
21658
- return Utils.roundTime(time) * this._timeToPixelsScale;
21674
+ return Math.round(time * this._timeToPixelsScale);
21659
21675
  };
21660
21676
  TimelineZoomView.prototype.pixelsToTime = function (pixels) {
21661
21677
  return Utils.roundTime(pixels / this._timeToPixelsScale);
@@ -21665,14 +21681,14 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
21665
21681
  };
21666
21682
  TimelineZoomView.prototype.setFrameOffset = function (newFrameOffset) {
21667
21683
  newFrameOffset = Math.max(0, newFrameOffset);
21668
- this._frameOffset = newFrameOffset;
21684
+ this._frameOffset = Math.round(newFrameOffset);
21669
21685
  this._timeOffset = this.pixelsToTime(this._frameOffset);
21670
21686
  };
21671
21687
  TimelineZoomView.prototype.getTimeOffset = function () {
21672
21688
  return this._timeOffset;
21673
21689
  };
21674
21690
  TimelineZoomView.prototype.setTimeOffset = function (newTimeOffset) {
21675
- this._timeOffset = newTimeOffset;
21691
+ this._timeOffset = Utils.roundTime(newTimeOffset);
21676
21692
  this._frameOffset = this.timeToPixels(this._timeOffset);
21677
21693
  };
21678
21694
  TimelineZoomView.prototype.getFrameOffsetY = function () {
package/src/line.js CHANGED
@@ -226,7 +226,7 @@ define([
226
226
  );
227
227
 
228
228
  if (newTimes) {
229
- source.updateTimes(newTimes.startTime, newTimes.endTime);
229
+ source.updateTimes(newTimes.start, newTimes.end);
230
230
 
231
231
  if (currentSource.prevSourceId) {
232
232
  this._sources[currentSource.prevSourceId].nextSourceId = source.id;
@@ -294,28 +294,28 @@ define([
294
294
  };
295
295
 
296
296
  Line.prototype._canBePlacedBetween = function(startTime, endTime, startLimit, endLimit) {
297
- var timeWidth = endTime - startTime;
297
+ var timeWidth = Utils.roundTime(endTime - startTime);
298
298
  var newTimes = null;
299
299
 
300
300
  if ((!endLimit && startTime > startLimit) || (startTime > startLimit && endTime < endLimit)) {
301
301
  // Can be placed at its wanted position with wanted start/end time
302
302
  newTimes = {
303
- startTime: startTime,
304
- endTime: endTime
303
+ start: startTime,
304
+ end: endTime
305
305
  };
306
306
  }
307
- else if (endLimit - startLimit >= timeWidth) {
307
+ else if (Utils.roundTime(endLimit - startLimit) >= timeWidth) {
308
308
  // Can be placed at its wanted position but not with its wanted start/end time
309
309
  if (startTime > startLimit) {
310
310
  newTimes = {
311
- startTime: endLimit - timeWidth,
312
- endTime: endLimit
311
+ start: Utils.roundTime(endLimit - timeWidth),
312
+ end: endLimit
313
313
  };
314
314
  }
315
315
  else {
316
316
  newTimes = {
317
- startTime: startLimit,
318
- endTime: startLimit + timeWidth
317
+ start: startLimit,
318
+ end: Utils.roundTime(startLimit + timeWidth)
319
319
  };
320
320
  }
321
321
  }
@@ -375,65 +375,63 @@ define([
375
375
  this._group.y(this._group.y() + dy);
376
376
  };
377
377
 
378
- Line.prototype.manageSourceOrder = function(source, newStartX, newEndX) {
379
- var cursorX = this._view.getPointerPosition().x;
380
- var tmpXs;
378
+ Line.prototype.manageSourceOrder = function(source, newTimes) {
379
+ var cursorTime = this._view.pixelsToTime(this._view.getPointerPosition().x);
380
+ var tmpTimes;
381
381
 
382
- var newXs = {
383
- startX: newStartX,
384
- endX: newEndX
385
- };
382
+ var sourceDuration = source.endTime - source.startTime;
386
383
 
387
- var sourceWidth = this._view.timeToPixels(source.endTime - source.startTime);
388
-
389
- if (newStartX !== null && newEndX !== null) {
384
+ if (newTimes.start !== null && newTimes.end !== null) {
390
385
  if (this._sources[source.id].prevSourceId) {
391
386
  // there is another source to the left
392
- var previousStartX = this._view.timeToPixels(
393
- this._sources[this._sources[source.id].prevSourceId].source.startTime
394
- );
387
+ var previousStartTime = this._sources[this._sources[source.id].prevSourceId].source.startTime;
395
388
 
396
- if (cursorX + this._view.getFrameOffset() < previousStartX) {
389
+ if (cursorTime + this._view.getTimeOffset() < previousStartTime) {
397
390
  // we want to change order
398
- tmpXs = this._changeSourcePosition(
391
+ tmpTimes = this._changeSourcePosition(
399
392
  source,
400
- sourceWidth,
401
- cursorX + this._view.getFrameOffset()
393
+ sourceDuration,
394
+ cursorTime + this._view.getTimeOffset()
402
395
  );
403
396
 
404
- if (tmpXs) {
405
- newXs.startX = tmpXs.startTime;
406
- newXs.endX = tmpXs.endTime;
397
+ if (tmpTimes) {
398
+ newTimes.start = tmpTimes.start;
399
+ newTimes.end = tmpTimes.end;
407
400
  }
408
401
  }
409
402
  }
410
403
 
411
404
  if (this._sources[source.id].nextSourceId) {
412
405
  // there is another source to the right
413
- var nextEndX = this._view.timeToPixels(
414
- this._sources[this._sources[source.id].nextSourceId].source.endTime
415
- );
406
+ var nextEndTime = this._sources[this._sources[source.id].nextSourceId].source.endTime;
416
407
 
417
- if (cursorX + this._view.getFrameOffset() > nextEndX) {
408
+ if (cursorTime + this._view.getTimeOffset() > nextEndTime) {
418
409
  // we want to change order
419
- tmpXs = this._changeSourcePosition(
410
+ tmpTimes = this._changeSourcePosition(
420
411
  source,
421
- sourceWidth,
422
- cursorX + this._view.getFrameOffset()
412
+ sourceDuration,
413
+ cursorTime + this._view.getTimeOffset()
423
414
  );
424
415
 
425
- if (tmpXs) {
426
- newXs.startX = tmpXs.startTime;
427
- newXs.endX = tmpXs.endTime;
416
+ if (tmpTimes) {
417
+ newTimes.start = tmpTimes.start;
418
+ newTimes.end = tmpTimes.end;
428
419
  }
429
420
  }
430
421
  }
431
422
  }
432
423
 
433
- return newXs;
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;
434
432
  };
435
433
 
436
- Line.prototype._changeSourcePosition = function(source, sourceWidth, x) {
434
+ Line.prototype._changeSourcePosition = function(source, sourceDuration, time) {
437
435
  if (source.orderable && this._firstSourceId) {
438
436
  var currentRange = {
439
437
  start: null,
@@ -452,35 +450,38 @@ define([
452
450
  }
453
451
 
454
452
  if (currentRange.start) {
455
- startLimit = this._view.timeToPixels(
456
- currentRange.start.source.endTime
457
- );
453
+ startLimit = currentRange.start.source.endTime;
458
454
  }
459
455
  else {
460
456
  startLimit = 0;
461
457
  }
462
458
 
463
459
  if (currentRange.end) {
464
- endLimit = this._view.timeToPixels(
465
- currentRange.end.source.startTime
466
- );
460
+ endLimit = currentRange.end.source.startTime;
467
461
  }
468
462
  else {
469
463
  endLimit = null;
470
464
  }
471
465
 
472
- if (x > startLimit && (endLimit === null || x < endLimit)) {
466
+ if (time > startLimit && (endLimit === null || time < endLimit)) {
473
467
  var newTimes = this._canBePlacedBetween(
474
- x,
475
- x + sourceWidth,
468
+ time,
469
+ time + sourceDuration,
476
470
  startLimit,
477
471
  endLimit
478
472
  );
479
473
 
480
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
+ }
481
+
481
482
  source.updateTimes(
482
- this._view.pixelsToTime(newTimes.startTime),
483
- this._view.pixelsToTime(newTimes.endTime)
483
+ newTimes.start,
484
+ newTimes.end
484
485
  );
485
486
  var prevSourceId = currentRange.start
486
487
  ? currentRange.start.source.id
@@ -534,7 +535,7 @@ define([
534
535
  this._sources[source.id] = sourceObj;
535
536
  };
536
537
 
537
- Line.prototype.manageCollision = function(source, newStartX, newEndX) {
538
+ Line.prototype.manageCollision = function(source, newTimes) {
538
539
  var originalStartTime = null;
539
540
  var originalEndTime = null;
540
541
  var newStartTime = null;
@@ -542,15 +543,11 @@ define([
542
543
  var startLimited = false;
543
544
  var endLimited = false;
544
545
 
545
- var newXs = {
546
- startX: newStartX,
547
- endX: newEndX,
548
- updateTimelineLength: false
549
- };
546
+ newTimes.updateTimelineLength = false;
550
547
 
551
- if (newStartX !== null) {
548
+ if (newTimes.start !== null) {
552
549
  // startMarker changed
553
- originalStartTime = this._view.pixelsToTime(newStartX);
550
+ originalStartTime = newTimes.start;
554
551
  newStartTime = originalStartTime;
555
552
 
556
553
  if (source.startTime > newStartTime) {
@@ -575,9 +572,9 @@ define([
575
572
  }
576
573
  }
577
574
 
578
- if (newEndX !== null) {
575
+ if (newTimes.end !== null) {
579
576
  // endMarker changed
580
- originalEndTime = this._view.pixelsToTime(newEndX);
577
+ originalEndTime = newTimes.end;
581
578
  newEndTime = originalEndTime;
582
579
 
583
580
  if (source.endTime < newEndTime) {
@@ -598,52 +595,52 @@ define([
598
595
 
599
596
  // Update the other edge if dragging and collision
600
597
  if (newStartTime !== null && newEndTime !== null) {
601
- var timeWidth = Utils.roundTime(originalEndTime - originalStartTime);
598
+ var timeWidth = originalEndTime - originalStartTime;
602
599
 
603
600
  if (startLimited) {
604
- newEndTime = newStartTime + timeWidth;
601
+ newEndTime = Utils.roundTime(newStartTime + timeWidth);
605
602
  }
606
603
 
607
604
  if (endLimited) {
608
- newStartTime = newEndTime - timeWidth;
605
+ newStartTime = Utils.roundTime(newEndTime - timeWidth);
609
606
  }
610
607
  }
611
608
 
612
609
  // Check for minimal size of source
613
610
  if (newStartTime !== null && newEndTime === null) {
614
- if (source.endTime - newStartTime < source.minSize) {
615
- newStartTime = source.endTime - source.minSize;
611
+ if (Utils.roundTime(source.endTime - newStartTime) < source.minSize) {
612
+ newStartTime = Utils.roundTime(source.endTime - source.minSize);
616
613
  }
617
614
  }
618
615
  else if (newEndTime !== null && newStartTime === null) {
619
- if (newEndTime - source.startTime < source.minSize) {
620
- newEndTime = source.startTime + source.minSize;
616
+ if (Utils.roundTime(newEndTime - source.startTime) < source.minSize) {
617
+ newEndTime = Utils.roundTime(source.startTime + source.minSize);
621
618
  }
622
619
  }
623
620
  else {
624
- if (newEndTime - newStartTime < source.minSize) {
621
+ if (Utils.roundTime(newEndTime - newStartTime) < source.minSize) {
625
622
  if (source.endTime !== newEndTime) {
626
- newEndTime = newStartTime + source.minSize;
623
+ newEndTime = Utils.roundTime(newStartTime + source.minSize);
627
624
  }
628
625
  if (source.startTime !== newStartTime) {
629
- newStartTime = newEndTime - source.minSize;
626
+ newStartTime = Utils.roundTime(newEndTime - source.minSize);
630
627
  }
631
628
  }
632
629
  }
633
630
 
634
631
  if (newStartTime !== null && newStartTime !== originalStartTime) {
635
- newXs.startX = this._view.timeToPixels(newStartTime);
632
+ newTimes.start = newStartTime;
636
633
  }
637
634
 
638
635
  if (newEndTime !== null && newEndTime !== originalEndTime) {
639
- newXs.endX = this._view.timeToPixels(newEndTime);
636
+ newTimes.end = newEndTime;
640
637
 
641
638
  if (this._sources[source.id].nextSourceId === null) {
642
- newXs.updateTimelineLength = true;
639
+ newTimes.updateTimelineLength = true;
643
640
  }
644
641
  }
645
642
 
646
- return newXs;
643
+ return newTimes;
647
644
  };
648
645
 
649
646
  // Line.prototype.rescale = function() {
package/src/lines.js CHANGED
@@ -376,12 +376,12 @@ define([
376
376
  }
377
377
  };
378
378
 
379
- Lines.prototype.manageCollision = function(source, newStartX, newEndX) {
380
- return this._linesBySourceId[source.id].manageCollision(source, newStartX, newEndX);
379
+ Lines.prototype.manageCollision = function(source, newTimes) {
380
+ return this._linesBySourceId[source.id].manageCollision(source, newTimes);
381
381
  };
382
382
 
383
- Lines.prototype.manageSourceOrder = function(source, newStartX, newEndX) {
384
- return this._linesBySourceId[source.id].manageSourceOrder(source, newStartX, newEndX);
383
+ Lines.prototype.manageSourceOrder = function(source, newTimes) {
384
+ return this._linesBySourceId[source.id].manageSourceOrder(source, newTimes);
385
385
  };
386
386
 
387
387
  // Lines.prototype.rescale = function() {
@@ -167,12 +167,17 @@ define([
167
167
  };
168
168
 
169
169
  SourceGroup.prototype._onSourceGroupHandleDrag = function(draggedElement, dragPos, leftHandle) {
170
+ const diff = this._view.pixelsToTime(dragPos.x - this._mouseDownX);
171
+ const timeOffsetDiff = this._view.getTimeOffset() - this._initialTimeOffset;
172
+
173
+ const { start, end } = this._initialTimes;
174
+
170
175
  this._view.updateWithAutoScroll(
171
176
  function() {
172
177
  if (this._layer.updateSource(
173
178
  this._source,
174
- leftHandle ? dragPos.x + this._view.getFrameOffset() : null,
175
- leftHandle ? null : dragPos.x + draggedElement.width() + this._view.getFrameOffset()
179
+ leftHandle ? start + diff + timeOffsetDiff : null,
180
+ leftHandle ? null : end + diff + timeOffsetDiff
176
181
  )) {
177
182
  this._layer.draw();
178
183
  }
@@ -265,6 +270,21 @@ define([
265
270
  }
266
271
  };
267
272
 
273
+ SourceGroup.prototype._onHandleDragStart = function() {
274
+ this._initialTimeOffset = this._view.getTimeOffset();
275
+ this._mouseDownX = this._view.getPointerPosition().x;
276
+ this._initialTimes = {
277
+ start: this._source.startTime,
278
+ end: this._source.endTime
279
+ };
280
+
281
+ this._hideButtons();
282
+ };
283
+
284
+ SourceGroup.prototype._onHandleDragEnd = function() {
285
+ this._showButtons();
286
+ };
287
+
268
288
  SourceGroup.prototype._addHandles = function(forceCreate) {
269
289
  var self = this;
270
290
  var handleWidth = Math.min(this._peaks.options.sourceHandleWidth, this._width / 2);
@@ -281,13 +301,9 @@ define([
281
301
  }
282
302
  });
283
303
 
284
- this._leftHandle.on('dragstart', function() {
285
- self._hideButtons();
286
- });
304
+ this._leftHandle.on('dragstart', this._onHandleDragStart.bind(this));
287
305
 
288
- this._leftHandle.on('dragend', function() {
289
- self._showButtons();
290
- });
306
+ this._leftHandle.on('dragend', this._onHandleDragEnd.bind(this));
291
307
 
292
308
  if (this._source.resizable) {
293
309
  this._leftHandle.on('mouseover', function() {
@@ -312,13 +328,9 @@ define([
312
328
  }
313
329
  });
314
330
 
315
- this._rightHandle.on('dragstart', function() {
316
- self._hideButtons();
317
- });
331
+ this._rightHandle.on('dragstart', this._onHandleDragStart.bind(this));
318
332
 
319
- this._rightHandle.on('dragend', function() {
320
- self._showButtons();
321
- });
333
+ this._rightHandle.on('dragend', this._onHandleDragEnd.bind(this));
322
334
 
323
335
  if (this._source.resizable) {
324
336
  this._rightHandle.on('mouseover', function() {
@@ -336,9 +336,9 @@ define([
336
336
  };
337
337
 
338
338
  SourcesLayer.prototype.onSourcesGroupDragStart = function(element) {
339
- this._initialFrameOffset = this._view.getFrameOffset();
339
+ this._initialTimeOffset = this._view.getTimeOffset();
340
340
  this._mouseDownX = this._view.getPointerPosition().x;
341
- this._selectedElements = {};
341
+ this._activeElements = {};
342
342
 
343
343
  const draggedElementId = element.currentTarget.attrs.sourceId;
344
344
  const shouldDragSelectedElements = Object.keys(this._view.getSelectedElements()).includes(
@@ -366,13 +366,13 @@ define([
366
366
  this._view.drawSourcesLayer();
367
367
  this._view.updateTimelineLength();
368
368
 
369
- this._selectedElements = {};
369
+ this._activeElements = {};
370
370
 
371
371
  this._peaks.emit('sources.updated', updatedSources);
372
372
  };
373
373
 
374
374
  SourcesLayer.prototype.onSourcesGroupDrag = function(draggedElement) {
375
- this._view.updateWithAutoScroll(this._updateSourcesGroup.bind(this));
375
+ this._view.updateWithAutoScroll(this._dragSourcesGroup.bind(this));
376
376
 
377
377
  return {
378
378
  x: draggedElement.absolutePosition().x,
@@ -380,7 +380,7 @@ define([
380
380
  };
381
381
  };
382
382
 
383
- SourcesLayer.prototype._updateSourcesGroup = function() {
383
+ SourcesLayer.prototype._dragSourcesGroup = function() {
384
384
  var mousePos = Math.min(
385
385
  this._view.getWidth() - this._peaks.options.autoScrollThreshold * this._view.getWidth(),
386
386
  Math.max(
@@ -389,28 +389,28 @@ define([
389
389
  )
390
390
  );
391
391
 
392
- const diff = mousePos - this._mouseDownX;
393
- const currentFrameOffset = this._view.getFrameOffset();
392
+ const diff = this._view.pixelsToTime(mousePos - this._mouseDownX);
393
+ const timeOffsetDiff = this._view.getTimeOffset() - this._initialTimeOffset;
394
394
  const mousePosY = this._view.getPointerPosition().y;
395
395
  var newEnd = 0;
396
396
  var shouldRedraw = false;
397
397
 
398
398
  (this._nonSelectedElement || Object.values(this._view.getSelectedElements())).forEach(function(source) {
399
- if (!this._selectedElements[source.id]) {
400
- this._selectedElements[source.id] = {
401
- startX: this._view.timeToPixels(source.startTime),
402
- endX: this._view.timeToPixels(source.endTime)
399
+ if (!this._activeElements[source.id]) {
400
+ this._activeElements[source.id] = {
401
+ initialStartTime: source.startTime,
402
+ initialEndTime: source.endTime
403
403
  };
404
404
  }
405
405
 
406
- const { startX, endX } = this._selectedElements[source.id];
406
+ const { initialStartTime, initialEndTime } = this._activeElements[source.id];
407
407
 
408
408
  newEnd = Math.max(newEnd, source.endTime);
409
409
 
410
410
  shouldRedraw = this.updateSource(
411
411
  source,
412
- startX + diff + (currentFrameOffset - this._initialFrameOffset),
413
- endX + diff + (currentFrameOffset - this._initialFrameOffset),
412
+ initialStartTime + diff + timeOffsetDiff,
413
+ initialEndTime + diff + timeOffsetDiff,
414
414
  mousePosY
415
415
  ) || shouldRedraw;
416
416
  }.bind(this));
@@ -435,26 +435,25 @@ define([
435
435
  );
436
436
  };
437
437
 
438
- SourcesLayer.prototype.updateSource = function(source, newStartX, newEndX, newY) {
439
- var newXs = {
440
- startX: newStartX,
441
- endX: newEndX
438
+ SourcesLayer.prototype.updateSource = function(source, startTime, endTime, newY) {
439
+ var newTimes = {
440
+ start: startTime,
441
+ end: endTime
442
442
  };
443
443
 
444
444
  if (this._peaks.options.canMoveSourcesBetweenLines) {
445
445
  this.manageVerticalPosition(source, newY);
446
446
  }
447
447
 
448
- newXs = this.manageSourceOrder(source, newStartX, newEndX);
449
-
450
- newXs = this.manageCollision(source, newXs.startX, newXs.endX);
448
+ newTimes = this.manageSourceOrder(source, newTimes);
449
+ newTimes = this.manageCollision(source, newTimes);
451
450
 
452
451
  source.updateTimes(
453
- newXs.startX !== null ? this._view.pixelsToTime(newXs.startX) : null,
454
- newXs.endX !== null ? this._view.pixelsToTime(newXs.endX) : null
452
+ newTimes.start,
453
+ newTimes.end
455
454
  );
456
455
 
457
- if (newXs) {
456
+ if (newTimes) {
458
457
  this._updateSource(
459
458
  source
460
459
  );
@@ -468,12 +467,12 @@ define([
468
467
  return this._lines.manageVerticalPosition(source, newY);
469
468
  };
470
469
 
471
- SourcesLayer.prototype.manageSourceOrder = function(source, newStartX, newEndX) {
472
- return this._lines.manageSourceOrder(source, newStartX, newEndX);
470
+ SourcesLayer.prototype.manageSourceOrder = function(source, newTimes) {
471
+ return this._lines.manageSourceOrder(source, newTimes);
473
472
  };
474
473
 
475
- SourcesLayer.prototype.manageCollision = function(source, newStartX, newEndX) {
476
- return this._lines.manageCollision(source, newStartX, newEndX);
474
+ SourcesLayer.prototype.manageCollision = function(source, newTimes) {
475
+ return this._lines.manageCollision(source, newTimes);
477
476
  };
478
477
 
479
478
  /**
@@ -599,6 +599,10 @@ define([
599
599
  TimelineZoomView.prototype.setZoom = function(newScale) {
600
600
  newScale = Math.min(Math.max(this._options.zoomRange[0], newScale), this._options.zoomRange[1]);
601
601
 
602
+ if (newScale === this._timeToPixelsScale) {
603
+ return false;
604
+ }
605
+
602
606
  var currentTime = this._peaks.player.getCurrentTime();
603
607
  var apexTime;
604
608
  var playheadOffsetPixels = this._playheadLayer.getPlayheadOffset();
@@ -623,6 +627,9 @@ define([
623
627
 
624
628
  this.setFrameOffset(apexPixel - playheadOffsetPixels);
625
629
 
630
+ // Block interactions while updating the view.
631
+ this.overrideInteractions(true, true);
632
+
626
633
  this.updateTimeline(this._frameOffset, undefined, undefined, true);
627
634
 
628
635
  this._sourcesLayer.rescale(true);
@@ -632,6 +639,9 @@ define([
632
639
 
633
640
  this._peaks.emit('zoom.update', newScale, prevScale);
634
641
 
642
+ // Re-enable interactions after updating the view.
643
+ this.overrideInteractions(false, true);
644
+
635
645
  return true;
636
646
  };
637
647
 
@@ -679,7 +689,7 @@ define([
679
689
  */
680
690
 
681
691
  TimelineZoomView.prototype.timeToPixels = function(time) {
682
- return Utils.roundTime(time) * this._timeToPixelsScale;
692
+ return Math.round(time * this._timeToPixelsScale);
683
693
  };
684
694
 
685
695
  /**
@@ -704,7 +714,7 @@ define([
704
714
 
705
715
  TimelineZoomView.prototype.setFrameOffset = function(newFrameOffset) {
706
716
  newFrameOffset = Math.max(0, newFrameOffset);
707
- this._frameOffset = newFrameOffset;
717
+ this._frameOffset = Math.round(newFrameOffset);
708
718
  this._timeOffset = this.pixelsToTime(this._frameOffset);
709
719
  };
710
720
 
@@ -713,7 +723,7 @@ define([
713
723
  };
714
724
 
715
725
  TimelineZoomView.prototype.setTimeOffset = function(newTimeOffset) {
716
- this._timeOffset = newTimeOffset;
726
+ this._timeOffset = Utils.roundTime(newTimeOffset);
717
727
  this._frameOffset = this.timeToPixels(this._timeOffset);
718
728
  };
719
729
 
@@ -722,7 +732,7 @@ define([
722
732
  * in pixels.
723
733
  */
724
734
 
725
- TimelineZoomView.prototype.getFrameOffsetY = function() {
735
+ TimelineZoomView.prototype.getFrameOffsetY = function() {
726
736
  return this._frameOffsetY;
727
737
  };
728
738
 
@@ -738,7 +748,7 @@ define([
738
748
  * @returns {Number} The width of the whole view, in pixels.
739
749
  */
740
750
 
741
- TimelineZoomView.prototype.getOriginalWidth = function() {
751
+ TimelineZoomView.prototype.getOriginalWidth = function() {
742
752
  return this._originalWidth;
743
753
  };
744
754