Skip to content

Commit 7558e08

Browse files
committed
[scroll-animations-1] Move remaining trigger text out of spec (#4913)
The specification no longer has a trigger API. Now that we have a explainer, the explanation as to why we made this design decision belongs there. Also removed empty trigger examples from specification and updated usecases to mention that trigger usecases are deferred.
1 parent 8674b1f commit 7558e08

File tree

6 files changed

+92
-326
lines changed

6 files changed

+92
-326
lines changed

scroll-animations-1/EXPLAINER.md

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@ Scroll-linked animated effect are common in web design:
3131

3232

3333
Currently the only way to achieve them is to respond to scroll events on the main thread. This
34-
means that these animations have to run on the main thread. There are two main problems with this:
34+
means that these animations have to run on the main thread which leads to two main problems:
3535
1. Modern browsers perform scrolling on separate thread/process so scroll events are delivered
36-
asynchronously
36+
asynchronously.
3737
2. Main thread animations are subject to jank.
3838

39-
Creating performant scroll-linked animation can be impossible or [very
39+
These make creating performant scroll-linked animations that are in-sync with
40+
scrolling impossible or [very
4041
difficult](https://developers.google.com/web/updates/2016/12/performant-parallaxing).
4142

4243

@@ -46,27 +47,47 @@ scroll-linked animation under the existing common web-animation model allowing t
4647
inspected, controlled via a common animations API.
4748

4849
### Non-goals
49-
* **Scroll-triggered animations**: these are time-based animations that may be triggered when a
50-
scroller reaches a certain offset. These are also common but do not suffer from jank issues since
51-
time-based animations can easily be off-thread. The current best practice is to use
52-
IntersectionObserver to kick-off such animation which seems sufficient. Other alternative ideas
53-
(`:ever-been-visible` pseudo class or generic animation-trigger) have been proposed
54-
[here](https://github.com/w3c/csswg-drafts/issues/4339#issuecomment-499666491) that the current
55-
ScrollTimeline proposal does not prohibit.
56-
57-
* **Stateful scripted scroll driven animations**: Some scroll-linked animations may not fit well
58-
within declarative animations such as those that depend on scroll velocity, or direction, or have
59-
custom per frame logic. We believe these can continue to be solved using rAF (and in future
60-
be made more efficient with [CSS Animation
61-
Worklet](https://drafts.css-houdini.org/css-animationworklet/)). ScrollTimeline may be used in
62-
conjunction with these.
50+
51+
#### Scroll-triggered animations
52+
53+
These are a class of animation whose progress is driven by time but whose activation may be
54+
triggered when scrolling past a certain position or into a given scroll range. These are also
55+
common on the web but they don't suffer from main thread jank and synchronous scrolling lad in the
56+
same way that scroll-linked animations do. This is becuase only their activation is tied to scroll
57+
position and and not their progress.
58+
59+
However, we found that in the vast majority of cases where a web author would want to do this, they
60+
would want to do it for a CSS transition (as opposed to a CSS animation). Unfortunately, it's not
61+
possible to trigger CSS transitions from the compositor thread (because triggering a transition
62+
requires style resolution, which cannot be performed on the compositor thread).
63+
64+
Earlier versions of this specification included a triggering mechanims. But given the extent to
65+
which triggering complicated the API and because of the smaller benefit that these type of
66+
animation will receive, we decided it wasn't worth it if you can't use it for transitions, so this
67+
feature was remove and scroll-triggered animations are non-goal for this API.
68+
69+
70+
At the moment, the current best practice is to use IntersectionObserver to kick-off such animation
71+
which seems sufficient. Other alternative ideas (`:ever-been-visible` pseudo class or generic
72+
animation-trigger) have been proposed
73+
[here](https://github.com/w3c/csswg-drafts/issues/4339#issuecomment-499666491) that the current
74+
ScrollTimeline proposal does not prohibit. The design space for triggering animations is still open
75+
and we welcome input on this subject for future revisions in this specification.
76+
77+
#### Stateful scripted scroll driven animations
78+
79+
Some scroll-linked animations may not fit well within declarative animations such as those that
80+
depend on scroll velocity, or direction, or have custom per frame logic. We believe these can
81+
continue to be solved using rAF (and in future be made more efficient with [Houdini Animation
82+
Worklet](https://drafts.css-houdini.org/css-animationworklet/)). ScrollTimeline may be used in
83+
conjunction with these.
6384

6485
## New APIs
6586

6687
The [Scroll-linked Animations](https://drafts.csswg.org/scroll-animations-1/) spec introduces one
6788
new concept: ScrollTimeline
6889

69-
### Scroll Timeline API
90+
### Scroll Timeline
7091

7192
A [ScrollTimeline](https://drafts.csswg.org/scroll-animations-1/#scrolltimeline-interface) is an
7293
[AnimationTimeline](https://drafts.csswg.org/web-animations-1/#the-animationtimeline-interface)

scroll-animations-1/Overview.bs

Lines changed: 7 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Group: CSSWG
88
URL: https://drafts.csswg.org/scroll-animations-1/
99
ED: https://drafts.csswg.org/scroll-animations-1/
1010
Shortname: scroll-animations-1
11-
Abstract: Defines an API and markup for creating animations that are either
12-
triggered by or tied to the scroll offset of a scroll container.
11+
Abstract: Defines an API and markup for creating animations that are tied to
12+
the scroll offset of a scroll container.
1313
Editor: Brian Birtles, Invited Expert, brian@birchill.co.jp, w3cid 43194
1414
Editor: Botond Ballo, Mozilla, botond@mozilla.com
1515
Editor: Antoine Quint, Apple, graouts@apple.com, w3cid 51377
@@ -74,7 +74,7 @@ way that does not require script to run each time the effect is sampled. User
7474
agents that support asynchronous scrolling are allowed (but not required) to
7575
sample such effects asynchronously as well.
7676

77-
## Value Definitions {#values}
77+
## Value Definitions ## {#values}
7878

7979
This specification follows the <a href="https://www.w3.org/TR/CSS2/about.html#property-defs">CSS property definition conventions</a> from [[!CSS2]]
8080
using the <a href="https://www.w3.org/TR/css-values-3/#value-defs">value definition syntax</a> from [[!CSS-VALUES-3]].
@@ -94,59 +94,8 @@ Note: Based on this <a
9494
href="https://github.com/WICG/scroll-animations/blob/master/Use%20cases.md">curated
9595
list of use cases</a>.
9696

97-
## Scroll-triggered animations ## {#scroll-triggered-animations-usecases}
9897

99-
### Navigation bar shrinking effect ### {#navigation-bar-shrinking-effect}
100-
101-
It is common to trigger an animation to run when the scroll position
102-
reaches a certain point. For example, a navigation bar may shrink once
103-
the user begins to scroll a page.
104-
105-
<figure>
106-
<img src="img/usecase1-2.svg" width="600"
107-
alt="Use case: Shrinking navigation bar">
108-
<figcaption>
109-
Shrinking navigation bar<br>
110-
The left figure shows the navigation bar before scrolling with
111-
a large menu bar.<br>
112-
The right figure shows the shrunken navigation bar after scrolling.
113-
</figcaption>
114-
</figure>
115-
116-
Advisement: The proposal does not yet define CSS markup or programming
117-
interfaces to express this use case.
118-
119-
### Navigation highlight effect ### {#navigation-highlight-effect}
120-
121-
Similarly, it is common to trigger an animation at certain fixed points
122-
in a element's scroll range. For example, a navigation bar that changes
123-
highlight based on the reader's position within the document.
124-
125-
<figure>
126-
<img src="img/usecase1-1.svg" width="600"
127-
alt="Use case: A navigation highlight effect.">
128-
<figcaption>
129-
A navigation highlight effect<br>
130-
On the left, the &ldquo;Abstract&rdquo; section is scrolled into view
131-
and hence the abstract menu item is highlighted.<br>
132-
After scrolling down to the &ldquo;Background&rdquo; section (right),
133-
the background menu item fades in while the abstract menu item fades
134-
out.
135-
</figcaption>
136-
</figure>
137-
138-
Advisement: The proposal does not yet define CSS markup or programming
139-
interfaces to express this use case.
140-
141-
## Scroll-triggered style changes ## {#scroll-triggered-style-changes-usecase}
142-
143-
Advisement: The proposal does not yet define CSS markup or programming
144-
interfaces to express this use case.
145-
146-
147-
## Scroll-linked animations ## {#scroll-linked-animations-usecase}
148-
149-
### Scrollable picture-story show ### {#scrollable-animation-usecase}
98+
## Scrollable picture-story show ## {#scrollable-animation-usecase}
15099

151100
Another pattern is an animation that tells a story where the user
152101
controls the progress of the animation by scrolling or some other
@@ -247,7 +196,7 @@ if (window.matchMedia('(prefers-reduced-motion: no-preference)').matches) {
247196
}
248197
</pre>
249198

250-
### The content progress bar ### {#content-progress-bar-usecase}
199+
## The content progress bar ## {#content-progress-bar-usecase}
251200

252201
Another common example of an animation that tracks scroll position is a
253202
progress bar that is used to indicate the reader's position in a long
@@ -449,7 +398,7 @@ not by wall-clock time, but by the progress of scrolling in a [=scroll container
449398

450399
: <dfn attribute for=ScrollTimeline>orientation</dfn>
451400
:: Determines the direction of scrolling which triggers the activation and drives
452-
the progress of the trigger.
401+
the progress of the timeline.
453402

454403
: <dfn attribute for=ScrollTimeline>start</dfn>
455404
:: A scroll offset, in the direction specified by {{orientation}}, which constitutes
@@ -472,7 +421,7 @@ not by wall-clock time, but by the progress of scrolling in a [=scroll container
472421

473422
: <dfn attribute for=ScrollTimeline>end</dfn>
474423
:: A scroll offset, in the direction specified by {{orientation}}, which constitutes
475-
the end of the range in which the trigger is activated.
424+
the end of the range in which the timeline is activated.
476425

477426
Recognized values are defined by the following grammar:
478427

@@ -856,30 +805,6 @@ run), the user agent may likewise choose not to sample scroll-driven animations
856805
for that composited frame. In such cases, the rendered scroll offset and the
857806
state of a scroll-driven animation may be inconsistent in the composited frame.
858807

859-
# Scroll-triggered (but time-driven) animations # {#scroll-triggered-animations}
860-
861-
An earlier draft of this proposal also provided for animations whose progress
862-
was driven by time (as with existing animations), but whose activation was
863-
triggered by scrolling past a certain scroll offset or into a given scroll range.
864-
865-
The main objective was to allow triggering the animation from the compositor
866-
thread. (The objective of scroll-linked animations is to make sure that
867-
the animation is in sync with the scroll position on each composited frame.
868-
If the triggering doesn't happen on the compositor thread, then it's possible
869-
that for a few frames the visual scroll position is such that the animation
870-
should have started, but it has not in fact started yet because the main thread,
871-
which is doing the triggering, is lagging behind.)
872-
873-
However, we found that in the vast majority of cases where a web author would
874-
want to do this, they would want to do it for a CSS transition (as opposed to
875-
a CSS animation). Unfortunately, it's not possible to trigger CSS transitions from
876-
the compositor thread (because triggering a transition requires style resolution,
877-
which cannot be performed on the compositor thread). Given the extent to which
878-
triggering complicated the API, we decided it wasn't worth it if you can't use
879-
it for transitions, so this feature was removed.
880-
881-
The design space for triggering animations is still open. We welcome input
882-
on this subject.
883808

884809
<h2 id="appendix-a-considerations-for-security-and-privacy">Appendix A. Considerations for Security and Privacy</h2>
885810

scroll-animations-1/Use cases.md

Lines changed: 46 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,49 @@
1-
1. Scroll-triggered animations
1+
1. Scroll-linked animations
2+
-----------------------------
3+
4+
Scroll position controls progress:
5+
6+
- http://alfredservice.com/ (controls animation progress, even movie progress)
7+
- http://www.flatvsrealism.com
8+
- http://makeyourmoneymatter.org/
9+
- http://www.dementialab.org/discovery-lab/
10+
- http://lostworldsfairs.com/atlantis/
11+
- http://everylastdrop.co.uk/
12+
- http://www.madwell.com/work
13+
- http://www.fannabee.com/
14+
- http://www.culturalsolutions.co.uk/
15+
- http://jason-kenny.com/
16+
- http://lamoulade.com/#!/home
17+
- http://www.nytimes.com/projects/2013/tomato-can-blues/?hp
18+
- http://www.unfold.no/
19+
- http://www.arnoldclark.com/challenge/
20+
- http://cyclemon.com/
21+
- http://www.bbc.co.uk/news/special/2014/newsspec_7617/index.html
22+
- http://johnpeelarchive.com/joe-boyd/#TOOTS
23+
- http://nasaprospect.com/
24+
- http://allout.org/en/
25+
- https://www.washingtonpost.com/graphics/sports/olympics/scale-of-the-olympics/?%3Ftid%3D=sm_pg&%3Ftid%3D=sm_pg (scroll &rarr; zoom)
26+
- https://www.invisionapp.com/product-design-industry-report-2016
27+
28+
2. Combination scroll and time-based animations
29+
------------------------------------------------------
30+
31+
- http://www.nytimes.com/projects/2012/snow-fall/#/?part=tunnel-creek
32+
- http://www.gestrandete-wale.info/
33+
- http://cuberto.com/
34+
35+
36+
37+
# Deferred Usecases
38+
39+
See [EXPLAINER](https://github.com/w3c/csswg-drafts/blob/master/scroll-animations-1/EXPLAINER.md#non-goals)
40+
for an explanation of why theses usecases are deferreing in the first version of this specification.
41+
The design space for triggering animations is still open. We welcome input on this subject for next
42+
revision of this specification.
43+
44+
45+
46+
3. Scroll-triggered animations
247
---------------------------------
348

449
Trigger an animation based on scroll position:
@@ -36,37 +81,3 @@ Multiple scroll-ranges:
3681
------------------------------------
3782

3883
- http://unformedbuilding.com/articles/fixed-nav-with-jquery/
39-
40-
3. Scroll-linked animations
41-
-----------------------------
42-
43-
Scroll position controls progress:
44-
45-
- http://alfredservice.com/ (controls animation progress, even movie progress)
46-
- http://www.flatvsrealism.com
47-
- http://makeyourmoneymatter.org/
48-
- http://www.dementialab.org/discovery-lab/
49-
- http://lostworldsfairs.com/atlantis/
50-
- http://everylastdrop.co.uk/
51-
- http://www.madwell.com/work
52-
- http://www.fannabee.com/
53-
- http://www.culturalsolutions.co.uk/
54-
- http://jason-kenny.com/
55-
- http://lamoulade.com/#!/home
56-
- http://www.nytimes.com/projects/2013/tomato-can-blues/?hp
57-
- http://www.unfold.no/
58-
- http://www.arnoldclark.com/challenge/
59-
- http://cyclemon.com/
60-
- http://www.bbc.co.uk/news/special/2014/newsspec_7617/index.html
61-
- http://johnpeelarchive.com/joe-boyd/#TOOTS
62-
- http://nasaprospect.com/
63-
- http://allout.org/en/
64-
- https://www.washingtonpost.com/graphics/sports/olympics/scale-of-the-olympics/?%3Ftid%3D=sm_pg&%3Ftid%3D=sm_pg (scroll &rarr; zoom)
65-
- https://www.invisionapp.com/product-design-industry-report-2016
66-
67-
4. Combination scroll and time-based animations
68-
------------------------------------------------------
69-
70-
- http://www.nytimes.com/projects/2012/snow-fall/#/?part=tunnel-creek
71-
- http://www.gestrandete-wale.info/
72-
- http://cuberto.com/

0 commit comments

Comments
 (0)