- From: Robert Flack via GitHub <noreply@w3.org>
- Date: Thu, 06 Nov 2025 15:32:09 +0000
- To: public-css-archive@w3.org
> The [`scrollByPages()` implementation is here](https://searchfox.org/mozilla-central/rev/72d959d715d3f832328057600811c09ee5195ae1/dom/base/nsGlobalWindowInner.cpp#3909-3926) if anyone's curious to see it. That function calls a generic C++ `ScrollBy()` function that's shared by a bunch of programmatic scrolling APIs, and the most relevant piece there for `scrollByPages` is the [`GetPageScrollAmount()`](https://searchfox.org/mozilla-central/rev/72d959d715d3f832328057600811c09ee5195ae1/layout/generic/ScrollContainerFrame.cpp#5161-5192) function, which defines what it means to scroll by a page. In this case we want to be a bit smarter about what it means to scroll by a page - in particular, avoiding scrolling further than a full page as a result of snapping to avoid skipping content. Currently, the algorithm we have in chrome to do this does so by [having three constraints](https://source.chromium.org/chromium/chromium/src/+/main:cc/input/snap_selection_strategy.cc;l=55;drc=c8dc70b538f1bb0862f1be58237d6e945ee81819) - an optimal scroll distance which seems equivalent to `GetPageScrollAmount()` you pointed to above, as well as a minimum and maximum (a full visible screen of content). Then, this is used to find a snap target that is as close to the optimal distance but not further than the maximum (avoiding skipped content). If this is not possible (e.g. the next snap target is more than a page away), then it will skip further. -- GitHub Notification of comment by flackr Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10914#issuecomment-3497842094 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Thursday, 6 November 2025 15:32:12 UTC