-
Notifications
You must be signed in to change notification settings - Fork 719
[css-scroll-snap-1] Avoid page scrolling skipping past snappable items #10914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Naively for built-in interactions, the UA could do something like select a snap area which scrolls no further than 100% of the scrollport if possible, though I wonder if there's some way we could make this work for programmatic scrolls as well as in the scrollTo example? E.g. we could say that for any scrolls less than or equal to 1 scrollport, we try to select a snap area which keeps the scroll less than that distance. I say "try" because developers can position snap areas arbitrarily far apart and we should make some progress in the requested scrolling direction. |
Alternately a more generic option could be to snap in a way that scrolls no more than the requested distance if possible. This would ensure that page-down never scrolls more than 85% unless that is necessary to go to the next snap area. |
The CSS Working Group just discussed
The full IRC log of that discussion |
From @dholbert:
|
Indeed; I'm pretty sure this is how we implement the The |
As per w3c#10914 when selecting a snap point as a result of a scroll by page operation we should always select a snap position that is less than a page away if one exists.
) As per #10914 when selecting a snap point as a result of a scroll by page operation we should always select a snap position that is less than a page away if one exists.
could we make snapping more conservative and choose the nearer of the points instead of the further? |
This originally came up from @johannesodland as a potential issue with scroll-buttons in #10722 (comment) however it's a pre-existing generic issue with scroll-snap, so filing it separately.
When a user pages down, usually by pressing the page-down key, they expect to scroll no further than one page if that is a valid scroll location. However, some browsers can select the next snap point as the target resulting in a scroll of more than a scrollport in length.
E.g. if you have a scrollport height of 1000px, most browsers will try to scroll by 850px. If however the nearest snappable element has a snap alignment that is further, then it can be selected, resulting in scrolls even greater than 1000px and an experience where content has been skipped over - even when that content itself defined a valid snap area. We should fix this so that it's easy to make an experience where
Codepen demo using page-down key: https://codepen.io/flackr/pen/abgeOKY
Original demo from @johannesodland using
scrollTo
api: https://codepen.io/johannesodland/pen/WNqmoYyThe text was updated successfully, but these errors were encountered: