Description
Current Implementation State
Chrome is working on implementation of snap points and we are getting close to shipping it. So I spent sometime looking at the current state of various implementation. I have summarized my finding below
Given this, I believe what we will ship initially will match the current subset implemented by Safari with some additional features.
I like to use this issue to start a discussion around a practical plan to get interop on this specification.
Safari , Chrome (Behind a flag)
Safari is shipping a subset of current specification i.e., scrollsnap
since at least Version 11.0.3 and have removed their previous prefixed implementation of old spec.
Chrome has an implementation in Canary channel which can be enabled via --enable-experimental-web-platform-features
flag.
Here is some more detail around which features are implemented:
Safari | Chrome | Test Page | |
---|---|---|---|
Touch | Yes | Yes | webkit demo page [0] |
Wheel | Yes | Yes | |
Scroll Bar | No | Partial[1] | |
Keyboard | No | No | |
Scroll{By,To} | Partial[2] | Yes | wpt test |
Margin | old name [3] | Yes | |
Padding | Yes | Yes | |
Visibility | No | Yes | demo page |
Large Element | No | No | |
Snap-Stop | No | No |
[0] WebKit demo lists only the old syntax but the example use old and new so it works in Safari 11.
[1] Chrome scrollbar snapping only works for dragging
[2] Seem to be working only on viewport scrolling element but no inner scroller
[3] Safari is using scroll-snap-margin
Firefox & Edge
Firefox and Edge still ship the old spefication, i.e., snappoints
.
Path to Interop
Firefox has an issue to implement the new CR specification but there has not been any implementation progress as far I can see since the issue was filed two years ago. The public info on Edge plans suggests that updating the implementation is on the backlog but no new update for past two years.
It will be great to find out more about intention of Firefox and Edge.
Tests
Chrome has been upstreaming tests as we have been implementing the feature. See:
https://wpt.fyi/css/css-scroll-snap/
They cover key aspects but I suspect we need more tests covering edge cases. Hopefully there will be more tests as other implementations update to the new specification
Communication to Authors on Usage of Old Properties
I wasn't able to find a lot of content on how the spec has evolved and how common patterns of usage can be migrated or potentially implemented in a way to work in both versions of the spec.
If we expect the old properties to continue being used for a while longer, I feel such communication may be valuable.
For example a horizontal carrousel can be implemented as follow:
.container {
overflow-x: scroll;
/* old spec */
scroll-snap-type: mandatory;
snap-destination: 50% 50%;
/* new spec */
scroll-snap-type: x mandatory;
}
.center-aligned-child {
/* old spec, probably also use -ms, and -webkit */
scroll-snap-coordinate: 50% 50%;
/* new spec */
scroll-snap-align: center;
}
.start-aligned-child {
/* old spec, probably also use -ms, and -webkit */
scroll-snap-coordinate: 0% 0%;
/* new spec */
scroll-snap-align: start none;
}
.end-aligned-child {
/* old spec, probably also use -ms, and -webkit */
scroll-snap-coordinate: 100% 100%;
/* new spec */
scroll-snap-align: end none;
}
In particular, I suggest we strongly discourage usage of scroll-snap-points-{x, y}
from old syntax since there is no good way to have closely matching behavior without lots of hacks and additional elements.