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
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 because a
67
+
scroll gesture performed on the navigation bar is almost never meant to scroll the document. Note
68
+
that using the native overscroll affordances are still desirable while scroll chaining is to be
69
+
prevented.
70
+
71
+
<pre class="lang-css">
72
+
#sidebar {
73
+
scroll-boundary-behavior: contain;
74
+
}
75
+
</pre>
76
+
77
+
In this case, the author can use <a value for=scroll-boundary-behavior>contain</a> on the sidebar to
78
+
prevent scrolling from being chained to the parent document element.
79
+
</div>
80
+
81
+
<div class=example>
82
+
A page wants to implement their own pull-to-refresh effect and thus needs to disable browser
83
+
native overscroll action.
84
+
85
+
<pre class="lang-css">
86
+
html {
87
+
/* only disable pull-to-refresh but allow swipe navigations */
88
+
scroll-boundary-behavior-y: contain;
89
+
}
90
+
</pre>
91
+
92
+
In this case, the author can use <a value for=scroll-boundary-behavior>contain</a> on the viewport
93
+
defining element to prevent overscroll from triggering navigation actions.
94
+
</div>
95
+
96
+
<div class=example>
97
+
A infinite scrollers loads more content as user reaches the boundary and thus wants to disable the
98
+
potentially confusing rubber banding effect in addition to scroll chaining.
99
+
100
+
<pre class="lang-css">
101
+
#infinite_scroller {
102
+
scroll-boundary-behavior-y: none;
103
+
}
104
+
</pre>
105
+
106
+
In this case the the author can use <a value for=scroll-boundary-behavior>none</a> on the infinite
107
+
scroller to prevent both scroll chaining and overscroll affordance.
108
+
</div>
48
109
49
110
Scroll chaining and boundary default actions {#scroll-chaining-and-boundary-default-actions}
50
111
==========================
51
112
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>
113
+
<em>Operating Systems have rules for scrolling such as scroll chaining and overscroll affordances.
114
+
This specification does not mandate if and how scroll chaining or overscroll affordances be
115
+
implemented. This specification only allows the content author to disable them if any are
116
+
implemented.</em>
53
117
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.
118
+
<dfn>Scroll chaining</dfn> is when scrolling is propagated from one <a>scroll container</a> to an
119
+
ancestor <a>scroll container</a> following the <a>scroll chain</a>. Typically scroll chaining is
120
+
performed starting at the event target recursing up the <a>containing block chain</a>. When a
121
+
<a>scroll container</a> in this chain receives a scroll event or gesture it may act on it and/or
122
+
pass it up the chain. Chaining typically occurs when the <a>scrollport</a> has reached its boundary.
55
123
56
-
A <dfn>scroll chain</dfn> is the order in which scrolling is propagated from one <a>scroll container</a> to another.
124
+
A <dfn>scroll chain</dfn> is the order in which scrolling is propagated from one <a>scroll
125
+
container</a> to another.
57
126
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.
127
+
<dfn>Scroll boundary</dfn> refers to when the scroll position of a <a>scroll container</a> reaches
128
+
the edge of the <a>scrollport</a>. If a scroll container has no potential to scroll, because it does
129
+
not <a>overflow</a> in the direction of the scroll, the element is always considered to be at the
130
+
scroll boundary.
59
131
60
132
<dfn>Boundary default action</dfn> refers to the user-agent-defined <a>default action</a> performed
61
133
when scrolling against the edge of the <a>scrollport</a>. A <dfn>local boundary default action</dfn>
@@ -67,14 +139,20 @@ navigation action.
67
139
Overview {#overview}
68
140
==========================
69
141
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.
142
+
This module introduces control over the behavior of a <a>scroll container</a> element when its
143
+
<a>scrollport</a> reaches the boundary of its scroll box. It allows the content author to specify
144
+
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.
149
+
These properties specify how a <a>scroll container</a> element must behave when scrolling. A element
150
+
that is not <a>scroll container</a> must accept but ignore the values of this property. This
151
+
property must be applied to all input methods supported by the user agent.
76
152
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.
153
+
Note: This property should provide guarantees that are, at least, as strong as <a>preventDefault</a>
154
+
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
168
</pre>
91
169
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.
170
+
The 'scroll-boundary-behavior-x' property specifies the behavior of the 'scroll-boundary-behavior'
171
+
in the horizontal direction and the 'scroll-boundary-behavior-y' property specifies the handling of
172
+
the 'scroll-boundary-behavior' in the vertical direction. When scrolling is performed along both the
173
+
horizontal and vertical axes at the same time, the 'scroll-boundary-behavior' of each respective
174
+
axis should be considered independently.
93
175
94
176
<pre class=propdef>
95
177
Name: scroll-boundary-behavior
@@ -124,7 +206,8 @@ Values have the following meanings:
124
206
with respect to <a>scroll chaining</a>, overscroll and navigation gestures.
125
207
</dl>
126
208
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.
209
+
Note: In the case where a user agent does not implement scroll chaining and overscroll affordances,
210
+
these values will have no side effects for a compliant implementation.
128
211
129
212
Note: Programmatic scrolling is clamped and can not trigger any <a>boundary default actions</a>.
0 commit comments