Re: [csswg-drafts] [css-scroll-snap-1] Avoid page scrolling skipping past snappable items (#10914)

> From @dholbert:
> 
> > FWIW there is a scrollByPages API in Firefox, non-standard:  https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollByPages

Indeed; I'm pretty sure this is how we implement the `Space/PageDown` and `PageUp` scrolling actions under-the-hood (as calls to `scrollByPages(1)` and `scrollByPages(-1)`, from Firefox's frontend JS).  But the JS API is also exposed to the web, too, for historical reasons I guess.

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.

-- 
GitHub Notification of comment by dholbert
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10914#issuecomment-2382134833 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 30 September 2024 05:19:55 UTC