Skip to content

Commit ac57a83

Browse files
committed
[css-scroll-snap] Better terminology, simplify definition of too-large snap areas and turn the rules into an example
1 parent b994681 commit ac57a83

File tree

1 file changed

+61
-34
lines changed

1 file changed

+61
-34
lines changed

css-scroll-snap/Overview.bs

Lines changed: 61 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -214,15 +214,21 @@ Scroll Snapping Model {#snap-model}
214214
Valid <a>snap positions</a> can be specified
215215
as a particular alignment ('scroll-snap-align')
216216
of an element's <a>scroll snap area</a> ('scroll-snap-area', defaulting to its margin box)
217-
within the <a>scroll container</a>’s viewport
218-
(as modified by 'scroll-snap-padding').
217+
within the <a>scroll container</a>’s <a>snap target area</a>
218+
(its viewport, as reduced by 'scroll-snap-padding').
219219
This is conceptually equivalent to specifying the alignment of
220220
an <a>alignment subject</a> within an <a>alignment container</a>.
221+
The scroll position that satisfies the specified alignment
222+
is a valid <a>snap position</a>.
221223

222224
Valid <a>snap positions</a> can also be specified explicitly
223225
as coordinates of the <a>scrollable area</a>
224226
with the 'scroll-snap-points-x' and 'scroll-snap-points-y' properties.
225227

228+
Issue: Discuss <a>intertial</a> vs <a>semantic</a> scrolling concepts (or drop from spec)
229+
230+
Issue: Discuss 1D vs 2D snapping behaviors... and scoping. (This is all related?)
231+
226232
Scroll Snapping Container {#snap-container}
227233
=========================
228234

@@ -298,7 +304,7 @@ Scroll Snapping Rules: the 'scroll-snap-type' property {#snap-type}
298304
<dt><dfn>single</dfn>
299305
<dd>
300306
This keyword indicates that for <a>inertial scrolls</a>,
301-
the next <a>snap position</a>in the direction of the inertia
307+
the next <a>snap position</a> in the direction of the inertia
302308
captures all remaining inertia.
303309
</dl>
304310

@@ -322,13 +328,35 @@ Scroll Snapping Window: the 'scroll-snap-padding' property {#snap-padding}
322328
Media: interactive
323329
</pre>
324330

325-
The 'scroll-snap-padding' property defines the area of the viewport
326-
that is used as the <a>alignment container</a>
327-
when aligning <a>scroll snap areas</a> to a <a>snap position</a>.
331+
The 'scroll-snap-padding' property defines the <dfn local-lt="snap target area">scroll snap target area</dfn>--
332+
the area of the viewport that is used as the <a>alignment container</a>
333+
when aligning a <a>scroll snap area</a> to a <a>snap position</a>.
328334
Values are interpreted as for 'padding',
329-
and specify inward offsets from each side.
335+
and specify inward offsets from each side of the viewport.
336+
337+
<div class="example">
338+
In this example, points of interest in a map are centered
339+
within the portion of the viewport that does not include the toolbar overlay.
340+
341+
<pre>
342+
map {
343+
overflow: scroll;
344+
scroll-snap-type: proximity;
345+
scroll-snap-padding: 3em 0 0 0;
346+
}
347+
toolbar {
348+
position: absolute;
349+
margin: 0.5em;
350+
top: 0; left: 0; right: 0;
351+
height: 2em;
352+
}
353+
city {
354+
scroll-snap-align: center;
355+
}
356+
</pre>
357+
</div>
330358

331-
Issue: Add illustration.
359+
<div class="example">
332360

333361
Coordinate-based Snapping {#snap-points}
334362
=========================
@@ -370,13 +398,16 @@ Scroll Snapping Coordinates: the 'scroll-snap-points-x' and 'scroll-snap-points-
370398
and clamp the computed value to that minimum.
371399
</dl>
372400

373-
Issue: We changed the initial value to make it so that the start and end of the scrollable area are always reachable and snappable.
401+
Coordinates specified by 'scroll-snap-points-x' and 'scroll-snap-points-y'
402+
are not affected by 'scroll-snap-padding'/'scroll-snap-destination'.
374403

375404
Issue: Should we add ''start-edge'' and ''end-edge'' keywords here, so that the start and end of the scrollable area can be defined as reachable?
376405
This would be good for e.g. maps. (See <a href="https://lists.w3.org/Archives/Public/www-style/2015Jul/0453.html">Matt Rakow's take</a> on not having ''start'' or ''end'' here.)
377406

378407
Issue: It was <a href="https://lists.w3.org/Archives/Public/www-style/2015Jul/0453.html">suggested</a> that repeat() be mutually exclusive with element-based snap positions. Is there a better way to integrate this than having the initial value here be "elements"?
379408

409+
Issue: This needs logical equivalents (-block/-inline instead of -x/-y).
410+
380411
Element-based Snapping {#element}
381412
======================
382413

@@ -412,37 +443,33 @@ Scroll Snapping Alignment: the 'scroll-snap-align' property {#scroll-snap-align}
412443
</pre>
413444

414445
Specifies the element's <a>snap position</a> as an alignment of
415-
its box (as the <a>alignment subject</a>) within the viewport (as the <a>alignment container</a>).
446+
its <a>snap area</a> (as the <a>alignment subject</a>)
447+
within the viewport's <a>snap target area</a> (as the <a>alignment container</a>).
416448

417449
The first value specifies alignment in the inline axis;
418450
the second value specifies alignment in the block axis.
419451
If one value is specified, it is duplicated.
420452

421-
### Snap Alignment in Small Viewports ### {#small-viewports}
453+
If the <a>snap area</a> is larger than the <a>snap target area</a> in a particular axis,
454+
then any scroll position in which the <a>snap area</a> covers the <a>snap target area</a>
455+
is a valid <a>snap position</a> in that axis.
456+
The UA may use the specified alignment as a more precise target
457+
for certain scroll operations (e.g. inertial scrolling or explicit paging).
422458

423-
The snapped position of a box is given by its 'scroll-snap-align' property.
424-
However, if its <a>scroll snap area</a> is larger than the viewport...
425-
426-
* Inertial scrolling (and scroll-adjustment caused by snapping)
427-
continues to align to the specified <a>snap position</a> as normal.
428-
429-
* For explicit/programmatic (non-fling) scrolling:
430-
431-
* While the area fully fills the viewport in a given axis,
432-
snapping is ignored in that axis:
433-
the container can be scrolled arbitrarily and will not react.
434-
435-
* If the container is scrolled such that the area
436-
no longer fully fills the viewport in an axis,
437-
the area acts as if it has both-edges snapping in that axis,
438-
resisting outward scrolling until you fling out
439-
or pull it sufficiently to trigger snapping to a different snap-position
440-
(with either proximity or mandatory behavior as appropriate).
441-
442-
As an example, imagine a photo as the area, or a slide in a slideshow.
443-
You want mandatory snapping from item to item,
444-
but if the item happens to be larger than your viewport,
445-
you want to be able to scroll around the whole thing once you're over it.
459+
<div class="example">
460+
For example, imagine a photo as the area, or a slide in a slideshow.
461+
The author wants mandatory snapping from item to item,
462+
but if the item happens to be larger than your viewport,
463+
you want to be able to scroll around the whole thing once you're over it.
464+
465+
Since the <a>snap area</a> is larger than the <a>snap target area</a>,
466+
while the area fully fills the viewport,
467+
the container can be scrolled arbitrarily and will not try to snap back to its aligned position.
468+
However, if the container is scrolled such that the area
469+
no longer fully fills the viewport in an axis,
470+
the area resisting outward scrolling
471+
until you fling out or pull it sufficiently to trigger snapping to a different <a>snap position</a>.
472+
</div>
446473

447474
<!--
448475
### Combining 1D and 2D Snap Alignments ### {#combo-snapping}

0 commit comments

Comments
 (0)