Skip to content
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions draftlogs/7704_fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fix visual jumps when zooming/scrolling through plots [[#7704](https://github.com/plotly/plotly.js/pull/7704)]
12 changes: 12 additions & 0 deletions src/plots/cartesian/dragbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,16 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
return;
}

// Store (sub)plot that initiated a scroll
if (gd._currentScrollingSubplot == null) {
gd._currentScrollingSubplot = plotinfo.id;
}
// Early exit to prevent jitters if this subplot didn't initiate the scroll
if (gd._currentScrollingSubplot !== plotinfo.id) {
e.preventDefault();
return;
}

clearAndResetSelect();

// If a transition is in progress, then disable any behavior:
Expand Down Expand Up @@ -528,6 +538,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
}

// viewbox redraw at first
gd._fullLayout._replotting = true;
updateSubplots(scrollViewBox);
ticksAndAnnotations();

Expand All @@ -537,6 +548,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) {
// no more scrolling is coming
redrawTimer = setTimeout(function() {
if(!gd._fullLayout) return;
gd._currentScrollingSubplot = null;
scrollViewBox = [0, 0, pw, ph];
dragTail();
}, REDRAWDELAY);
Expand Down
1 change: 1 addition & 0 deletions src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -1663,6 +1663,7 @@ plots.purge = function(gd) {
delete gd._editing;
delete gd._mouseDownTime;
delete gd._legendMouseDownTime;
delete gd._currentScrollingSubplot;

// remove all event listeners
if(gd.removeAllListeners) gd.removeAllListeners();
Expand Down