Open cartr opened 3 years ago
Just for the record, Chrome's implementation obviously currently has general problems regarding multi-column elements and scroll snapping, see https://bugs.chromium.org/p/chromium/issues/detail?id=1172771.
It generally needs to be clarified how scroll-snap-*
properties work for multi-column elements, not just scroll-snap-align
but also scroll-padding-*
don't seem to be handled as expected by the browsers.
Sebastian
So there are two issues here; the one being asked, and the one being alluded to by the e-reader use case mentioned in the OP. The latter is addressed in #6017.
For the question of how to snap to a fragmented element, there are a few options:
The first is roughly Chrome's current behavior, the second is Firefox's.
If we do the second, there's then the question of which fragment to snap to when an element is targeted/scrolled-into-view: 2a. the first fragment is always the initial snap 2b. the first fragment is snapped when "start" aligned, the last is snapped when "end" aligned, the middle (???) fragment when "center" aligned
2b has some complications (which fragment is the "middle"? just count by index? weight by size? if # of fragments is even, do we bias toward start or end?) and can be a little confusing if you're start-snapping in one axis and end-snapping in another (this is already handled by the spec, it's just potentially confusing to authors).
So I propose either 1 or 2a, but don't have a strong opinion between them. There might also be other options we haven't thought of.
The CSS Working Group just discussed [css-scroll-snap] Scroll snap areas for fragmented boxes (like in css-multicol)
.
Where does the scroll snap position go when you set
scroll-snap-align
on a block that's fragmented across multiple columns? (Here is a demo that attempts to do this. The goal was to create behavior similar to an e-book reader application, where text is flowed into columns that the user can swipe between.)The CSS Scroll Snap Module says (emphasis mine):
However, the CSS Fragmentation Module appears to suggest that you can't apply transforms to a box, you have to apply transforms to each fragment of the box separately:
My demo actually behaves differently in different browsers. Firefox creates multiple scroll snap positions, one for each fragment. Safari picks a column near the middle and places a single scroll snap position aligned to that column.
So it's not completely clear what's supposed to happen in this situation, and it would be nice if it was specified more clearly.
Personally, I think Firefox's behavior is the best here, mostly because it lets me do the e-book reader thing. I could also see an approach where you draw a bounding box around all the fragments to create a single scroll snap area. Safari's behavior doesn't make much sense to me so I don't think it should be written into the specification.