fix(reader): prevent scroll inertia jumps and smooth deceleration - #805
Open
andyWang1688 wants to merge 1 commit into
Open
andyWang1688 wants to merge 1 commit into
andyWang1688 wants to merge 1 commit into
Conversation
Use actual content bounds instead of paginated snap bounds during inertia. Estimate release speed over a time window, integrate decay over elapsed time, and preserve subpixel motion. Add pure-function and browser regression coverage and regenerate the mobile reader. Refs codedogQBY#581. Follow-up to codedogQBY#711.
This branch has not been deployed
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.
Summary
Fix scroll-mode snap-back and abrupt inertia stops introduced by the smooth-reading implementation in #711.
Refs #581. This is a follow-up fix, not a new setting or a change to paginated reading.
Problem
With smooth reading enabled and the reader set to continuous scrolling, releasing a long swipe could jump backward and then trigger an unwanted whole-page transition. In the regression fixture, release at 900px snapped to 620px and then advanced to 1240px.
The drag path updated the actual scroll container, while inertia called
scrollBy(), which clamps against stale one-page snap bounds. These bounds are appropriate for paginated swipes, not continuous scrolling.Additional motion issues were a hard 900ms cutoff, an unweighted average of the last three input events, truncated frame time, and small rounded scroll steps being mistaken for a content boundary.
Changes
No changes to the smooth-reading setting/default, paginated swipe logic, chapter preloading, dependencies, or native signing configuration.
Validation
node --test packages/foliate-js/tests/scroll-inertia.test.js.git diff --checkpasses.For browser tests, serve
packages/foliate-jsover local HTTP, open/tests/scroll-inertia.html, and runawait window.runTimingSuite()andawait window.runSuite()separately in the console. Each result includes a top-levelpassand frame traces.Scope limits: automated gestures use a single horizontal-writing chapter in Chromium, not physical iOS touch input. Browser rAF was throttled, so behavior tests are not FPS measurements. Cross-chapter transitions and vertical writing are not covered by this fixture.