-
Notifications
You must be signed in to change notification settings - Fork 799
Expand file tree
/
Copy pathindex.bs
More file actions
130 lines (102 loc) · 8.92 KB
/
Copy pathindex.bs
File metadata and controls
130 lines (102 loc) · 8.92 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
<pre class='metadata'>
Title: CSS Scroll Boundary Behavior Module Level 1
Shortname: scroll-boundary-behavior
Level: 1
Status: CG-DRAFT
Work Status: Exploring
Group: WICG
URL: https://wicg.github.io/scroll-boundary-behavior/
Editor: Benoit Girard, Facebook, bgirard@fb.com
Abstract: This module defines 'scroll-boundary-behavior' to control the behavior when the scroll position of a <a>scroll container</a> reaches the edge of the <a>scrollport</a>.
Abstract: This allows content authors to hint that the <a>boundary default actions</a>,
Abstract: such as scroll chaining and overscroll, should not be triggered.
</pre>
<pre class='anchors'>
urlPrefix: https://www.w3.org/TR/css-display-3/
type: dfn; text: containing block chain
url: https://drafts.csswg.org/css-overflow-3/#scroll-container
type: dfn; text: scroll container
type: dfn; text: scroll containers
url: https://www.w3.org/TR/uievents/#default-action
type: dfn; text: default action
type: dfn; text: default actions
url: #local
type: dfn; text: local boundary default action
type: dfn; text: local boundary default actions
url: https://dom.spec.whatwg.org/#dom-event-preventdefault
type: dfn; text: preventDefault
url: https://dom.spec.whatwg.org/#dom-eventtarget-addeventlistener
type: dfn; text: passive flag
</pre>
Introduction {#intro}
=====================
<em>This section is not normative.</em>
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:
* The user agent may in the future introduce new input methods for scrolling that are not supported by the content author's event listeners.
* 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.
* 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>.
* 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.
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 <a>scroll-boundary-behavior</a> property fixes this shortcoming.
<pre class=example>
A 'position: fixed' left navigation bar may not want to hand off scrolling to the
document but does not want to prevent native overscroll affordances.
</pre>
Scroll chaining and boundary default actions {#scroll-chaining-and-boundary-default-actions}
==========================
<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>
<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.
A <dfn>scroll chain</dfn> is the order in which scrolling is propagated from one <a>scroll container</a> to another.
<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.
<dfn>Boundary default action</dfn> refers to the user-agent-defined <a>default action</a> performed when scrolling against the edge of the <a>scrollport</a>. A <a>boundary default action</a> is said to be <dfn>local</dfn>, for example overscroll, if it is performed on the <a>scroll container</a> without interacting with the page. Conversely, a <dfn>non-local boundary default action</dfn> will interact with the page such as scroll chaining or a navigation action.
Overview {#overview}
==========================
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.
Scroll Boundary Behavior Properties {#scroll-boundary-behavior-properties}
==========================
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.
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.
<pre class=propdef>
Name: scroll-boundary-behavior-x, scroll-boundary-behavior-y
Value: ''contain'' | ''none'' | ''auto''
Initial: ''auto''
Applies to: <a>scroll container</a> elements
Inherited: no
Percentages: N/A
Media: visual
Computed value: see individual properties
Animatable: no
Canonical order: <abbr title="follows order of property value definition">per grammar</abbr>
</pre>
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.
<pre class=propdef>
Name: scroll-boundary-behavior
Value: ''contain'' | ''none'' | ''auto''
Initial: ''auto''
Applies to: <a>scroll container</a> elements
Inherited: no
Media: visual
Computed value: see individual properties
Animatable: no
Canonical order: <abbr title="follows order of property value definition">per grammar</abbr>
</pre>
Values have the following meanings:
<dl dfn-for="scroll-boundary-behavior, scroll-boundary-behavior-x, scroll-boundary-behavior-y" dfn-type="value">
<dt><dfn>contain</dfn>
<dd>
This value indicates that the element must not perform <a>non-local boundary default actions</a>. The user agent must not perform scholl chaining to any ancestors along the <a>scroll chain</a> regardless of whether the scroll originated at this element or one of its descendants. This value must not modify the behavior of how <a>local boundary default actions</a> should behave, such as overscroll behavior and navigation guestures.
<dt><dfn>none</dfn>
<dd>
This value implies the same behavior as <a>contain</a> and in addition this element must also not perform <a>local boundary default actions</a> such as showing any overscroll affordances or performing any navigation guestures.
<dt><dfn>auto</dfn>
<dd>
This value indicates that the user agent should perform the usual <a>boundary default action</a> with respect to both <a>scroll chaining</a>, overscroll and navigation guestures.
</dl>
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.
Note: Programmatic scrolling is clamped and can not trigger any <a>boundary default actions</a>.
Security and Privacy Considerations
===================================
There are no known security or privacy impacts of this feature. The feature may be used to prevent
certain native UI features such as overscroll affordances and overscroll navigations (e.g., pull-
to-refresh, swipe navigations). However, this does not expose any additional abilities beyond what
is already possible in the platform e.g., by preventing the default action of the event that would
cause a scroll.