You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create a new motivating example section and move existing example there.
Also added two other examples related to other usecases of the API.
Add simple css markup for each example scenario.
Also formatted all lines to wrap @ 100 for consistency.
A content author does not necessarily want <a>scroll chaining</a> to occur for all <a>scroll containers</a>. Some <a>scroll containers</a> may be part of a <a>containing block chain</a> but may serve a different logical purpose in the document and may want to prevent scrolling from continuing up the <a>scroll chain</a>. To achieve this, a content author will install event listeners without the <a>passive flag</a> set and will use <a>preventDefault</a> when there is a risk that scroll chaining will occur. This is detrimental for the following reasons:
37
-
* The user agent may in the future introduce new input methods for scrolling that are not supported by the content author's event listeners.
38
-
* A non passive event listener will delay scrolling because the user agent will have to wait for the result of the event listener to determine if <a>preventDefault</a> was called causing increased scroll latency.
39
-
* When scrolling is performed near the edge of the <a>scroll boundary</a>, the <a>default action</a> may cause both scrolling to the edge of the <a>scroll container</a> and a <a>boundary default action</a>. Calling <a>preventDefault</a> will not only cancel the <a>boundary default action</a> but also the scroll to the edge of the <a>scrollport</a>.
40
-
* The <a>default action</a> for the event may also provide additional behavior that the author does not want to cancel such as an overscroll affordance. <a>preventDefault</a> doesn't allow the content author to cancel only some of the <a>default actions</a> such as scroll chaining.
41
-
42
-
Thus, it is not possible for a content author to control <a>scroll chaining</a> and overscroll in a robust, performant and forward compatible way. The 'scroll-boundary-behavior' property fixes this shortcoming.
43
-
44
-
<pre class=example>
45
-
A 'position: fixed' left navigation bar may not want to hand off scrolling to the
46
-
document but does not want to prevent native overscroll affordances.
47
-
</pre>
36
+
A content author does not necessarily want <a>scroll chaining</a> to occur for all <a>scroll
37
+
containers</a>. Some <a>scroll containers</a> may be part of a <a>containing block chain</a> but may
38
+
serve a different logical purpose in the document and may want to prevent scrolling from continuing
39
+
up the <a>scroll chain</a>. To achieve this, a content author will install event listeners without
40
+
the <a>passive flag</a> set and will use <a>preventDefault</a> when there is a risk that scroll
41
+
chaining will occur. This is detrimental for the following reasons:
42
+
43
+
* The user agent may in the future introduce new input methods for scrolling that are not supported
44
+
by the content author's event listeners.
45
+
* A non passive event listener will delay scrolling because the user agent will have to wait for the
46
+
result of the event listener to determine if <a>preventDefault</a> was called causing increased
47
+
scroll latency.
48
+
* When scrolling is performed near the edge of the <a>scroll boundary</a>, the <a>default action</a>
49
+
may cause both scrolling to the edge of the <a>scroll container</a> and a <a>boundary default
50
+
action</a>. Calling <a>preventDefault</a> will not only cancel the <a>boundary default action</a>
51
+
but also the scroll to the edge of the <a>scrollport</a>.
52
+
* The <a>default action</a> for the event may also provide additional behavior that the author does
53
+
not want to cancel such as an overscroll affordance. <a>preventDefault</a> doesn't allow the
54
+
content author to cancel only some of the <a>default actions</a> such as scroll chaining.
55
+
56
+
Thus, it is not possible for a content author to control <a>scroll chaining</a> and overscroll in a
57
+
robust, performant and forward compatible way. The 'scroll-boundary-behavior' property fixes this
58
+
shortcoming.
59
+
60
+
61
+
Motivating Examples {#motivating-examples}
62
+
=================
63
+
64
+
65
+
<div class=example>
66
+
A 'position: fixed' left navigation bar does not want to hand off scrolling to the document but does
67
+
not want to prevent native overscroll affordances. Note that A scroll gesture performed on the
68
+
navigation bar s is almost never meant to scroll the document.
69
+
70
+
<pre class="lang-css">
71
+
#sidebar {
72
+
scroll-boundary-behavior: contain;
73
+
}
74
+
</pre>
75
+
76
+
In this case, the author can use <a value for=scroll-boundary-behavior>contain</a> on the sidebar to
77
+
prevent its scroll to chain up to document.
78
+
</div>
79
+
80
+
<div class=example>
81
+
A page wants to implement their own pull-to-refresh effect and thus needs to disable browser
82
+
native overscroll action.
83
+
84
+
<pre class="lang-css">
85
+
html {
86
+
/* only disable pull-to-refresh but allow swipe navigations */
87
+
scroll-boundary-behavior-y: contain;
88
+
}
89
+
</pre>
90
+
91
+
In this case, the author can use <a value for=scroll-boundary-behavior>contain</a> on the viewport
92
+
defining element to prevent overscroll from triggering navigation actions.
93
+
</div>
94
+
95
+
<div class=example>
96
+
A infinite scrollers loads more content as user reaches the boundary and thus wants to disable the
97
+
potentially confusing rubber banding effect.
98
+
99
+
<pre class="lang-css">
100
+
#infinite_scroller {
101
+
scroll-boundary-behavior-y: none;
102
+
}
103
+
</pre>
104
+
105
+
In this case the the author can use <a value for=scroll-boundary-behavior>none</a> on infinite
106
+
scroller to preventing overscroll affordance.
107
+
</div>
48
108
49
109
Scroll chaining and boundary default actions {#scroll-chaining-and-boundary-default-actions}
50
110
==========================
51
111
52
-
<em>Operating Systems have rules for scrolling such as scroll chaining and overscroll affordances. This specification does not mandate if and how scroll chaining or overscroll affordances be implemented. This specification only allows the content author to disable them if any are implemented.</em>
112
+
<em>Operating Systems have rules for scrolling such as scroll chaining and overscroll affordances.
113
+
This specification does not mandate if and how scroll chaining or overscroll affordances be
114
+
implemented. This specification only allows the content author to disable them if any are
115
+
implemented.</em>
53
116
54
-
<dfn>Scroll chaining</dfn> is when scrolling is propagated from one <a>scroll container</a> to an ancestor <a>scroll container</a> following the <a>scroll chain</a>. Typically scroll chaining is performed starting at the event target recursing up the <a>containing block chain</a>. When a <a>scroll container</a> in this chain receives a scroll event or gesture it may act on it and/or pass it up the chain. Chaining typically occurs when the <a>scrollport</a> has reached its boundary.
117
+
<dfn>Scroll chaining</dfn> is when scrolling is propagated from one <a>scroll container</a> to an
118
+
ancestor <a>scroll container</a> following the <a>scroll chain</a>. Typically scroll chaining is
119
+
performed starting at the event target recursing up the <a>containing block chain</a>. When a
120
+
<a>scroll container</a> in this chain receives a scroll event or gesture it may act on it and/or
121
+
pass it up the chain. Chaining typically occurs when the <a>scrollport</a> has reached its boundary.
55
122
56
-
A <dfn>scroll chain</dfn> is the order in which scrolling is propagated from one <a>scroll container</a> to another.
123
+
A <dfn>scroll chain</dfn> is the order in which scrolling is propagated from one <a>scroll
124
+
container</a> to another.
57
125
58
-
<dfn>Scroll boundary</dfn> refers to when the scroll position of a <a>scroll container</a> reaches the edge of the <a>scrollport</a>. If a scroll container has no potential to scroll, because it does not <a>overflow</a> in the direction of the scroll, the element is always considered to be at the scroll boundary.
126
+
<dfn>Scroll boundary</dfn> refers to when the scroll position of a <a>scroll container</a> reaches
127
+
the edge of the <a>scrollport</a>. If a scroll container has no potential to scroll, because it does
128
+
not <a>overflow</a> in the direction of the scroll, the element is always considered to be at the
129
+
scroll boundary.
59
130
60
131
<dfn>Boundary default action</dfn> refers to the user-agent-defined <a>default action</a> performed
61
132
when scrolling against the edge of the <a>scrollport</a>. A <dfn>local boundary default action</dfn>
@@ -67,14 +138,20 @@ navigation action.
67
138
Overview {#overview}
68
139
==========================
69
140
70
-
This module introduces control over the behavior of a <a>scroll container</a> element when its <a>scrollport</a> reaches the boundary of its scroll box. It allows the content author to specify that a <a>scroll container</a> element must prevent scroll chaining and/or overscroll affordances.
141
+
This module introduces control over the behavior of a <a>scroll container</a> element when its
142
+
<a>scrollport</a> reaches the boundary of its scroll box. It allows the content author to specify
143
+
that a <a>scroll container</a> element must prevent scroll chaining and/or overscroll affordances.
These properties specify how a <a>scroll container</a> element must behave when scrolling. A element that is not <a>scroll container</a> must accept but ignore the values of this property. This property must be applied to all input methods supported by the user agent.
148
+
These properties specify how a <a>scroll container</a> element must behave when scrolling. A element
149
+
that is not <a>scroll container</a> must accept but ignore the values of this property. This
150
+
property must be applied to all input methods supported by the user agent.
76
151
77
-
Note: This property should provide guarantees that are, at least, as strong as <a>preventDefault</a> for preventing both scroll chaining and overscroll. Doing otherwise would cause content authors to use <a>preventDefault</a> instead.
152
+
Note: This property should provide guarantees that are, at least, as strong as <a>preventDefault</a>
153
+
for preventing both scroll chaining and overscroll. Doing otherwise would cause content authors to
Canonical order: <abbr title="follows order of property value definition">per grammar</abbr>
90
167
</pre>
91
168
92
-
The 'scroll-boundary-behavior-x' property specifies the behavior of the 'scroll-boundary-behavior' in the horizontal direction and the 'scroll-boundary-behavior-y' property specifies the handling of the 'scroll-boundary-behavior' in the vertical direction. When scrolling is performed along both the horizontal and vertical axes at the same time, the 'scroll-boundary-behavior' of each respective axis should be considered independently.
169
+
The 'scroll-boundary-behavior-x' property specifies the behavior of the 'scroll-boundary-behavior'
170
+
in the horizontal direction and the 'scroll-boundary-behavior-y' property specifies the handling of
171
+
the 'scroll-boundary-behavior' in the vertical direction. When scrolling is performed along both the
172
+
horizontal and vertical axes at the same time, the 'scroll-boundary-behavior' of each respective
173
+
axis should be considered independently.
93
174
94
175
<pre class=propdef>
95
176
Name: scroll-boundary-behavior
@@ -124,6 +205,7 @@ Values have the following meanings:
124
205
with respect to <a>scroll chaining</a>, overscroll and navigation gestures.
125
206
</dl>
126
207
127
-
Note: In the case where a user agent does not implement scroll chaining and overscroll affordances, these values will have no side effects for a compliant implementation.
208
+
Note: In the case where a user agent does not implement scroll chaining and overscroll affordances,
209
+
these values will have no side effects for a compliant implementation.
128
210
129
211
Note: Programmatic scrolling is clamped and can not trigger any <a>boundary default actions</a>.
0 commit comments