Repository navigation
Fixed: Preserve horizontal pan and zoom when scrolling - #572
Conversation
The wheel handler and the top and bottom limit clamps recentered the viewport horizontally, so a zoomed-in canvas that had been dragged sideways jumped back to the middle as soon as it was scrolled. The scrollbar refit the layout width instead, which also recentered the viewport and, when zoomed in past the page width, reset the zoom. Keep the horizontal position when scrolling with the wheel or the scrollbar. The clamps keep the target x because OpenSeadragon raises the pan event for an animated drag step before the view moves; the current x would drop that step's horizontal movement at the limits. Refs DDMAL#569
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (1)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughWheel scrolling, top and bottom clamping, and scrollbar interactions now preserve the viewport’s current horizontal centre. Browser tests check that vertical scrolling preserves horizontal position and zoom, and that panning after scrolling changes horizontal position. ChangesViewport scrolling
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The scrolling change has no identified issue that needs resolution before merge; normal checks remain appropriate. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
After zooming in and dragging a canvas horizontally, scrolling with the mouse wheel or trackpad snaps it back to the horizontal center. Dragging the scrollbar does the same.
See #569.
Cause
handleWheelset the new center's x to the column middle (getCenterX()), then calledrecenterBoundsX().clampTop/clampBottomalso panned togetCenterX()when the view reached the first or last page, which also blocked dragging sideways at those limits.scrollToOffset, which fits the full layout width. That recenters x and resets any zoom past fit-width.Fix
getCenter(false)). OSD raisespanfor an animated drag step before the view moves, so using the current x would drop that step's horizontal movement.Test
The new test covers the wheel, a scrollbar thumb drag, and a two-step animated pan against the top limit. It fails on
developand when the clamps use the current x. It waits for the zoom animation to finish because Diva recenters once after the first animation following load. The two-step pan makes the clamp run while a horizontal pan is still animating.Summary by CodeRabbit