This is a list of differences between the CSS Scroll Snap Module as maintained by Matt Rakow and the CSS Scroll Snap Module Change Proposal maintained by Tab and fantasai.
At the most recent F2F the group agreed to accept a bunch of changes from Fantasai and Tab. Microsoft asked for some time to do a final review.
While we don't have immediate plans to implement, it would be nice to get the specification stable soon. Can we set a deadline for review, after which we go ahead with the resolution from the meeting?
I'm not sure how much time is necessary. Microsoft?
Dean Jackson, www-style, 10 December 2015
In the interests of F2F time, we are requesting that the WG adopt the following rapid-decision format for resolution of these changes:
+1 | I agree with adopting the new wording. |
---|---|
-1 | I disagree with adopting the new wording. |
+2 | I think the new wording is better than the old one, but I would like to see further improvements, which I will file as a follow-up issue. |
0 | I need more time to decide, please revisit this after the break (during which I promise to review the change, obviously). |
T | I need more time to decide, please revisit this tomorrow morning (at which point I promise to have an opinion or a damned good reason outside of my control to ask for more time). |
Our goal in presenting this list is to close, by the end of the F2F, on all outstanding technical and editorial issues, and by formally adopting the exact wording changes necessary to resolve these issues, remove the need for any further spec-editor discretion in updating the spec. This will allow somebody who actually has the time (i.e. not Matt Rakow) to make the edits so that the spec can be 100% up-to-date by next week rather than sometime in the next six months maybe.
(Of course, not all of these edits are perfect, but insofar as they are better we would like the CSSWG to formally adopt them. Further review, edits, and improvements can then be made once there is a fully up-to-date consensus spec on /TR.)
CSS Scroll Snap
PointsModule Level 1http://www.w3.org/TR/css-
snappointsscroll-snap-1/
s/scroll snap margin/scroll snap area/g;
(In the most recent changes, “margin box” has been replaced with “border box”, but the resulting text is awkward.)Snap positions can be specified as a particular alignment (scroll-snap-align) of an element’s scroll snap area (
its border box, as modified byscroll-snap-margin
, defaulting to its margin boxscroll-snap-margin
) within …
scroll-snap-type
that, since it applies generally to scroll-snapping,
we felt belonged in Overview section that defines
the overall scroll-snapping model
rather than specifically in scroll-snap-type
.
ItThe CSS Scroll Snap Module intentionally does not specify nor mandate any precise animations or physics used to enforce snap positions; this is left up to the user agent.
Name: scroll-snap-type Value none | [ proximity | mandatory ] || [ x | y | block | inline | both ]
The scroll-snap-type property defines … and which axes are considered.
The strictness values (none, proximity, mandatory) specify how strictly snap positions are enforced on the scroll container (by forcing an adjustment to the scroll offset). Values are defined as follows:
…
The axis values specify what axis(es) are affected by snap positions, and whether snap positions are evaluated independently per axis, or together as a 2D point. Values are defined as follows:
- x
- The scroll container axis-snaps to snap positions in its horizontal axis only.
- y
- The scroll container axis-snaps to snap positions in its vertical axis only.
- block
- The scroll container axis-snaps to snap positions in its block axis only.
- inline
- The scroll container axis-snaps to snap positions in its inline axis only.
- both
- The scroll container axis-snaps to snap positions in both of its axises independently (potentially snapping to different elements in each axis).
If no axis value is specified, then the axis is automatically computed:
If the scroll container is only scrollable in one axis (only one axis has its overflow set to auto or scroll) it axis-snaps in the scrollable axis only.
Otherwise, it axis-snaps in its block axis only.
There remains an open issue on whether there should be longhands for this and if so, what the shorthand/longhand names should be.
none
values of the scroll-snap-type
property “trap” descendant scroll snap positions
in order to provide authors a way of blocking upward propagation of snap positions within a box’s content.
(Issue 82 resolved TPAC 2015)
In order to fix this,
Tab and I adjusted the definitions of the scroll-snap-type
strictness values as follows:
- none
If specified on a scroll container, …
If specified on a non-scroll container, this value has no effect.
- proximity
If specified on a scroll container, …
If specified on a non-scroll container, this value “traps” descendant boxes’ snap positions, preventing them from affecting any ancestor scroll containers.
…
- mandatory
- If specified on a scroll container, …
If specified on a non-scroll container, this value “traps” descendant boxes’ snap positions, preventing them from affecting any ancestor scroll containers.
…
We also introduced the term “scroll snap container”
(“snap container” for short)
to represent the scroll container associated to a particular snap position. This term allows us to give a straightforward definition, in one single place, that accounts for the fact that the relevant box is found along the containing block chain, and also that it is intercepted by any intervening elements with a none-none
value for scroll-snap-type
.
The
scroll-snap-type
property specifies whether a scroll container is a scroll snap container …
A box captures snap positions if it is a scroll container or has a value other than
none
forscroll-snap-type
. If a box’s nearest snap-position capturing ancestor on its containing block chain is a scroll container with a non-none
value forscroll-snap-type
, then that is the box’s scroll snap container. Otherwise, the box has no scroll snap container, and its specified snap positions do not trigger snapping.
This also allows the following fix for some imprecise wording in the definition of scroll-snap-align
:
The
scroll-snap-align
property specifieshow an element’s scroll snap margin should align with its ancestor scroll container’s snap alignment containerthe box’s snap position as an alignment of its snap area (as the alignment subject) within its snap container’s snapport (as the alignment container).
mandatory
,
it seems more appropriate to use RFC2119’s “requirement”.
… the scroll container is
guaranteedrequired …
Authors should use mandatory snap positions with consideration of varyingly-sized screens and (if applicable) varying-sized content. In particular, although access to snapped elements larger than the viewport is handled by the UA, if authors assign mandatory snapping to non-adjacent siblings, content in between can become inaccessible in cases where it is longer than the screen. 7
scroll-snap-type
values do.
(This editorial movement is particularly important for authors reading the spec.)
This also allows us to merge the two paragraphs, which are nearly identical,
making the spec overall easier to read and less likely to contain inconsistencies.
If the content changes (e.g. content is added, moved, deleted, resized), the UA must re-evaluate, and potentially re-snap if necessary, the resulting scroll offset once the positions of the content have restabilized. … (stuff about resnapping to the same position) … Otherwise, the scroll container must be re-snapped as if the user had scrolled to its current scroll offset (as an explicit scroll, if no other scroll operation is active).
… If the content changes …
such that the scroll container would no longer be snapped to the same snap position it was snapped to before the content change and that same snap position still exists (e.g. its associated element was not deleted) and is reachable, the scroll container must be re-snapped to that same snap position after the content change… If the content changes … changes such that the scroll container would no longer be snapped (e.g. content is added, moved, deleted, resized) to the same snap position it was snapped to before the content change, the scroll container must be re-snapped. If the same snap position it was snapped to before the content change still exists (e.g. its associated element was not deleted) and is reachable, the scroll container must be re-snapped to that same snap position after the content change.
… If the content changes (e.g. content is added, moved, deleted, resized), the UA must re-evaluate, and potentially re-snap if necessary, the resulting scroll offset once the positions of the content have restabilized. However, if there was a previously-snapped snap position (associated with the same element) that still exists after such changes, the UA must remain snapped to it.
If the content or layout of the scroll container changes e.g. content is added, moved, deleted, resized), the UA must re-evaluate, and potentially re-snap if necessary, the resulting scroll offset once the positions of the content have restabilized. This can result in no snapping, (e.g. if there are no nearby snap positions for a proximitiy-snapping scroll container). However, if there was a previously-snapped snap position (associated with the same element) that still exists after such changes, the UA must remain snapped to it—even if the changes would have placed a different snap position closer to the current scroll offset. Otherwise, the scroll container must be re-snapped as if the user had scrolled to its current scroll offset (as an explicit scroll, if no other scroll operation is active).
Name: scroll-snap-padding Percentages: relative to the corresponding dimension of the scroll container’s visual viewport
Name: scroll-snap-padding Animatable: yesas length, percentage, or calc
Name: scroll-snap-margin Name: yesas length
margin
and border-image-outset
are defined,
which ensures that the assignment of values is fully defined (by reference).
It also clarifies that the bounding box is axis-aligned in the scroll container’s coordinate space.
The <length> values give outsets (interpreted as for margin or border-image-outset). The scroll snap area is the rectangular bounding box of the transformed border box, plus the specified outsets, axis-aligned in the scroll container’s coordinate space.
- <length>{1,4}
- Specifies the outset of the element’s snap margin from the axis-aligned bounding box of the transformed border box, in the scroll container’s coordinate space. Outsets are applied to this bounding box, not the border box.
scroll-snap-align
Merged
The scroll-snap-align property specifieshow an element’s scroll snap margin should align with its ancestor scroll container’s snapportthe box’s snap position as an alignment of its snap area (as the alignment subject) within its snap container’s snapport as the alignment container).
scroll-snap-align
in the proposal we prepared for the WG.
See further explanation.
The following changes are due to this difference:
The two values specify the snapping behavior in the
xblock andyinline axes, respectively.
For all of these values, the block or inline axis is relative to the element’s parent’s writing mode.
scroll-snap-type
property
scroll-snap-padding
property
scroll-snap-margin
property
scroll-snap-align
property
<dfn>
markup for “snap position” back to the first paragraph of the overview and delete the (redundant) definition from the definition list:
This module introduces control over scroll snap positions, which are scroll positions that produce particular alignments of content ithin a scrollable viewport. Using the scroll-snap-type property n the relevant scroll container, the author can request a particular bias for the viewport to land on a valid 2 snap position after scrolling operations.
- snap position
- For a scroll container, a particular value for its scroll offset is a snap position if when scrolled to that offset the visual viewport of the scroll container would align with a descendent element in the manner specified by the scroll snap properties.
scroll-snap-margin
and scroll-snap-padding
, respectively:
- snap alignment container
- A scroll container’s snap alignment container is the rectangle obtained by reducing its visual viewport by its scroll-snap-padding. ISSUE: better name for this concept?
- snap margin
- An element’s snap margin is the rectangle obtained by expanding its border box by its scroll-snap-margin.
The act of adjusting the scroll offset of a scroll container’s visual viewport such that it is aligned to a snap position is called snapping, and a scroll container is said to be snapped to a snap position if its visual viewport’s scroll offset is that snap position and there is no active scrolling operation.
- snapped
- A scroll container is said to be snapped to a snap position if its visual viewport’s scroll offset is that snap position and there is no active scrolling operation.
- snap
- The act of adjusting the scroll offset of a scroll container’s visual viewport such that it is snapped to a snap position is called snapping.
Snap positions are specified as a particular alignment (scroll-snap-align) of an element’s scroll snap area (its border box, as modified by scroll-snap-margin) within the scroll container’s snapport (its visual viewport, as reduced by scroll-snap-padding). This is conceptually equivalent to specifying the alignment of an alignment subject within an alignment container. A scroll position that satisfies the specified alignment is a valid snap position.
Snap positions can be specified as a particular alignment (
scroll-snap-align
) of an element’s scroll snap area (its border bounding box, as modified byscroll-snap-margin
) within the scroll container’s snapport (the rectangle obtained by reducing its visual viewportits visual viewport, as reduced by its scroll-snap-padding).
Snap positions
mustonly affect the nearest ancestor(on the element’scontaining block chain)scroll container on the element’scontaining block chain.
proximity
(the concerns about reachability apply to equally to proximity
, and are therefore handled in the general requirements for “snap positions”):
Adding parentheses to the following sentence (and simplifying it by using a pronoun) helps the reader to know that this case is considered exceptional:the scroll container is required to be snapped to a valid snap position when there are no active scrolling operations.
If a reachable snap position exists, then the scroll container must snap at the termination of a scroll.That is, it must snap to a valid snap position at the termination of a scroll, if any exist.
(If
no reachable snap positionnone exists, then no snapping occurs.)
The scroll-snap-padding property defines the scroll snapport—
a region inset from the visual viewport of a scroll container used in calculating its snap positions. The snapport is used as the alignment container when calculating snap positions.the area of the scrollport that is used as the alignment container of the scroll snap areas when calculating their snap positions.
[ <length> | <percentage> ]{1,4}Specifies the region inset from the visual viewport.Values are interpreted as for padding, and specify inward offsets from each edge of the visual viewport.
The scroll-snap-margin property defines the scroll snap area
on elements within a scroll container, used in calculating snap positions for that scroll containerthat is used for snapping this box to the snapport.
Values are defined as follows:
- none
- This box does not define a snap position in the specified axis.
- start
The scroll offset which aligns the start edge of this box’s scroll snap margin with the start edge of its ancestor scroll container’s region defined by scroll-snap-padding in the specified axis is a snap position in that axis.- Start alignment of this box’s scroll snap area within the scroll container’s snapport is a valid snap position in the specified axis.
- end
The scroll offset which aligns the end edge of this box’s scroll snap margin with the end edge of its ancestor scroll container’s region defined by scroll-snap-padding in the specified axis is a snap position in that axis.- End alignment of this box’s scroll snap area within the scroll container’s snapport is a valid snap position in the specified axis.
- center
The scroll offset which aligns the center of this box’s scroll snap margin with the center of its ancestor scroll container’s region defined by scroll-snap-padding in the specified axis is a snap position in that axis.- Center alignment of this box’s scroll snap area within the scroll container’s snapport is a valid snap position in the specified axis.
scroll-snap-type: none
in that mental model:
&hellip the scroll container must not snap: all scroll positions are equally valid.
… the scroll container may snap to a valid snap position at the termination of a scroll …
… the scroll container is guaranteed to be snapped to a valid snap position when there are no active scrolling operations …
the scroll container may snap to a valid snap position at the termination of a scroll, at the discretion of the UA given the parameters of the scroll.
point
value,
as well as a section about how it works.
(This is, as you can see, clearly labelled as “to be deferred”, however.)
Name: scroll-snap-type Value none | [ proximity | mandatory ] || [ x | y | block | inline | both | point ]
- point
- The scroll container point-snaps to snap positions in both axises simultaneously, treating each element’s snap position as a single 2D position (rather than potentially snapping to different elements in each axis).
7.2. Axis vs Point-Snapping
This feature is planned to be removed in the next publication in order to reduce the feature-set of Level 1. It is included here for future reference in defining Level 2.
…
(A likely use case for point snapping is tiled galleries that do not form a strict grid, as in this example (Flexbox) or this one (Grid). Again, we're happy to leave this to level 2, but do want the feature design published for future reference.)
Many thanks to
lots of people for their proposals and recommendations, some of which are incorporated into this document.David Baron, Simon Fraser, Håkon Wium Lie, Edward O'Connor, François Remy, Majid Valpour, potentially some anonymous Microsoft engineers (?), and most especially to Robert O'Callahan for their proposals and recommendations, which have been incorporated into this document.
Anyway, here is some feedback about the new draft. I hope it's not ignored again.
Robert O'Callahan, www-style, 30 January 2014