Skip to content

fix: quadratic scroll speed in smooth scrolling causes enormous jumps#52

Open
karlvr wants to merge 1 commit intovioletlib:masterfrom
karlvr:fix/smooth-scroll-quadratic-bug
Open

fix: quadratic scroll speed in smooth scrolling causes enormous jumps#52
karlvr wants to merge 1 commit intovioletlib:masterfrom
karlvr:fix/smooth-scroll-quadratic-bug

Conversation

@karlvr
Copy link
Copy Markdown
Contributor

@karlvr karlvr commented Mar 17, 2026

The smooth scrolling path in getUnitsToScroll(MouseWheelEvent e, boolean isSmooth) used e.getUnitsToScroll() (which is scrollAmount * wheelRotation) multiplied by e.getPreciseWheelRotation() (which is ~wheelRotation). This squares the wheel rotation, causing scroll distance to grow quadratically with scroll speed rather than linearly.

Fix: use e.getScrollAmount() (the per-notch amount, typically 3) instead of e.getUnitsToScroll() so the rotation is only applied once via getPreciseWheelRotation().

The smooth scrolling path in getUnitsToScroll() used e.getUnitsToScroll()
(which is scrollAmount * wheelRotation) multiplied by
e.getPreciseWheelRotation() (which is ~wheelRotation). This
squares the wheel rotation, causing scroll distance to grow quadratically
with scroll speed rather than linearly.

Fix: use e.getScrollAmount() (the per-notch amount, typically 3) instead
of e.getUnitsToScroll() so the rotation is only applied once via
getPreciseWheelRotation().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant