Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
7e0ff02
Initial commit
bgirard Apr 18, 2017
d9ec44a
Fix MD for issues to file
bgirard Apr 18, 2017
52d9529
Typos
vdjeric Apr 18, 2017
2988582
Merge pull request #1 from vdjeric/master
bgirard Apr 18, 2017
561dade
Small editing changes
vdjeric Apr 19, 2017
d0b90df
Update README.md
vdjeric Apr 19, 2017
1424970
Merge pull request #2 from vdjeric/master
bgirard Apr 19, 2017
7a1eede
Initial specification draft
bgirard Apr 25, 2017
04b71ce
'contain' must not modify overscroll
bgirard Apr 28, 2017
69a2f65
Issue 6: Add a note for programmatic scrolling
bgirard May 4, 2017
68a6a99
Issue #7: Be more explicit about gestures
bgirard May 4, 2017
e349ced
Issue #4: Use 'scroll container' instead of 'scrollable element'
bgirard May 5, 2017
36310b5
Issue #8: Define non-local bonudary default action
bgirard May 8, 2017
838ff7e
Update README title and add link to specification
majido Sep 6, 2017
3f91871
Anwser security privacy questionnare
majido Sep 6, 2017
6b9d2c5
Merge pull request #11 from majido/update-readme
bgirard Sep 6, 2017
e276343
Add security privacy section to the spec
majido Sep 7, 2017
c45d685
Remove old file
majido Sep 7, 2017
1f07f4e
Clarify that contain prevents navigation.
majido Sep 7, 2017
c14b06c
Merge pull request #12 from majido/security-considerations
majido Sep 7, 2017
bca0bfc
Fix link issues
majido Sep 7, 2017
5203200
Add motivating examples
majido Sep 7, 2017
a34b827
Merge branch 'master' into correction-contain
majido Sep 7, 2017
4207473
Merge pull request #14 from majido/correction-contain
majido Sep 7, 2017
21f9f61
Merge remote-tracking branch 'wicg/master' into fix-link-issues
majido Sep 7, 2017
71e7f80
Add id for security privacy section
majido Sep 7, 2017
13325d4
Merge pull request #15 from majido/fix-link-issues
majido Sep 7, 2017
5803252
Merge remote-tracking branch 'wicg/master' into add-usecases
majido Sep 8, 2017
42c4cd2
Update example wording to address feedback
majido Sep 8, 2017
db3dc65
Merge pull request #16 from majido/add-usecases
majido Sep 8, 2017
582b8ce
Computed value as specified for longhands
ericwilligers Sep 11, 2017
465f39e
Shorthand syntax when -x and -y values distinct
ericwilligers Sep 11, 2017
2d039ab
Merge pull request #17 from ewilligers/longhand-as-specified
majido Sep 11, 2017
f5a04ab
Merge pull request #19 from ewilligers/shorthand-syntax
majido Sep 11, 2017
e5528a6
Specify Repository metadata
majido Oct 12, 2017
bf1b358
Merge pull request #23 from majido/fix-repo
majido Oct 12, 2017
bf0f848
Rename scroll-boundary-behavior to overscroll-behavior
majido Oct 25, 2017
df140de
Update README to use overscroll-behavior
majido Oct 31, 2017
776cf24
Merge pull request #26 from WICG/update-README-overscroll
majido Oct 31, 2017
a31c0c6
Update README with correct link to Draft Spec page
arkmuntasser Nov 14, 2017
9cc870e
Fix links
martinthomson Nov 27, 2017
a03f559
Move to sub-directory in preparation to move
majido Jul 31, 2018
9cab4ab
Merge wicg/overscroll-behavior project
majido Sep 25, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions css-overscroll-behavior/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Web Platform Incubator Community Group

This repository is being used for work in the Web Platform Incubator Community Group, governed by the [W3C Community License
Agreement (CLA)](http://www.w3.org/community/about/agreements/cla/). To contribute, you must join
the CG.

If you are not the sole contributor to a contribution (pull request), please identify all
contributors in the pull request's body or in subsequent comments.

To add a contributor (other than yourself, that's automatic), mark them one per line as follows:

```
+@github_username
```

If you added a contributor by mistake, you can remove them in a comment with:

```
-@github_username
```

If you are making a pull request on behalf of someone else but you had no part in designing the
feature, you can remove yourself with the above syntax.
5 changes: 5 additions & 0 deletions css-overscroll-behavior/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
All Reports in this Repository are licensed by Contributors under the
[W3C Software and Document
License](http://www.w3.org/Consortium/Legal/2015/copyright-software-and-document). Contributions to
Specifications are made under the [W3C CLA](https://www.w3.org/community/about/agreements/cla/).

37 changes: 37 additions & 0 deletions css-overscroll-behavior/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Overscroll Behavior
---
# Draft Specification
https://wicg.github.io/overscroll-behavior/

# Problem

Scroll chaining is the process of propagating the scroll event to the the nearest scrollable parent element once a scrollable reaches its limit. Scroll chaining is not always desirable. For example, consider a fixed/absolute position scroller whose scroll should not chain to the parent scroller, i.e. the document. You can find this UX pattern used in most chat boxes that live at the bottom of a page such as in Facebook or GMail UIs.

To give you a sense of how popular preventing scroll chaining may be, according to my quick http-archive search "-ms-scroll-chaining: none" is used in 0.4% of top 300K pages despite being limited in functionality and only supported on IE/Edge.

# Current Solution

-ms-scroll-chaining is a vendor specific API. The proposed CSS property provides a simple declarative way to prevent propagation of scroll gestures to parent containers but unfortunately it is limited to touch/touchpad scrolls only.

This means that currently the best cross-browser compatible way to prevent scroll propagation is to have a combination of a blocking wheel event listener (bad for performance), blocking keyboard listeners for all scroll inducing keys, carefully crafted touch-action values, and perhaps even -ms-scroll-chaining. These are rather ugly and complex hacks that "-ms-scroll-chaining" should have been able to replace but it cannot in its current form.

# Proposal

The current proposal is a summary of the public discussion from:
https://github.com/w3c/csswg-drafts/issues/769

This proposal introduces a new CSS property to control the scrolling behavior once a scrollable element reaches the boundary of the scrollport. This property will allow the author to hint that the user agent should deny scrolling from being chained to any ancestor. Note that for certain input modes, particularly on devices with a limited screen size and limited alternative input modes, the user agent may ignore the hint and allow scroll chaining to some ancestor, like the document viewport, or all ancestors.

The property can also hint at the overscroll behavior that the browser should take when at the boundary of the scrollport. The overscroll behavior is implementor defined. The property should provide a hint to either allow or disallow the overscroll behavior of the user agent.

The proposal for the syntax is:
```
overscroll-behavior{-x,-y}: auto | contain | none
```

where:
* auto - Allow the default behavior for the user agent.
* contain - Hint to disable scroll chaining. The user agent may show an appropriate overscroll affordance. If the scroll chaining would trigger a non-scroll action, such as a navigation action, this property should be a hint to disable the navigation action.
* none - Same as contain but also hint that no overscroll affordance should be triggered.

This should apply to all, non-programatic, user scroll actions.
227 changes: 227 additions & 0 deletions css-overscroll-behavior/index.bs
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
<pre class='metadata'>
Title: CSS Overscroll Behavior Module Level 1
Shortname: overscroll-behavior
Level: 1
Status: CG-DRAFT
Work Status: Exploring
Group: WICG
URL: https://wicg.github.io/overscroll-behavior/
Repository: wicg/overscroll-behavior
Editor: Benoit Girard, Facebook, bgirard@fb.com
Abstract: This module defines 'overscroll-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: 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 'overscroll-behavior' property fixes this
shortcoming.


Motivating Examples {#motivating-examples}
=================


<div class=example>
A position fixed left navigation bar does not want to hand off scrolling to the document because a
scroll gesture performed on the navigation bar is almost never meant to scroll the document. Note
that using the native overscroll affordances are still desirable while scroll chaining is to be
prevented.

<pre class="lang-css">
#sidebar {
overscroll-behavior: contain;
}
</pre>

In this case, the author can use <a value for=overscroll-behavior>contain</a> on the sidebar to
prevent scrolling from being chained to the parent document element.
</div>

<div class=example>
A page wants to implement their own pull-to-refresh effect and thus needs to disable browser
native overscroll action.

<pre class="lang-css">
html {
/* only disable pull-to-refresh but allow swipe navigations */
overscroll-behavior-y: contain;
}
</pre>

In this case, the author can use <a value for=overscroll-behavior>contain</a> on the viewport
defining element to prevent overscroll from triggering navigation actions.
</div>

<div class=example>
A infinite scrollers loads more content as user reaches the boundary and thus wants to disable the
potentially confusing rubber banding effect in addition to scroll chaining.

<pre class="lang-css">
#infinite_scroller {
overscroll-behavior-y: none;
}
</pre>

In this case the the author can use <a value for=overscroll-behavior>none</a> on the infinite
scroller to prevent both scroll chaining and overscroll affordance.
</div>

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 <dfn>local boundary default action</dfn>
is a <a>boundary default action</a> which is performed on the <a>scroll container</a> without
interacting with the page, for example displaying a overscroll UI affordance. Conversely, a <dfn
>non-local boundary default action</dfn> interacts with the page, for example 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.

Overscroll Behavior Properties {#overscroll-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: overscroll-behavior-x, overscroll-behavior-y
Value: contain | none | auto
Initial: auto
Applies to: <a>scroll container</a> elements
Inherited: no
Percentages: N/A
Media: visual
Computed value: as specified
Animatable: no
Canonical order: <abbr title="follows order of property value definition">per grammar</abbr>
</pre>

The 'overscroll-behavior-x' property specifies the behavior of the 'overscroll-behavior'
in the horizontal direction and the 'overscroll-behavior-y' property specifies the handling of
the 'overscroll-behavior' in the vertical direction. When scrolling is performed along both the
horizontal and vertical axes at the same time, the 'overscroll-behavior' of each respective
axis should be considered independently.

<pre class=propdef>
Name: overscroll-behavior
Value: [ contain | none | auto ]{1,2}
Initial: auto 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>

The two values specify the behavior in the horizontal and vertical direction, respectively. If only one value is specified, the second value defaults to the same value.

Values have the following meanings:

<dl dfn-for="overscroll-behavior, overscroll-behavior-x, overscroll-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>
such as scroll chaining or navigation. The user agent must not perform scroll 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.
<dt><dfn>none</dfn>
<dd>
This value implies the same behavior as <a value for=overscroll-behavior>contain</a> and in
addition this element must also not perform <a>local boundary default actions</a> such as
showing any overscroll affordances.
<dt><dfn>auto</dfn>
<dd>
This value indicates that the user agent should perform the usual <a>boundary default action</a>
with respect to <a>scroll chaining</a>, overscroll and navigation gestures.
</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 {#security-and-privacy}
===================================
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.


Loading