-
Notifications
You must be signed in to change notification settings - Fork 790
Expand file tree
/
Copy pathOverview.bs
More file actions
697 lines (582 loc) · 36.6 KB
/
Overview.bs
File metadata and controls
697 lines (582 loc) · 36.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
<pre class="metadata">
Title: CSS Scroll Snap Module Level 1
Group: csswg
Shortname: css-snappoints
TR: http://www.w3.org/TR/css-snappoints-1/
Level: 1
Status: ED
Previous Version: http://www.w3.org/TR/2016/WD-css-snappoints-1-20160329/
Previous Version: http://www.w3.org/TR/2015/WD-css-snappoints-1-20150326/
Work Status: Exploring
ED: https://drafts.csswg.org/css-snappoints/
Editor: Matt Rakow, Microsoft
Editor: Jacob Rossi, Microsoft
Abstract: This module contains features to control panning and scrolling behavior with "snap positions".
Ignored Terms: containing block chain
</pre>
Issue: <b>This spec is currently undergoing major changes in line with the resolutions in <a href="https://lists.w3.org/Archives/Public/www-style/2015Dec/0048.html">https://lists.w3.org/Archives/Public/www-style/2015Dec/0048.html</a>. During this process it is not safe to assume that the current form will be representative of what it will look like in the future. After the work in process is completed, it will closely resemble <a href="https://drafts.csswg.org/css-scroll-snap/">this proposal</a>.</b>
Introduction {#intro}
=====================
<em>This section is not normative.</em>
Popular UX paradigms for scrollable content frequently employ paging through content,
or sectioning into logical divisions.
This is especially true for touch interactions
where it is quicker and easier for users to quickly pan through a flatly-arranged breadth of content
rather than delving into a heirarchical structure through tap navigation.
For example, it is easier for a user to view many photos in a photo album
by panning through a photo slideshow view
rather than tapping on individual photos in an album.
However, given the imprecise nature of scrolling inputs
like touch panning and mousewheel scrolling,
it is difficult for web developers to guarantee a well-controlled scrolling experience,
in particular creating the effect of paging through content.
For instance, it is easy for a user to land at an awkward scroll position
which leaves a page partially on-screen when panning.
To this end, we introduce scroll snap positions
which enforce the scroll positions that a <a>scroll container's</a> scrollport may end at
after a scrolling operation has completed.
Module interactions {#placement}
--------------------------------
This module extends the scrolling user interface features defined in [[!CSS21]] section 11.1.
None of the properties in this module apply to the ''::first-line'' and ''::first-letter'' pseudo-elements.
Values {#values}
----------------
This specification follows the
<a href="https://www.w3.org/TR/CSS21/about.html#property-defs">CSS property
definition conventions</a> from [[!CSS21]]. Value types not defined in
this specification are defined in CSS Level 2 Revision 1 [[!CSS21]].
Other CSS modules may expand the definitions of these value types: for
example [[CSS3VAL]], when combined with this module, expands the
definition of the <<length>> value type as used in this specification.
<!--
████████ ██ ██ ███ ██ ██ ████████ ██ ████████ ██████
██ ██ ██ ██ ██ ███ ███ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ████ ████ ██ ██ ██ ██ ██
██████ ███ ██ ██ ██ ███ ██ ████████ ██ ██████ ██████
██ ██ ██ █████████ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
████████ ██ ██ ██ ██ ██ ██ ██ ████████ ████████ ██████
-->
Motivating Examples {#examples}
===============================
<div class="example">
In this example, a series of images arranged in a <a>scroll container</a>
are used to build a photo gallery. In this example the <a>scroll container</a>
is larger than the photos contained within (such that multiple images may be seen simultaneously), and the image
sizes vary. Using mandatory element-based snap
positions, scrolling will always complete with an image centered in the <a>scroll container's</a> scrollport.
<pre class="lang-css">
img {
/* Specifies that the center of each photo
should align with the center of the scroll
container in the X axis when snapping */
scroll-snap-align: center none;
}
.photoGallery {
width: 500px;
overflow-x: auto;
overflow-y: hidden;
white-space: nowrap;
/* Requires that the scroll position always be
at a snap position when the scrolling
operation completes. */
scroll-snap-type: mandatory;
}
</pre>
<pre class="lang-html">
<div class="photoGallery">
<img src="img1.jpg">
<img src="img2.jpg">
<img src="img3.jpg">
<img src="img4.jpg">
<img src="img5.jpg">
</div>
</pre>
<figure>
<img src="element_snap_positions.png" alt="">
<figcaption>
The layout of the scroll container's contents in the example.
The snapport is represented by the red rectangle, and the snap area is represented by the yellow rectangle. Since the scroll-snap-align is "center" in the X axis, a snap position is established at each scroll position which aligns the X-center of the snapport (represented by a red dotted line) with the X-center of a snap area (represented by a yellow dotted line).
</figcaption>
</figure>
</div>
<div class="example">
This example builds a paginated document that aligns each page near to (but not exactly on) the edge of the <a>scroll container</a>.
This allows the previous page to "peek" in from above in order to make the user aware that they are not yet at the top of the document.
Using proximity snap positions instead of mandatory snap positions allows the user to stop halfway through a page (rather than forcing them
to snap one page at a time). However, if a scrolling operation would finish near a snap position, then the scroll will be adjusted to
align the page as specified.
<pre class="lang-css">
.page {
/* Defines the top of each page as the
edge that should be used for snapping */
scroll-snap-align: none start;
}
.docScroller {
width: 500px;
overflow-x: hidden;
overflow-y: auto;
/* Specifies that each element's snap area should
align with a 100px offset from the top edge. */
scroll-snap-padding: 100px 0 0;
/* Encourages scrolling to end at a snap position when the
operation completes, if it is near a snap position */
scroll-snap-type: proximity;
}
</pre>
<pre class="lang-html">
<div class="docScroller">
<div class="page">Page 1</div>
<div class="page">Page 2</div>
<div class="page">Page 3</div>
<div class="page">Page 4</div>
</div>
</pre>
<figure>
<img src="element_snap_positions_offset.png" alt="">
<figcaption>
The layout of the scroll container's contents in the example.
The snapport is represented by the red rectangle (inset from the top by 100px due to the scroll-snap-padding), and the snap area is represented by the yellow rectangle. Since the scroll-snap-align is "start" in the Y axis, a snap position is established at each scroll position which aligns the Y-start of the snapport (represented by a red dotted line) with the Y-start of a snap area (represented by a yellow dotted line).
</figcaption>
</figure>
</div>
<!--
███████ ██ ██ ████████ ████████ ██ ██ ████ ████████ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██████ ████████ ██ ██ ██ ██████ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
███████ ███ ████████ ██ ██ ███ ████ ████████ ███ ███
-->
Overview {#overview}
====================
This module introduces control over <dfn lt="scroll snap position" local-lt="snap position">scroll snap positions</dfn>,
which are scroll positions that produce particular alignments
of content within a scroll container.
Using the 'scroll-snap-type' property on the relevant <a>scroll container</a>,
the author can request a particular bias
for the scrollport to land on a <a>snap position</a>
after scrolling operations.
<a>Snap positions</a> can be specified
as a particular alignment ('scroll-snap-align')
of an element's <a>scroll snap area</a> ('scroll-snap-margin', defaulting to its border box)
within the <a>scroll container</a>’s <a>snapport</a>
(its scrollport, as reduced by its 'scroll-snap-padding').
This is conceptually equivalent to specifying the alignment of
an <a>alignment subject</a> within an <a>alignment container</a>.
A scroll position that satisfies the specified alignment
is a <a>snap position</a>.
The act of adjusting the scroll position
of a scroll container’s scrollport
such that it is aligned to a snap position
is called <dfn lt="snap | snapping | snapped">snapping</dfn>,
and a <a>scroll container</a> is said to be
<a>snapped</a> to a <a>snap position</a>
if its scrollport’s scroll position
is that <a>snap position</a>
and there is no active scrolling operation.
The CSS Scroll Snap Module
intentionally does not specify nor mandate
any precise animations or physics used to enforce <a>snap positions</a>;
this is left up to the user agent.
<a>Snap positions</a> only affect the nearest ancestor <a>scroll container</a> on the element's <a>containing block chain</a>.
<!--
████████ ████████ ████████ ████ ██ ██ ████ ████████ ████ ███████ ██ ██ ██████
██ ██ ██ ██ ██ ███ ██ ██ ██ ██ ██ ██ ███ ██ ██ ██
██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ████ ██ ██
██ ██ ██████ ██████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██████
██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ████ ██
██ ██ ██ ██ ██ ██ ███ ██ ██ ██ ██ ██ ██ ███ ██ ██
████████ ████████ ██ ████ ██ ██ ████ ██ ████ ███████ ██ ██ ██████
-->
Definitions {#definitions}
==========================
<dl>
<dt><dfn export>scroll container</dfn>
<dd>
An element which provides a scrolling user interface as described in [[!CSS21]], particularly in the section on overflow.
</dl>
Capturing Scroll Snap Areas: Properties on the scroll container {#properties-on-the-scroll-container}
======================================================================================================
<!--
████████ ██ ██ ████████ ████████
██ ██ ██ ██ ██ ██
██ ████ ██ ██ ██
██ ██ ████████ ██████
██ ██ ██ ██
██ ██ ██ ██
██ ██ ██ ████████
-->
Scroll Snapping Rules: the 'scroll-snap-type' property {#scroll-snap-type}
--------------------------------------------------------------------------
<pre class="propdef">
Name: scroll-snap-type
Value: none | [ [ mandatory | proximity ] [ x | y | block | inline ]? ]{1,2} | [ mandatory | proximity ] point
Initial: none
Applies to: all elements
Inherited: no
Percentages: n/a
Media: interactive
Computed value: as specified
Animatable: no
</pre>
The 'scroll-snap-type' property specifies whether a <a>scroll container</a> is a <a>scroll snap container</a>, how strictly a <a>scroll container</a> should <a>snap</a>, and which axes are considered.
The <dfn noexport lt="strictness value">strictness values</dfn>
(''scroll-snap-type/none'', ''proximity'', ''mandatory'')
specify how strictly
<a>snap positions</a> are enforced on the <a>scroll container</a>
(by forcing an adjustment to the scroll position).
Values are defined as follows:
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.
Issue: Currently considering renaming the values
<dl dfn-type="value" dfn-for="scroll-snap-type">
<dt><dfn>none</dfn>
<dd>
If specified on a <a>scroll container</a>, the <a>scroll container</a> must not <a>snap</a>.
<dt><dfn>mandatory</dfn>
<dd>
If specified on a <a>scroll container</a>, the <a>scroll container</a> is required to be <a>snapped</a> to a snap position when there are no active scrolling operations. If a reachable snap position exists then the scroll container must <a>snap</a> at the termination of a scroll (if none exist then no <a>snapping</a> occurs).
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, 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 specified on a non-<a>scroll container</a>,
this value “traps” descendant boxes’ <a>snap positions</a>,
preventing them from affecting any ancestor <a>scroll containers</a>.
<dt><dfn>proximity</dfn>
<dd>
If specified on a <a>scroll container</a>, the <a>scroll container</a> may <a>snap</a> to a snap position at the termination of a scroll, at the discretion of the UA given the parameters of the scroll.
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.
Issue: The text for mandatory and proximity resnapping requirements has some overlap -- try to rewrite this more concisely and without repetition without altering functionality
If specified on a non-<a>scroll container</a>,
this value “traps” descendant boxes’ <a>snap positions</a>,
preventing them from affecting any ancestor <a>scroll containers</a>.
</dl>
A box <dfn export>captures snap positions</dfn>
if it is a <a>scroll container</a>
<em>or</em> has a value other than ''scroll-snap-type/none'' for 'scroll-snap-type'.
If a box's nearest <a lt="captures snap positions">snap-position capturing</a> ancestor
on its <a>containing block chain</a>
is a <a>scroll container</a> with a non-''scroll-snap-type/none'' value for 'scroll-snap-type',
that is the box's <dfn export local-lt="snap container">scroll snap container</dfn>.
Otherwise, the box has no <a>scroll snap container</a>,
and its <a>snap positions</a> do not trigger <a>snapping</a>.
The <dfn noexport lt="axis value">axis values</dfn>
specify what axis(es) are affected by <a>snap positions</a>,
and whether <a>snap positions</a> are evaluated independently per axis,
or together as a 2D point.
Values are defined as follows:
<dl dfn-type=value dfn-for="scroll-snap-type">
<dt><dfn>x</dfn>
<dd>
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>.
<dt><dfn>y</dfn>
<dd>
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>.
<dt><dfn>block</dfn>
<dd>
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>.
<dt><dfn>inline</dfn>
<dd>
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>.
<dt><dfn>point</dfn>
<dd>
The <a>scroll container</a> <a>point-snaps</a> to <a>snap positions</a> in both axes simultaneously,
treating each element’s <a>snap position</a> as a single 2D position
(rather than potentially snapping to different elements in each axis).
</dl>
If <a>axis values</a> are not specified, then the axis is automatically computed:
* 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>.
* 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>.
* 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>.
Advisement:
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 scrollport
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.
<!--
████████ ███ ████████ ████████ ████ ██ ██ ██████
██ ██ ██ ██ ██ ██ ██ ██ ██ ███ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██
████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████
██ █████████ ██ ██ ██ ██ ██ ██ ████ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██ ███ ██ ██
██ ██ ██ ████████ ████████ ████ ██ ██ ██████
-->
Scroll Snapport: the 'scroll-snap-padding' property {#scroll-snap-padding}
--------------------------------------------------------------------------
<pre class="propdef">
Name: scroll-snap-padding
Value: [ <<length>> | <<percentage>> ]{1,4}
Initial: 0
Applies to: <a>scroll containers</a>
Inherited: no
Percentages: relative to the corresponding dimension of the scroll container's scrollport
Media: interactive
Computed value: as specified, with lengths made absolute
Animatable: as length, percentage, or calc
</pre>
The 'scroll-snap-padding' property defines the <dfn local-lt="snapport">scroll snapport</dfn>, the area of the scrollport that is used as the <a>alignment container</a> for the <a>scroll snap areas</a> when calculating <a>snap positions</a>. Values are interpreted as for 'padding', and specify inward offsets from each edge of the scrollport.
<div class="example">
In this example, scroll-snap-padding is used to center slideshow images within the portion of the scrollport that is not obscured by a fixed-position toolbar.
<pre class="lang-css">
body {
overflow-x: auto;
overflow-y: hidden;
scroll-snap-type: mandatory;
scroll-snap-padding: 0 500px 0 0;
}
.toolbar {
position: fixed;
height: 100%;
width: 500px;
right: 0;
}
img {
scroll-snap-align: center none;
}
</pre>
</div>
This property is a <a>shorthand property</a> that sets all of the <a href="#longhands"><css>scroll-snap-padding-*</css> longhands</a> in one declaration.
Aligning Scroll Snap Areas: Properties on the elements {#properties-on-the-elements}
=====================================================================================
<!--
███ ████████ ████████ ███
██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██
██ ██ ████████ ██████ ██ ██
█████████ ██ ██ ██ █████████
██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ████████ ██ ██
-->
Scroll Snapping Area: the 'scroll-snap-margin' property {#scroll-snap-margin}
-----------------------------------------------------------------------------
<pre class="propdef">
Name: scroll-snap-margin
Value: <<length>>{1,4}
Initial: 0
Applies to: all elements
Inherited: no
Percentages: n/a
Media: interactive
Computed value: as specified, with lengths made absolute
Animatable: as length
</pre>
The 'scroll-snap-margin' property defines
the <dfn lt="scroll snap area" local-lt="snap area">scroll snap area</dfn>
that is used for snapping this box to the snapport.
The <<length>> values give outsets
(interpreted as for 'margin' or 'border-image-outset').
The <a>scroll snap area</a> is the rectangular bounding box of the transformed border box,
plus the specified outsets,
axis-aligned in the <a>scroll container’s</a> coordinate space.
Note: This ensures that the <a>scroll snap area</a> is always rectangular and axis-aligned to the <a>scroll container's</a> coordinate space.
This property is a <a>shorthand property</a> that sets all of the <a href="#longhands"><css>scroll-snap-margin-*</css> longhands</a> in one declaration.
<!--
███ ██ ████ ██████ ██ ██
██ ██ ██ ██ ██ ██ ███ ██
██ ██ ██ ██ ██ ████ ██
██ ██ ██ ██ ██ ████ ██ ██ ██
█████████ ██ ██ ██ ██ ██ ████
██ ██ ██ ██ ██ ██ ██ ███
██ ██ ████████ ████ ██████ ██ ██
-->
Scroll Snapping Alignment: the 'scroll-snap-align' property {#scroll-snap-align}
--------------------------------------------------------------------------------
<pre class="propdef">
Name: scroll-snap-align
Value: [ none | start | end | center ]{1,2}
Initial: none
Applies to: all elements
Inherited: no
Percentages: n/a
Media: interactive
Computed value: two keywords
Animatable: no
</pre>
The 'scroll-snap-align' property specifies
the box's <a>snap position</a> as an alignment of
its <a>snap area</a> (as the <a>alignment subject</a>)
within its <a>snap container's</a> <a>snapport</a> (as the <a>alignment container</a>). The two values specify the snapping behavior in the x and y axes, respectively. If only one value is specified, the second value defaults to the same value.
Issue: Should this be x/y axes, or inline/block? Starting with x/y axes for consistency with padding/area, otherwise a writing mode change would result in a axis mismatch (since padding is physical by default).
Values are defined as follows:
<dl dfn-type="value" dfn-for="scroll-snap-align">
<dt><dfn>none</dfn>
<dd>
This box does not define a <a>snap position</a> in the specified axis.
<dt><dfn>start</dfn>
<dd>
Start alignment of this box's <a>scroll snap area</a>
within the <a>scroll container</a>'s <a>snapport</a>
is a <a>snap position</a>
in the specified axis.
<dt><dfn>end</dfn>
<dd>
End alignment of this box's <a>scroll snap area</a>
within the <a>scroll container</a>'s <a>snapport</a>
is a <a>snap position</a>
in the specified axis.
<dt><dfn>center</dfn>
<dd>
Center alignment of this box's <a>scroll snap area</a>
within the <a>scroll container</a>'s <a>snapport</a>
is a <a>snap position</a>
in the specified axis.
</dl>
<!--
██ ████████ ███████ ████████
████ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██
██ ██ ██ ███████ ██ ██
██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██
██████ ████████ █████████ ████████
-->
Axis vs Point-Snapping {#snap-dimensions}
-----------------------------------------
Issue: 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.
There are two distinct <dfn lt="snap behavior|snapping behavior">snapping behaviors</dfn> that a <a>scroll container</a> might engage in:
: <dfn export local-lt="axis" lt="axis-snapping|axis-snap">axis-snapping</dfn>
:: If a <a>scroll container</a> is <a>axis-snapping</a>,
its descendants indicate a desired scroll position
in each axis of the <a>scroll container</a> independently,
with no dependent preference for what the other axis's scroll position should be.
Note: This is the “default” type of <a>snap behavior</a>
that most <a>scroll containers</a> will want to use,
and so the ''scroll-snap-type'' property intentionally defaults to it.
Note: An element in an <a>axis-snapping</a> <a>scroll container</a>
can declare two <a>snap positions</a>,
one in each axis.
If one of the element's <a>snap positions</a> is chosen in one axis,
this has no bearing on the other dimension's <a>snap position</a>--
it might be chosen,
or a different element's <a>snap position</a> might be chosen for that axis,
or that axis might not snap at all.
: <dfn export local-lt="point" lt="point-snapping|point-snap">point-snapping</dfn>
:: If a <a>scroll container</a> is <a>point-snapping</a>,
its descendants indicate a desired scroll position
in both axes of the <a>scroll container</a> simultaneously--
in other words,
some point in the descendant must be aligned to a corresponding point in the <a>scroll container</a>.
This type of <a>snapping behavior</a> is intended for "two-dimensional" panning-type layouts,
such as cities on a map
(using ''proximity'' 2D snap positions to snap a city to the center of the display when it gets close),
or a tiled image gallery
(using ''mandatory'' 2D snap positions to force each image to be centered on the screen).
In both of these cases,
it would look weird if the horizontal scrolling was aligned to one element
while the vertical was aligned to a different element
(which is the behavior you'd get if the <a>scroll container</a> was <a>axis-snapping</a>).
<!--
██ ███████ ██ ██ ██████ ██ ██ ███ ██ ██ ████████ ██████
██ ██ ██ ███ ██ ██ ██ ██ ██ ██ ██ ███ ██ ██ ██ ██ ██
██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ████ █████████ ██ ██ ██ ██ ██ ██ ██ ██████
██ ██ ██ ██ ████ ██ ██ ██ ██ █████████ ██ ████ ██ ██ ██
██ ██ ██ ██ ███ ██ ██ ██ ██ ██ ██ ██ ███ ██ ██ ██ ██
████████ ███████ ██ ██ ██████ ██ ██ ██ ██ ██ ██ ████████ ██████
-->
Appendix A: Longhands {#longhands}
==================================
Physical Longhands for 'scroll-snap-padding' {#padding-longhands-physical}
--------------------------------------------------------------------------
<pre class="propdef">
Name: scroll-snap-padding-top, scroll-snap-padding-right, scroll-snap-padding-bottom, scroll-snap-padding-left
Value: <<length>> | <<percentage>>
Initial: 0
Applies to: <a>scroll containers</a>
Inherited: no
Percentages: relative to the scroll container's scrollport
Media: interactive
Computed value: as specified, with lengths made absolute
Animatable: as length, percentage, or calc
</pre>
These <a>longhands</a> of 'scroll-snap-padding' specify the top, right, bottom, and left edges of the <a>snapport</a>, respectively.
Flow-relative Longhands for 'scroll-snap-padding' {#padding-longhands-logical}
-------------------------------------------------------------------------------
<pre class="propdef">
Name: scroll-snap-padding-inline-start, scroll-snap-padding-block-start, scroll-snap-padding-inline-end, scroll-snap-padding-block-end
Value: <<length>> | <<percentage>>
Initial: 0
Applies to: <a>scroll containers</a>
Inherited: no
Percentages: relative to the scroll container's scrollport
Media: interactive
Computed value: as specified, with lengths made absolute
Animatable: as length, percentage, or calc
</pre>
These <a>longhands</a> of 'scroll-snap-padding' specify the block-start, inline-start, block-end, and inline-end edges of the <a>snapport</a>, respectively.
<pre class="propdef">
Name: scroll-snap-padding-block, scroll-snap-padding-inline
Value: [ <<length>> | <<percentage>> ]{1,2}
Initial: 0
Applies to: all elements
Inherited: no
Percentages: relative to the scroll container's scrollport
Media: interactive
Computed value: as specified, with lengths made absolute
Animatable: as length, percentage, or calc
</pre>
These <a>shorthands</a> of 'scroll-snap-padding-block-start' + 'scroll-snap-padding-block-end' and 'scroll-snap-padding-inline-start' + 'scroll-snap-padding-inline-end' are <a>longhands</a> of 'scroll-snap-padding', and specify the block-axis and inline-axis edges of the <a>snapport</a>, respectively.
If two values are specified, the first gives the start value and the second gives the end value.
Physical Longhands for 'scroll-snap-margin' {#margin-longhands-physical}
-------------------------------------------------------------------------
<pre class="propdef">
Name: scroll-snap-margin-top, scroll-snap-margin-right, scroll-snap-margin-bottom, scroll-snap-margin-left
Value: <<length>>
Initial: 0
Applies to: all elements
Inherited: no
Percentages: n/a
Media: interactive
Computed value: as specified, with lengths made absolute
Animatable: as length
</pre>
These <a>longhands</a> of 'scroll-snap-margin' specify the top, right, bottom, and left edges of the <a>scroll snap area</a>, respectively.
Flow-relative Longhands for 'scroll-snap-margin' {#margin-longhands-logical}
-----------------------------------------------------------------------------
<pre class="propdef">
Name: scroll-snap-margin-block-start, scroll-snap-margin-inline-start, scroll-snap-margin-block-end, scroll-snap-margin-inline-end
Value: <<length>>
Initial: 0
Applies to: all elements
Inherited: no
Percentages: n/a
Media: interactive
Computed value: as specified, with lengths made absolute
Animatable: as length
</pre>
These <a>longhands</a> of 'scroll-snap-margin' specify the block-start, inline-start, block-end, and inline-end edges of the <a>scroll snap area</a>, respectively.
<pre class="propdef">
Name: scroll-snap-margin-block, scroll-snap-margin-inline
Value: <<length>>{1,2}
Initial: 0
Applies to: all elements
Inherited: no
Percentages: n/a
Media: interactive
Computed value: as specified, with lengths made absolute
Animatable: as length
</pre>
These <a>shorthands</a> of 'scroll-snap-margin-block-start' + 'scroll-snap-margin-block-end' and 'scroll-snap-margin-inline-start' + 'scroll-snap-margin-inline-end' are <a>longhands</a> of 'scroll-snap-margin', and specify the block-axis and inline-axis edges of the <a>scroll snap area</a>, respectively.
If two values are specified, the first gives the start value and the second gives the end value.
Privacy and Security Considerations {#priv-sec}
===============================================
This specification does not expose any information whatsoever that is not already exposed to the DOM directly; it just makes scrolling slightly more functional. There are no new privacy or security considerations.
Acknowledgements {#acknowledgements}
====================================
Many thanks to
David Baron,
Simon Fraser,
Håkon Wium Lie,
Edward O'Connor,
François Remy,
Majid Valpour,
Tab Atkins-Bittner,
Elika J. Etemad / fantasai,
and most especially Robert O'Callahan
for their proposals and recommendations,
which have been incorporated into this document.