Repository navigation
fix(view): one wheel notch stops within about 0.2 s in every view (#522) - #532
Merged
Merged
Conversation
The single-page view scrolled with a velocity that decayed per frame, so the run-out depended on the frame rate: on a heavy drawing at about 20 frames per second one notch kept moving for over 2 seconds and went about twice as far as the notch. The other views left wheel scrolling to the browser. A shared helper (js/pdf/wiel-scroll.js) now gives every view the same behaviour: a mouse-wheel notch moves exactly its distance with a short time-based ease-out (180 ms), quick notches add up without lag or overshoot, a notch back reverses at once (also at the scroll edge), and touchpad scrolling stays 1:1 without added smoothing. Page flipping at the page edge, Ctrl+wheel zoom and smooth jumps to a page or search result are unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #522.
What happened
In single-page mode the wheel added velocity that decayed by a fixed factor per animation frame. The run-out therefore depended on the frame rate: measured with a fake clock, one notch (deltaY 100) kept moving for 285 ms at 144 fps, 683 ms at 60 fps and about 2 seconds at 20 fps, which is what a heavy vector page renders at. It also travelled about 207 px instead of 100, and a touchpad swipe got the same floaty run-out. The continuous, book and side-by-side views left the wheel to the browser, so the views behaved differently.
What this changes
js/pdf/wiel-scroll.js, shared by every view:pdf-viewport.js: the friction velocity is gone; the render loop plays the helper.navigation-events.js: single page, continuous, book, side by side and blank documents use the same helper for mouse-wheel notches; touchpad and fine wheel input stay 1:1 (in the scrolling views the browser keeps them). Inputs and elements that scroll themselves keep their own wheel.Behaviour change on purpose: in single-page mode one notch now moves 100 px, like the other views, instead of the earlier ~207 px. If a larger step is wanted, it is one factor in one place.
Verification
js/pdf/wiel-scroll.test.mjs, 22 tests with a fake clock. They were first run against a copy of the old algorithm behind the same calls (14 failed for the reported reasons, e.g. still moving at 285 ms, 207 px instead of 100, five notches 1040 px instead of 500).npm run test:unit2613 passed, 0 failed;npx vite buildandnpm run typecheckgreen.🤖 Generated with Claude Code