[csswg-drafts] [css-scroll-snap-2] Better snap physics and customization? (#8549)

flackr has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-scroll-snap-2] Better snap physics and customization? ==
We've had requests from developers (e.g. [airbnb](https://bugs.chromium.org/p/chromium/issues/detail?id=1189696#c3), [google search](https://bugs.chromium.org/p/chromium/issues/detail?id=1420772)) to customize the fling curve of snap point scrolls. A common cause or desire is to align behavior, which itself seems partially motivated from the way that browsers haven't given special treatment to scrolling physics for certain snap use cases in the same way that the experiences being emulating have given them different physics.

`scroll-snap-stop` is often used as a simple form of control over the physics (forcing a stop at each item), but even when the typical interaction is to scroll one item at a time developers often want to still allow flings to cross multiple items.

I think expectations may vary based on the size of snap items and lengths of documents, e.g.:
* For long articles with headers that may want to snap, having snap behave similar to normal scrolling likely matches expectations
* For lists with snap points on each item, there is often an expectation that a standard length flick will move about a page of items. The experiment in [crbug.com/1189696](https://bugs.chromium.org/p/chromium/issues/detail?id=1189696) shows that for such use cases it may be as simple as adjusting fling distances to meet expectations here. A paginated book would likely have similar expectations.
* Scrolling within a large snap point should probably match document scrolling but may want to prefer seeing the end of the current snap point rather than jumping to the next snap point.

While some cases the browser may be able to "just do the right thing", I think there are cases that would be helpful if the developer could give the browser a hint what kind of category things fall into.

Some possible ideas:
* Add a `scroll-snap-distance: item | page | document` which hints whether the UA should treat a typical fling as traversing the distance of one item, one page, or a document scroll (the current behavior). Alternately, it could take a length.
* Add a `scroll-snap-friction: #` which applies some amount of friction to getting to scrolling past each subsequent snap point.
* Something else?

I'm not sure what the exact right solution is here but there seems to be a common developer need to apply different physics to different scenarios.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8549 using your GitHub account


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

Received on Thursday, 9 March 2023 00:33:54 UTC