Skip to content

Commit 98d303d

Browse files
committed
[css-snappoints] Adding point snapping and axis syntax to scroll-snap-type with alternative syntax proposal based loosely on suggestion from Tab, for discussion in f2f tomorrow
1 parent 810f63d commit 98d303d

1 file changed

Lines changed: 101 additions & 3 deletions

File tree

css-snappoints/Overview.bs

Lines changed: 101 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,12 @@ Capturing Scroll Snap Areas: Properties on the scroll container {#properties-on
252252
██ ██ ██ ████████
253253
-->
254254

255-
Snapping Rules: the 'scroll-snap-type' property {#scroll-snap-type}
255+
Scroll Snapping Rules: the 'scroll-snap-type' property {#scroll-snap-type}
256256
-------------------------------------------------------------------
257257

258258
<pre class="propdef">
259259
Name: scroll-snap-type
260-
Value: none | mandatory | proximity
260+
Value: none | [ [ mandatory | proximity ] [ x | y | block | inline ]? ]{1,2} | [ mandatory | proximity ] point
261261
Initial: none
262262
Applies to: all elements
263263
Inherited: no
@@ -267,7 +267,14 @@ Snapping Rules: the 'scroll-snap-type' property {#scroll-snap-type}
267267
Animatable: no
268268
</pre>
269269

270-
The 'scroll-snap-type' property defines how strictly a <a>scroll container</a> should <a>snap</a>.
270+
The 'scroll-snap-type' property specifies how strictly a <a>scroll container</a> should <a>snap</a>, and which axes are considered.
271+
272+
The <dfn noexport lt="strictness value">strictness values</dfn>
273+
(''scroll-snap-type/none'', ''proximity'', ''mandatory'')
274+
specify how strictly
275+
<a>snap positions</a> are enforced on the <a>scroll container</a>
276+
(by forcing an adjustment to the scroll offset).
277+
Values are defined as follows:
271278

272279
Issue: <a href="https://lists.w3.org/Archives/Public/www-style/2015Nov/0328.html">Open issue</a> on whether to enhance the scroll-snap-type property for specifying the axis or adding a second property. We have <a href="https://lists.w3.org/Archives/Public/www-style/2015Dec/0048.html">resolved</a> that this functionality be added once the issue is resolved.
273280

@@ -291,6 +298,42 @@ Snapping Rules: the 'scroll-snap-type' property {#scroll-snap-type}
291298
If the content changes such that the scroll container would no longer be <a>snapped</a> (e.g. content is added, moved, deleted, resized) 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.
292299
</dl>
293300

301+
The <dfn noexport lt="axis value">axis values</dfn>
302+
specify what axis(es) are affected by <a>snap positions</a>,
303+
and whether <a>snap positions</a> are evaluated independently per axis,
304+
or together as a 2D point.
305+
Values are defined as follows:
306+
307+
<dl dfn-type=value dfn-for="scroll-snap-type">
308+
<dt><dfn>x</dfn>
309+
<dd>
310+
The <a>scroll container</a> <a>axis-snaps</a> to <a>snap positions</a> in its horizontal axis using the corresponding <a>strictness value</a>.
311+
312+
<dt><dfn>y</dfn>
313+
<dd>
314+
The <a>scroll container</a> <a>axis-snaps</a> to <a>snap positions</a> in its vertical axis using the corresponding <a>strictness value</a>.
315+
316+
<dt><dfn>block</dfn>
317+
<dd>
318+
The <a>scroll container</a> <a>axis-snaps</a> to <a>snap positions</a> in its block axis using the corresponding <a>strictness value</a>.
319+
320+
<dt><dfn>inline</dfn>
321+
<dd>
322+
The <a>scroll container</a> <a>axis-snaps</a> to <a>snap positions</a> in its inline axis using the corresponding <a>strictness value</a>.
323+
324+
<dt><dfn>point</dfn>
325+
<dd>
326+
The <a>scroll container</a> <a>point-snaps</a> to <a>snap positions</a> in both axises simultaneously,
327+
treating each element’s <a>snap position</a> as a single 2D position
328+
(rather than potentially snapping to different elements in each axis).
329+
</dl>
330+
331+
If <a>axis values</a> are not specified, then the axis is automatically computed:
332+
333+
* If only one <a>strictness value</a> is specified, the <a>scroll container</a> <a>axis-snaps</a> in both axes using that <a>strictness value</a>.
334+
* If two <a>strictness values</a> are specified and no <a>axis values</a> are specified, the <a>scroll container</a> <a>axis-snaps</a> in the horizontal axis using the first <a>strictness value</a> and in the vertical axis using the second <a>strictness value</a>.
335+
* If two <a>strictness values</a> are specified and one <a>axis value</a> is specified, the axis perpendicular to the specified <a>axis value</a> is used for the other <a>strictness value</a>.
336+
294337
Advisement:
295338
Authors should use mandatory snap positions with consideration of
296339
varyingly-sized screens and (if applicable) varying-sized content.
@@ -444,6 +487,61 @@ Scroll Snapping Alignment: the 'scroll-snap-align' property {#scroll-snap-align}
444487
The scroll offset which aligns the center of this box's scroll snap area with the center of its ancestor scroll container's region defined by 'scroll-snap-padding' in the specified axis is a <a>snap position</a> in that axis.
445488
</dl>
446489

490+
<!--
491+
██ ████████ ███████ ████████
492+
████ ██ ██ ██ ██ ██ ██
493+
██ ██ ██ ██ ██ ██
494+
██ ██ ██ ███████ ██ ██
495+
██ ██ ██ ██ ██ ██
496+
██ ██ ██ ██ ██ ██
497+
██████ ████████ █████████ ████████
498+
-->
499+
500+
Axis vs Point-Snapping {#snap-dimensions}
501+
-----------------------------------------
502+
503+
Issue: This feature is planned to be removed in the next publication
504+
in order to reduce the feature-set of Level 1.
505+
It is included here for future reference in defining Level 2.
506+
507+
There are two distinct <dfn lt="snap behavior|snapping behavior">snapping behaviors</dfn> that a <a>scroll container</a> might engage in:
508+
509+
: <dfn export local-lt="axis" lt="axis-snapping|axis-snap">axis-snapping</dfn>
510+
:: If a <a>scroll container</a> is <a>axis-snapping</a>,
511+
its descendants indicate a desired scroll position
512+
in each axis of the <a>scroll container</a> independently,
513+
with no dependent preference for what the other axis's scroll position should be.
514+
515+
Note: This is the “default” type of <a>snap behavior</a>
516+
that most <a>scroll containers</a> will want to use,
517+
and so the ''scroll-snap-type'' property intentionally defaults to it.
518+
519+
Note: An element in an <a>axis-snapping</a> <a>scroll container</a>
520+
can declare two <a>snap positions</a>,
521+
one in each axis.
522+
If one of the element's <a>snap positions</a> is chosen in one axis,
523+
this has no bearing on the other dimension's <a>snap position</a>--
524+
it might be chosen,
525+
or a different element's <a>snap position</a> might be chosen for that axis,
526+
or that axis might not snap at all.
527+
528+
: <dfn export local-lt="point" lt="point-snapping|point-snap">point-snapping</dfn>
529+
:: If a <a>scroll container</a> is <a>point-snapping</a>,
530+
its descendants indicate a desired scroll position
531+
in both axises of the <a>scroll container</a> simultaneously--
532+
in other words,
533+
some point in the descendant must be aligned to a corresponding point in the <a>scroll container</a>.
534+
535+
This type of <a>snapping behavior</a> is intended for "two-dimensional" panning-type layouts,
536+
such as cities on a map
537+
(using ''proximity'' 2D snap positions to snap a city to the center of the display when it gets close),
538+
or a tiled image gallery
539+
(using ''mandatory'' 2D snap positions to force each image to be centered on the screen).
540+
In both of these cases,
541+
it would look weird if the horizontal scrolling was aligned to one element
542+
while the vertical was aligned to a different element
543+
(which is the behavior you'd get if the <a>scroll container</a> was <a>axis-snapping</a>).
544+
447545
<!--
448546
██ ███████ ██ ██ ██████ ██ ██ ███ ██ ██ ████████ ██████
449547
██ ██ ██ ███ ██ ██ ██ ██ ██ ██ ██ ███ ██ ██ ██ ██ ██

0 commit comments

Comments
 (0)