-
Notifications
You must be signed in to change notification settings - Fork 759
Description
The issue
When snapping to items that are larger than the viewport, the spec declares that the user must be able to freely scroll while the edges of the item do not yet meet the edges of the scroll container. See https://www.w3.org/TR/css-scroll-snap-1/#snap-overflow for details.
But what happens when you always want a scroll container to snap to the first edge of the target item after a scroll action? Right now, according to the spec, a scroll container always snaps to the specified edge. Regardless of the direction the user is scrolling in.
Demo of the problem:
Scroll down and back up in small steps to replicate the unwanted behaviour.
To clarify, I would like to:
- Snap to top when a user scrolls down
- Snap to bottom to user scroll up
Expected behaviour:
Proposed solution
This problem can be addressed with new values on scroll-snap-align. One for each edge a scroll container can snap to. Looking from the perspective of the scroll direction: the start edge or the end edge. Center is center regardless of the scroll direction.
Considered options
First idea:
nearest-edgefarthest-edge
Alternative, more explicit:
scroll-direction-startscroll-direction-end
Shorter alternative:
direction-startdirection-end
Alternative solution
Introduce a new key scroll-snap-overscroll-behaviour with the values auto & contain. Where contain would implement this same behaviour. But that might break the expectations a developer might have for scroll-snap-align, and create conflicting rules.
Disclaimer: I'm the author of PanelSnap, and would like my package to become obsolete.