Skip to content

fix(web): keep the page index when reopening a book in scroll mode - #741

Merged
hectorqin merged 1 commit into
mainfrom
devin/1795663127-reopen-page-index
Nov 26, 2026
Merged

hectorqin merged 1 commit into
mainfrom
devin/1795663127-reopen-page-index

Conversation

@hectorqin

@hectorqin hectorqin commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

In the Android shell, reopening a book left on page 3/7 restored the right text but showed 2/7. The page counter was wrong; the text position was not.

Root cause: scroll-mode restore in ReaderView computes scrollTop = limit * sectionOffset from the r1 locator. The locator offset is rounded to 4 decimals, and Android WebView rounds scrollTop again on top of that (1170.485 → 1170.182, then 1169.818 on a second restore). The result lands just before page 3's boundary, outside the 1px tolerance in scrollPage.

Fix: when restoring, if the target is within 1px + limit * LOCATOR_OFFSET_ROUNDING_ERROR of a page boundary, snap to that boundary (via the new screenBoundaryAt, which scrollPage now shares). Positions in the middle of a page and the locator format are unchanged. web/test/reader-paging.test.ts covers both the snap case and the middle-of-page case.

Verified on an API 35 emulator: before the fix it went 3/7 → 2/7 on reopen; with the fix it stays 3/7. Desktop Chromium never reproduced it, and still shows 3/7 with the fix.

Android before Android after
before after

Julia opened this PR for Qin
Implemented in session Test issue 735 on Android emulator
Review with Devin · Open in Devin Desktop


Co-Authored-By: qin hector <hectorq.me@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@hectorqin
hectorqin merged commit 8b93e1f into main Nov 26, 2026
10 checks passed
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