Skip to content

Scroll to the right page when reading Bottom to Top - #836

Merged
ajslater merged 1 commit into
developfrom
fix-btt-vertical-page-scroll
Sep 2, 2026
Merged

Scroll to the right page when reading Bottom to Top#836
ajslater merged 1 commit into
developfrom
fix-btt-vertical-page-scroll

Conversation

@ajslater

@ajslater ajslater commented Sep 2, 2026

Copy link
Copy Markdown
Owner

The bug

The vertical pager hands v-virtual-scroll a list of page numbers and
reverses that list for bottom-to-top reading, so page 0 becomes the last
item and the last page becomes the first.

scrollToIndex takes an index into that list, but scrollToPage passed the
page number straight through as if it were one. In Bottom to Top every jump
therefore landed on the mirrored page: opening a comic at page 0 scrolled to
the last page, page 1 of 10 showed page 9, and so on. The offset calculation
clamps rather than erroring, so it failed silently.

Bottom to Top is the only reading direction that is both vertical and
reversed, so it is the only one affected. Top to Bottom was always correct,
because there a page number really is its own index.

Page tracking was never wrong in either direction. The intersection observer
reads the real page number off the element, so only jumping to a page was
affected, not reporting which page you are on.

The fix

Look the page up in items instead of assuming it is the index. Deriving it
from the list rather than repeating the reversal means it keeps working
however that list comes to be built.

Testing

Four tests covering both directions, including Top to Bottom as a regression
guard that the common path still maps a page to its own index.
Mutation-checked: restoring the old call fails all three Bottom to Top cases
and leaves the Top to Bottom one green. Suite is 460 passing, lint clean.

Found while answering whether Vuetify 4.2.0's new scrollToIndex position
argument could simplify this component. It cannot, and that is unrelated to
this fix, which predates the upgrade.

🤖 Generated with Claude Code

The vertical pager hands `v-virtual-scroll` a list of page numbers and
reverses that list for bottom-to-top reading, so page 0 becomes the last
item. `scrollToIndex` takes an index into that list, but `scrollToPage`
passed the page number straight through, so every jump landed on the
mirrored page: opening a comic at page 0 scrolled to the last page.

Look the page up in `items` rather than repeating the reversal, so this
keeps following however that list is built. Top to Bottom is unaffected,
where a page number is already its own index; a test pins that too.

Page tracking was never wrong. The intersection observer reads the real page
number off the element, so only jumping to a page was affected.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ajslater
ajslater merged commit 16eeb72 into develop Sep 2, 2026
3 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