diff --git a/css-snappoints/Overview.bs b/css-snappoints/Overview.bs new file mode 100644 index 00000000000..9c838b43da9 --- /dev/null +++ b/css-snappoints/Overview.bs @@ -0,0 +1,317 @@ +
+Group: csswg +Shortname: css-snappoints +TR: http://www.w3.org/TR/css-snappoints-1/ +Level: 1 +Status: ED +Work Status: Exploring +ED: http://dev.w3.org/csswg/css-snappoints/ +Editor: Matt Rakow, Microsoft +Editor: Jacob Rossi, Microsoft +Abstract: This module contains features to control panning and scrolling behavior with "snap positions". +!Issue Tracking: http://wiki.csswg.org/spec/css-snappoints +Ignored Terms: scroll-snap-positions-*, containing block chain ++ +
+ 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 offset always be
+ at a valid snap position when the scrolling
+ operation completes. */
+ scroll-snap-type: mandatory;
+ }
+
+
+ + <div class="photoGallery"> + <img src="img1.jpg"> + <img src="img2.jpg"> + <img src="img3.jpg"> + <img src="img4.jpg"> + <img src="img5.jpg"> + </div> ++ +
+
+
+ .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 valid snap position */
+ scroll-snap-type: proximity;
+ }
+
+
+ + <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> ++ +
+
+ + Open issue on whether to enhance the scroll-snap-type property for specifying the axis or adding a second property. We have resolved that this functionality be added once the issue is resolved. +
+ ++ Name: scroll-snap-type + Value: none | mandatory | proximity + Initial: none + Applies to: all elements + Inherited: no + Percentages: n/a + Media: interactive + Computed value: specified value + Animatable: no ++ +
+ Name: scroll-snap-padding + Value: <+ +>{1,4} + Initial: 0 + Applies to: scroll containers + Inherited: no + Percentages: relative to the scroll container's visual viewport + Media: interactive + Computed value: specified value, with lengths made absolute + Animatable: yes +
+ Name: scroll-snap-area + Value: [ border-box | margin-box ]? <+ +>{1,4} + Initial: 0 + Applies to: all elements + Inherited: no + Percentages: relative to the specified element box + Media: interactive + Computed value: specified value, with lengths made absolute + Animatable: yes +
+ 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). +
+ +
+ 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
+
+
+ Copyright © 2015 W3C® (MIT, ERCIM, Keio, Beihang). W3C liability, trademark and document use rules apply.
+Copyright © 2016 W3C® (MIT, ERCIM, Keio, Beihang). W3C liability, trademark and document use rules apply.
This module contains features to control panning and scrolling behavior with "snap points".
+This module contains features to control panning and scrolling behavior with "snap positions".
CSS is a language for describing the rendering of structured documents (such as HTML and XML) on screen, on paper, in speech, etc. @@ -115,19 +116,25 @@To this end, we introduce scroll snap points +
To this end, we introduce scroll snap positions which enforce the scroll offsets that a scroll container’s visual viewport may end at after a scrolling operation has completed.
img {
- /* Defines the center of each photo as the
- coordinate that should be used for snapping */
- scroll-snap-coordinate: 50% 50%;
+ /* 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;
- /* Specifies that each element’s snap coordinate should
- align with the center of the scroll container */
- scroll-snap-destination: 50% 50%;
- /* Requires that scrolling always end at a snap point
- when the operation completes. */
+ /* Requires that the scroll offset always be
+ at a valid snap position when the scrolling
+ operation completes. */
scroll-snap-type: mandatory;
}
@@ -207,35 +213,31 @@
+
.page {
- /* Defines the top center of each page as the
- coordinate that should be used for snapping */
- scroll-snap-coordinate: 50% 0;
+ /* 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 coordinate should
- align with the center of the scroll container, offset
- a short distance from the top edge. */
- scroll-snap-destination: 50% 100px;
- /* Encourages scrolling to end at a snap point when the
- operation completes, if it is near a snap point */
+ /* 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 valid snap position */
scroll-snap-type: proximity;
}
@@ -247,21 +249,42 @@
+
This module introduces control over scroll snap positions, + which are scroll positions that produce particular alignments + of content within a scrollable viewport. + Using the scroll-snap-type property on the relevant scroll container, + the author can request a particular bias + for the viewport to land on a valid snap position after scrolling operations.
+Valid snap positions can be specified + as a particular alignment (scroll-snap-align) + of an element’s scroll snap area (scroll-snap-area, defaulting to its margin box) + within the scroll container’s snap alignment container (the rectangle obtained by reducing its visual viewport by its 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 must only affect the nearest ancestor + (on the element’s containing block chain) scroll container.
+The scroll-snap-type property is used to define how strictly snap points are enforced on the scroll container, if any are present. It defines how and when snap points are enforced on the visual viewport of the scroll container it is applied to in order to adjust scroll offset. It intentionally does not specify nor mandate any precise animations or physics used to enforce those snap points; this is left up to the user agent.
+The scroll-snap-type property defines how strictly a scroll container’s visual viewport should rest on snap positions. It intentionally does not specify nor mandate any precise animations or physics used to enforce those snap position; this is left up to the user agent.
+Open issue on whether to enhance the scroll-snap-type property for specifying the axis or adding a second property. We have resolved that this functionality be added once the issue is resolved.
| Name: - | scroll-snap-destination + | scroll-snap-padding |
|---|---|---|
| Value: - | <position> + | <length>{1,4} |
| Initial: - | 0px 0px + | 0 |
| Applies to: - | scroll containers + | scroll containers |
| Inherited: | no | |
| Percentages: - | relative to width and height of the padding-box of the scroll container + | relative to the scroll container’s visual viewport |
| Media: | interactive
@@ -336,23 +356,23 @@
|
The scroll-snap-coordinate property is used to define a coordinate within an element. This coordinate is then associated with the nearest ancestor element which is a scroll container or has a scroll-snap-type that is not "none". If it is associated with a scroll container, then that scroll container is considered to be snapped to that element if its scroll offset is such that the coordinate and destination are aligned. In the case that the element has been transformed, the snap coordinate is also transformed in the same way (such that the snap-point is aligned with the element as-drawn).
-Consider alternative naming besides "coordinate". Consider naming conventions like in Grid Layout for grouping properties on the container vs. items.
-| Name: - | scroll-snap-coordinate + | scroll-snap-area | ||||||
|---|---|---|---|---|---|---|---|---|
| Value: - | none | [ border-box | margin-box ]? <position> + | [ border-box | margin-box ]? <length>{1,4} | ||||||
| Initial: - | none + | 0 | ||||||
| Applies to: | all elements
@@ -361,7 +381,7 @@
| Percentages: - | refer to the specified element box + | relative to the specified element box | Media: | interactive
@@ -373,93 +393,133 @@
|
Note: This ensures that the scroll snap area is always rectangular and axis-aligned to the scroll container’s coordinate space.
+The scroll-snap-align property specifies how a scroll container’s region specified by scroll-snap-padding should align with descendent elements' scroll snap area. 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.
+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).
+| 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 + |
Many thanks to lots of people for their proposals and recommendations, some of which are incorporated into this document.
Conformance requirements are expressed with a combination of - descriptive assertions and RFC 2119 terminology. The key words "MUST", - "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", - "RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this - document are to be interpreted as described in RFC 2119. - However, for readability, these words do not appear in all uppercase - letters in this specification.
+ descriptive assertions and RFC 2119 terminology. The key words "MUST", + "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", + "RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this + document are to be interpreted as described in RFC 2119. + However, for readability, these words do not appear in all uppercase + letters in this specification.All of the text of this specification is normative except sections - explicitly marked as non-normative, examples, and notes. [RFC2119]
+ explicitly marked as non-normative, examples, and notes. [RFC2119]Examples in this specification are introduced with the words "for example"
- or are set apart from the normative text with class="example",
- like this:
This is an example of an informative example.
+ or are set apart from the normative text withclass="example",
+ like this:
+
Informative notes begin with the word "Note" and are set apart from the
- normative text with class="note", like this:
Note, this is an informative note.
+ normative text withclass="note", like this:
+ Note, this is an informative note.
Advisements are normative sections styled to evoke special attention and are
- set apart from other normative text with <strong class="advisement">, like
- this: UAs MUST provide an accessible alternative.
<strong class="advisement">, like
+ this: UAs MUST provide an accessible alternative.
+ Conformance to this specification - is defined for three conformance classes:
+ is defined for three conformance classes:A style sheet is conformant to this specification - if all of its statements that use syntax defined in this module are valid - according to the generic CSS grammar and the individual grammars of each - feature defined in this module.
+ if all of its statements that use syntax defined in this module are valid + according to the generic CSS grammar and the individual grammars of each + feature defined in this module.A renderer is conformant to this specification - if, in addition to interpreting the style sheet as defined by the - appropriate specifications, it supports all the features defined - by this specification by parsing them correctly - and rendering the document accordingly. However, the inability of a - UA to correctly render a document due to limitations of the device - does not make the UA non-conformant. (For example, a UA is not - required to render color on a monochrome monitor.)
+ if, in addition to interpreting the style sheet as defined by the + appropriate specifications, it supports all the features defined + by this specification by parsing them correctly + and rendering the document accordingly. However, the inability of a + UA to correctly render a document due to limitations of the device + does not make the UA non-conformant. (For example, a UA is not + required to render color on a monochrome monitor.)An authoring tool is conformant to this specification - if it writes style sheets that are syntactically correct according to the - generic CSS grammar and the individual grammars of each feature in - this module, and meet all other conformance requirements of style sheets - as described in this module.
-So that authors can exploit the forward-compatible parsing rules to - assign fallback values, CSS renderers must treat as invalid (and ignore - as appropriate) any at-rules, properties, property values, keywords, - and other syntactic constructs for which they have no usable level of - support. In particular, user agents must not selectively - ignore unsupported component values and honor supported values in a single - multi-value property declaration: if any value is considered invalid - (as unsupported values must be), CSS requires that the entire declaration - be ignored.
-To avoid clashes with future CSS features, the CSS2.1 specification - reserves a prefixed - syntax for proprietary and experimental extensions to CSS.
-Prior to a specification reaching the Candidate Recommendation stage - in the W3C process, all implementations of a CSS feature are considered - experimental. The CSS Working Group recommends that implementations - use a vendor-prefixed syntax for such features, including those in - W3C Working Drafts. This avoids incompatibilities with future changes - in the draft.
-The following sections define several conformance requirements + for implementing CSS responsibly, + in a way that promotes interoperability in the present and future.
+So that authors can exploit the forward-compatible parsing rules to assign fallback values, CSS renderers must treat as invalid + (and ignore as appropriate) + any at-rules, properties, property values, keywords, and other syntactic constructs + for which they have no usable level of support. + In particular, user agents must not selectively ignore + unsupported property values and honor supported values in a single multi-value property declaration: + if any value is considered invalid (as unsupported values must be), + CSS requires that the entire declaration be ignored.
+To avoid clashes with future stable CSS features, + the CSSWG recommends following best practices for the implementation of unstable features and proprietary extensions to CSS.
+Once a specification reaches the Candidate Recommendation stage, - non-experimental implementations are possible, and implementors should - release an unprefixed implementation of any CR-level feature they - can demonstrate to be correctly implemented according to spec.
+ implementers should release an unprefixed implementation + of any CR-level feature they can demonstrate + to be correctly implemented according to spec, + and should avoid exposing a prefixed variant of that feature.To establish and maintain the interoperability of CSS across implementations, the CSS Working Group requests that non-experimental CSS renderers submit an implementation report (and, if necessary, the @@ -473,27 +533,37 @@
| Name - | Value - | Initial - | Applies to - | Inh. - | %ages - | Media - | Animatable - | Computed value - |
|---|---|---|---|---|---|---|---|---|
| scroll-snap-type - | none | mandatory | proximity - | none - | all elements - | no - | n/a - | interactive - | no - | specified value - |
| scroll-snap-destination - | <position> - | 0px 0px - | scroll containers - | no - | relative to width and height of the padding-box of the scroll container - | interactive - | yes - | specified value, with lengths made absolute - |
| scroll-snap-coordinate - | none | [ border-box | margin-box ]? <position> - | none - | all elements - | no - | refer to the specified element box - | interactive - | yes - | specified value, with lengths made absolute - |
| Name + | Value + | Initial + | Applies to + | Inh. + | %ages + | Media + | Animatable + | Computed value + |
|---|---|---|---|---|---|---|---|---|
| scroll-snap-type + | none | mandatory | proximity + | none + | all elements + | no + | n/a + | interactive + | no + | specified value + |
| scroll-snap-padding + | <length>{1,4} + | 0 + | scroll containers + | no + | relative to the scroll container’s visual viewport + | interactive + | yes + | specified value, with lengths made absolute + |
| scroll-snap-area + | [ border-box | margin-box ]? <length>{1,4} + | 0 + | all elements + | no + | relative to the specified element box + | interactive + | yes + | specified value, with lengths made absolute + |
| scroll-snap-align + | [ none | start | end | center ]{1,2} + | none + | all elements + | no + | n/a + | interactive + | no + | two keywords + |