8000 [css-snappoints] Add Example 3, update diagrams for single coordinate… · w3c/csswg-drafts@16beb36 · GitHub
Skip to content

Commit 16beb36

Browse files
committed
[css-snappoints] Add Example 3, update diagrams for single coordinate property
1 parent 50ebfe9 commit 16beb36

5 files changed

Lines changed: 144 additions & 46 deletions

File tree

css-snappoints/Overview.html

Lines changed: 73 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
</p>
5555
<h1 class="p-name no-ref" id=title>CSS Scroll Snap Points Module Level 1</h1>
5656
<h2 class="no-num no-toc no-ref heading settled heading" id=subtitle><span class=content>Editor’s Draft,
57-
<span class=dt-updated><span class=value-title title=20140228>28 February 2014</span></span></span></h2>
57+
<span class=dt-updated><span class=value-title title=20140301>1 March 2014</span></span></span></h2>
5858
<div data-fill-with=spec-metadata><dl><dt>This version:<dd><a class=u-url href=http://dev.w3.org/csswg/css-snappoints/>http://dev.w3.org/csswg/css-snappoints/</a><dt>Editor’s Draft:<dd><a href=http://dev.w3.org/csswg/css-snappoints/>http://dev.w3.org/csswg/css-snappoints/</a>
5959
<dt>Feedback:</dt>
6060
<dd><a href="mailto:www-style@w3.org?subject=%5Bcss-snappoints%5D%20feedback">www-style@w3.org</a>
@@ -195,8 +195,12 @@ <h2 class="heading settled heading" data-level=2 id=examples><span class=secno>2
195195
overflow-x: auto;
196196
overflow-y: hidden;
197197
white-space: nowrap;
198-
scroll-snap-points-x: snap-interval(0px 100%); /* Sets up points to which scrolling will snap along x-axis */
199-
scroll-snap-type: mandatory; /* Requires that scrolling always end at a snap point when the operation completes (hard snap) */
198+
/* Sets up points to which scrolling
199+
will snap along x-axis */
200+
scroll-snap-points-x: snap-interval(0px 100%);
201+
/* Requires that scrolling always end at a snap point when
202+
the operation completes (hard snap) */
203+
scroll-snap-type: mandatory;
200204
}
201205
</pre>
202206
<pre> &lt;div class="photoGallery"&gt;
@@ -225,24 +229,24 @@ <h2 class="heading settled heading" data-level=2 id=examples><span class=secno>2
225229
will always complete with an image centered in the <a data-link-type=dfn href=#scroll-container title="scroll container">scroll container</a>.
226230

227231
<pre> img {
228-
scroll-snap-coordinate: 50% 50%;
229232
/* Defines the center of each photo as the
230233
coordinate that should be used for snapping */
234+
scroll-snap-coordinate: 50% 50%;
231235
}
232236
.photoGallery {
233237
width: 500px;
234238
overflow-x: auto;
235239
overflow-y: hidden;
236240
white-space: nowrap;
241+
/* Denotes that snap points will be defined
242+
by the elements contained within. */
237243
scroll-snap-points-x: elements;
238-
/* Denotes that snap points will be defined by
239-
the elements contained within. */
244+
/* Specifies that each element’s snap coordinate should
245+
align with the center of the scroll container */
240246
scroll-snap-destination: 50% 50%;
241-
/* Specifies that each element’s snap coordinate
242-
should align with the center of the scroll container */
243-
scroll-snap-type: mandatory;
244247
/* Requires that scrolling always end at a snap point
245-
when the operation completes (hard snap) */
248+
when the operation completes (hard snap). */
249+
scroll-snap-type: mandatory;
246250
}
247251
</pre>
248252
<pre> &lt;div class="photoGallery"&gt;
@@ -258,21 +262,61 @@ <h2 class="heading settled heading" data-level=2 id=examples><span class=secno>2
258262

259263
<figcaption>
260264
The layout of the scroll container’s contents in the example.
261-
The snap-destination is horizontally centered within the scroll container
262-
(represented by a red line),
263-
and each element has its snap coordinate horizontally centered within the element
264-
(represented by dashed yellow lines).
265+
The snap-destination is horizontally and vertically centered within the scroll container
266+
(represented by a red X),
267+
and each element has its snap coordinate horizontally and vertically centered within the element
268+
(represented by yellow plus signs).
265269
</figcaption>
266270
</figure>
271+
</div>
267272

268-
<p class=issue id=issue-5c5bf90c><a class=self-link href=#issue-5c5bf90c></a>
269-
Add an example of snapping elements with a slight offset, such that the previous element is allowed to "peek" in from the side.
270-
</p>
273+
<div class=example>
274+
This example builds a paginated document that aligns each page near to (but not exactly on) the edge of the <a data-link-type=dfn href=#scroll-container title="scroll container">scroll container</a>.
275+
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.
276+
Using proximity snap points instead of mandatory snap points allows the user to stop halfway through a page (rather than forcing them
277+
to snap one page at a time). However, if a scrolling operation would finish near a snap point, then the scroll will be adjusted to
278+
align the page as specified.
279+
280+
<pre> .page {
281+
/* Defines the top center of each page as the
282+
coordinate that should be used for snapping */
283+
scroll-snap-coordinate: 50% 0;
284+
}
285+
.docScroller {
286+
width: 500px;
287+
overflow-x: hidden;
288+
overflow-y: auto;
289+
/* Denotes that snap points will be defined
290+
by the elements contained within. */
291+
scroll-snap-points-y: elements;
292+
/* Specifies that each element’s snap coordinate should
293+
align with the center of the scroll container, offset
294+
a short distance from the top edge. */
295+
scroll-snap-destination: 50% 100px;
296+
/* Encourages scrolling to end at a snap point when the
297+
operation completes, if it is near a snap point */
298+
scroll-snap-type: proximity;
299+
}
300+
</pre>
301+
<pre> &lt;div class="docScroller"&gt;
302+
&lt;div class="page"&gt;Page 1&lt;/div&gt;
303+
&lt;div class="page"&gt;Page 2&lt;/div&gt;
304+
&lt;div class="page"&gt;Page 3&lt;/div&gt;
305+
&lt;div class="page"&gt;Page 4&lt;/div&gt;
306+
&lt;/div&gt;
307+
</pre>
308+
<figure>
309+
<img alt="" src=element_snap_points_offset.png>
271310

272-
<p class=issue id=issue-f83f9fa0><a class=self-link href=#issue-f83f9fa0></a>
273-
What happens in zooming scenarios, e.g. if the images become larger than the viewport? Snapping makes less sense in this case. Consider the snap-area stuff below to help solve this.
274-
</div>
275-
311+
<figcaption>
312+
The layout of the scroll container’s contents in the example.
313+
The snap-destination is horizontally centered and offset 100px from the top edge with respect to the scroll container
314+
(represented by a red X),
315+
and each element has its snap coordinate horizontally centered and top-aligned with respect to the element
316+
(represented by yellow plus signs).
317+
</figcaption>
318+
</figure>
319+
</div>
276320

277321
<h2 class="heading settled heading" data-level=3 id=definitions><span class=secno>3 </span><span class=content>Definitions</span><a class=self-link href=#definitions></a></h2>
278322

@@ -313,6 +357,10 @@ <h2 class="heading settled heading" data-level=4 id=scroll-snap-type><span class
313357
If we do some behavior like snap-area, what happens when near an edge -- try to align with the edge or not?
314358
</p>
315359

360+
<p class=issue id=issue-fa211d04><a class=self-link href=#issue-fa211d04></a>
361+
What happens in zooming scenarios, e.g. if the images become larger than the viewport? Snapping makes less sense in this case. Is this addressable with a snap-area type of effect?
362+
</p>
363+
316364
<p class=issue id=issue-b3745db4><a class=self-link href=#issue-b3745db4></a>
317365
Consider naming conventions like in Grid Layout for grouping properties on the container vs. items.
318366
</p>
@@ -610,12 +658,6 @@ <h2 class="no-num no-ref heading settled heading" id=property-index><span class=
610658

611659

612660
<h2 class="no-num heading settled" id=issues-index><span class=content>Issues Index</span><a class=self-link href=#issues-index></a></h2><div style="counter-reset: issue"><div class=issue>
613-
Add an example of snapping elements with a slight offset, such that the previous element is allowed to "peek" in from the side.
614-
<a href=#issue-5c5bf90c></a></div>
615-
616-
<div class=issue>
617-
What happens in zooming scenarios, e.g. if the images become larger than the viewport? Snapping makes less sense in this case. Consider the snap-area stuff below to help solve this.
618-
<a href=#issue-f83f9fa0></a></div><div class=issue>
619661
Could this be defined on a per-snap-point basis? What does it mean to mix types of snap points within a single scroller? Alternatively, should this be definable separately for each axis?
620662
<a href=#issue-c41d98db></a></div>
621663

@@ -627,6 +669,10 @@ <h2 class="no-num heading settled" id=issues-index><span class=content>Issues In
627669
If we do some behavior like snap-area, what happens when near an edge -- try to align with the edge or not?
628670
<a href=#issue-bc37a0a2></a></div>
629671

672+
<div class=issue>
673+
What happens in zooming scenarios, e.g. if the images become larger than the viewport? Snapping makes less sense in this case. Is this addressable with a snap-area type of effect?
674+
<a href=#issue-fa211d04></a></div>
675+
630676
<div class=issue>
631677
Consider naming conventions like in Grid Layout for grouping properties on the container vs. items.
632678
<a href=#issue- 8096 b3745db4></a></div>

css-snappoints/Overview.src.html

Lines changed: 71 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,12 @@ <h2 id="examples">Motivating Examples</h2>
7373
overflow-x: auto;
7474
overflow-y: hidden;
7575
white-space: nowrap;
76-
scroll-snap-points-x: snap-interval(0px 100%); /* Sets up points to which scrolling will snap along x-axis */
77-
scroll-snap-type: mandatory; /* Requires that scrolling always end at a snap point when the operation completes (hard snap) */
76+
/* Sets up points to which scrolling
77+
will snap along x-axis */
78+
scroll-snap-points-x: snap-interval(0px 100%);
79+
/* Requires that scrolling always end at a snap point when
80+
the operation completes (hard snap) */
81+
scroll-snap-type: mandatory;
7882
}
7983
</pre>
8084

@@ -107,24 +111,24 @@ <h2 id="examples">Motivating Examples</h2>
107111

108112
<pre>
109113
img {
110-
scroll-snap-coordinate: 50% 50%;
111114
/* Defines the center of each photo as the
112115
coordinate that should be used for snapping */
116+
scroll-snap-coordinate: 50% 50%;
113117
}
114118
.photoGallery {
115119
width: 500px;
116120
overflow-x: auto;
117121
overflow-y: hidden;
118122
white-space: nowrap;
123+
/* Denotes that snap points will be defined
124+
by the elements contained within. */
119125
scroll-snap-points-x: elements;
120-
/* Denotes that snap points will be defined by
121-
the elements contained within. */
126+
/* Specifies that each element's snap coordinate should
127+
align with the center of the scroll container */
122128
scroll-snap-destination: 50% 50%;
123-
/* Specifies that each element's snap coordinate
124-
should align with the center of the scroll container */
125-
scroll-snap-type: mandatory;
126129
/* Requires that scrolling always end at a snap point
127-
when the operation completes (hard snap) */
130+
when the operation completes (hard snap). */
131+
scroll-snap-type: mandatory;
128132
}
129133
</pre>
130134

@@ -143,20 +147,64 @@ <h2 id="examples">Motivating Examples</h2>
143147

144148
<figcaption>
145149
The layout of the scroll container's contents in the example.
146-
The snap-destination is horizontally centered within the scroll container
147-
(represented by a red line),
148-
and each element has its snap coordinate horizontally centered within the element
149-
(represented by dashed yellow lines).
150+
The snap-destination is horizontally and vertically centered within the scroll container
151+
(represented by a red X),
152+
and each element has its snap coordinate horizontally and vertically centered within the element
153+
(represented by yellow plus signs).
150154
</figcaption>
151155
</figure>
156+
</div>
157+
158+
<div class="example">
159+
This example builds a paginated document that aligns each page near to (but not exactly on) the edge of the <a>scroll container</a>.
160+
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.
161+
Using proximity snap points instead of mandatory snap points allows the user to stop halfway through a page (rather than forcing them
162+
to snap one page at a time). However, if a scrolling operation would finish near a snap point, then the scroll will be adjusted to
163+
align the page as specified.
164+
165+
<pre>
166+
.page {
167+
/* Defines the top center of each page as the
168+
coordinate that should be used for snapping */
169+
scroll-snap-coordinate: 50% 0;
170+
}
171+
.docScroller {
172+
width: 500px;
173+
overflow-x: hidden;
174+
overflow-y: auto;
175+
/* Denotes that snap points will be defined
176+
by the elements contained within. */
177+
scroll-snap-points-y: elements;
178+
/* Specifies that each element's snap coordinate should
179+
align with the center of the scroll container, offset
180+
a short distance from the top edge. */
181+
scroll-snap-destination: 50% 100px;
182+
/* Encourages scrolling to end at a snap point when the
183+
operation completes, if it is near a snap point */
184+
scroll-snap-type: proximity;
185+
}
186+
</pre>
152187

153-
<p class="issue">
154-
Add an example of snapping elements with a slight offset, such that the previous element is allowed to "peek" in from the side.
155-
</p>
188+
<pre>
189+
&lt;div class="docScroller">
190+
&lt;div class="page">Page 1&lt;/div>
191+
&lt;div class="page">Page 2&lt;/div>
192+
&lt;div class="page">Page 3&lt;/div>
193+
&lt;div class="page">Page 4&lt;/div>
194+
&lt;/div>
195+
</pre>
156196

157-
<p class="issue">
158-
What happens in zooming scenarios, e.g. if the images become larger than the viewport? Snapping makes less sense in this case. Consider the snap-area stuff below to help solve this.
159-
</div>
197+
<figure>
198+
<img src="element_snap_points_offset.png" alt="">
199+
200+
<figcaption>
201+
The layout of the scroll container's contents in the example.
202+
The snap-destination is horizontally centered and offset 100px from the top edge with respect to the scroll container
203+
(represented by a red X),
204+
and each element has its snap coordinate horizontally centered and top-aligned with respect to the element
205+
(represented by yellow plus signs).
206+
</figcaption>
207+
</figure>
160208
</div>
161209

162210
<h2 id="definitions">Definitions</h2>
@@ -209,6 +257,10 @@ <h2 id="scroll-snap-type">Scroll Snap Types: the 'scroll-snap-type' property</h2
209257
If we do some behavior like snap-area, what happens when near an edge -- try to align with the edge or not?
210258
</p>
211259

260+
<p class="issue">
261+
What happens in zooming scenarios, e.g. if the images become larger than the viewport? Snapping makes less sense in this case. Is this addressable with a snap-area type of effect?
262+
</p>
263+
212264
<p class="issue">
213265
Consider naming conventions like in Grid Layout for grouping properties on the container vs. items.
214266
</p>
-3.7 KB
Loading
6.98 KB
Loading

css-snappoints/example1.png

-23 KB
Binary file not shown.

0 commit comments

Comments
 (0)