Skip to content

Commit

Permalink
Prevent scrolling the zoomview when set to auto zoom
Browse files Browse the repository at this point in the history
See #536
  • Loading branch information
chrisn committed Aug 14, 2024
1 parent 72a1fb4 commit b6e1662
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/scroll-mouse-drag-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,17 @@ ScrollMouseDragHandler.prototype._onMouseMove = function(mousePosX) {
this._seek(time);
}
else {
// Moving the mouse to the left increases the time position of the
// left-hand edge of the visible waveform.
const diff = this._mouseDownX - mousePosX;
const newFrameOffset = this._initialFrameOffset + diff;

if (newFrameOffset !== this._initialFrameOffset) {
this._view.updateWaveform(newFrameOffset);
// TODO: Prevent scrolling when zoomed to fit the waveform to the
// view width. Sometimes the waveform is a few pixels longer.
if (!this._view.isAutoZoom()) {
// Moving the mouse to the left increases the time position of the
// left-hand edge of the visible waveform.
const diff = this._mouseDownX - mousePosX;
const newFrameOffset = this._initialFrameOffset + diff;

if (newFrameOffset !== this._initialFrameOffset) {
this._view.updateWaveform(newFrameOffset);
}
}
}
};
Expand Down
4 changes: 4 additions & 0 deletions src/waveform-zoomview.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,10 @@ WaveformZoomView.prototype._resampleData = function(options) {
this._pixelLength = this._data.length;
};

WaveformZoomView.prototype.isAutoZoom = function() {
return this._zoomLevelAuto;
};

WaveformZoomView.prototype.setStartTime = function(time) {
if (time < 0) {
time = 0;
Expand Down

0 comments on commit b6e1662

Please sign in to comment.