Skip to content

Commit cf1a69a

Browse files
authored
[css-animationworklet] Update README
- sync usecases with other document - make the relationship between AW and other primitives clear
1 parent a7c95ad commit cf1a69a

File tree

1 file changed

+62
-43
lines changed

1 file changed

+62
-43
lines changed

css-animationworklet/README.md

Lines changed: 62 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,59 +3,78 @@
33

44
# Overview
55

6-
Animation Worklet is a new primitive for creating scroll-linked and other high performance
7-
procedural animations on the web. It is being incubated here as part of the
8-
[CSS Houdini task force](https://github.com/w3c/css-houdini-drafts/wiki), and if successful will be
9-
transferred to that task force for full standardization.
10-
11-
# Introduction
12-
13-
Scripted effects (written in response to `requestAnimationFrame` or async `onscroll` events) are
14-
rich but are subject to main thread jankiness. On the other hand, accelerated CSS transitions and
15-
animations can be fast (for a subset of *accelerated* properties) but are not rich enough to enable
16-
[many common use cases](#motivating-use-cases) and currently have no way to access scroll offset
17-
and other user input. This is why scripted effects are still very popular for implementing common
18-
effects such as hidey-bars, parallax, position:sticky, and etc. We believe (and others
19-
[agree][roc-thread]) that there is a need for a new primitive for creating fast and rich visual
20-
effects with the ability to respond to user input such as scroll.
21-
22-
This document proposes an API to create custom animations that execute inside an isolated execution
23-
environment, *worklet*. It aims to be compatible with Web Animations and uses existing constructs as
24-
much as possible. We believe this API hits a sweet spot in balancing among performance, richness,
25-
and rationality for addressing our key use cases.
26-
27-
See the [Animation Worklet design principles and goals](principles.md) for an overview of the
28-
motivations behind Animation Worklet and how the design will be evolved to support a growing set of
29-
rich use cases. Also see [the status document](status.md) for high level implementation status and
30-
timeline.
6+
Animation Worklet is a new primitive that provides extensibility in web animations and enables high
7+
performance procedural animations on the web. The feature is developed as part of the
8+
[CSS Houdini task force](https://github.com/w3c/css-houdini-drafts/wiki).
319

32-
# Motivating Use Cases
33-
34-
* Scroll-linked effects:
35-
- Parallax ([demo](https://googlechromelabs.github.io/houdini-samples/animation-worklet/parallax-scrolling/))
36-
- Animated scroll headers, eg. "hidey-bars" ([demo](https://googlechromelabs.github.io/houdini-samples/animation-worklet/twitter-header/), [twitter](https://twitter.com/LEGO_Group), [Polymer `paper-scroll-header-panel`](https://elements.polymer-project.org/elements/paper-scroll-header-panel?view=demo:demo/index.html))
37-
- Springy sticky elements ([demo](http://googlechromelabs.github.io/houdini-samples/animation-worklet/spring-sticky/))
10+
The Animation Worklet API provides a method to create scripted animations that control a set of
11+
animation effects. These animations are executed inside an isolated execution environment, *worklet*
12+
which makes it possible for user agents to run such animations in their own dedicated thread to
13+
provide a degree of performance isolation from main thread. The API is compatible with Web
14+
Animations and uses existing constructs as much as possible.
3815

39-
* Animations with custom timing functions (particularly those that are not calculable a priori)
16+
# Background
4017

41-
- Spring timing function ([demo](https://googlechromelabs.github.io/houdini-samples/animation-worklet/spring-timing/))
18+
Scripted interactive effects (written in response to `requestAnimationFrame`, `pointer events` or
19+
async `onscroll` events) are rich but are subject to main thread jankiness. On the other hand,
20+
accelerated CSS transitions and animations can be fast (for a subset of *accelerated* properties)
21+
but are not rich enough to enable [many common use cases](#motivating-use-cases) and currently have
22+
no way to access key user input (pointer events, gestures, scroll). This is why scripted effects are
23+
still very popular for implementing common effects such as hidey-bars, parallax, pull-to-refresh,
24+
drag-and-drop, swipe to dismiss and etc. Animation Worklet provides is key building block for
25+
enabling creation of smooth rich interactive visual effects on the web while also exposing an
26+
extensibility hook in web animations.
4227

43-
* Location tracking and positioning:
4428

45-
- Position: sticky
29+
See the [Animation Worklet design principles and goals](principles.md) for a more extended overview
30+
of the motivations behind Animation Worklet and how the design will be evolved to support a growing
31+
set of use cases. Also see [the status document](status.md) for high level implementation status and
32+
timeline. [Here][roc-thread] you may find an earlier high level discussion on general approaches to
33+
address this problem.
4634

47-
* Procedural animation of multiple elements in sync:
4835

49-
- Efficient Expando ([demo](http://googlechromelabs.github.io/houdini-samples/animation-worklet/expando/), [more info](https://developers.google.com/web/updates/2017/03/performant-expand-and-collapse))
50-
- Compositing growing / shrinking box with border (using 9 patch)
51-
52-
* Sophisticated effects which involves complex coordination across multiple animations.
36+
# Motivating Use Cases
5337

38+
* Scroll driven effects:
39+
* [Hidey-bar](https://googlechromelabs.github.io/houdini-samples/animation-worklet/twitter-header/): animation depends on both time and scroll input.
40+
* [Parallax](https://googlechromelabs.github.io/houdini-samples/animation-worklet/parallax-scrolling/): Simplest scroll-drive effect.
41+
* [Custom paginated slider](http://aw-playground.glitch.me/amp-scroller.html).
42+
* Pull-to-refresh: animation depends on both touch and time inputs.
43+
* Custom scrollbars.
44+
* High-fidelity location tracking and positioning
45+
* [More examples](https://github.com/w3c/css-houdini-drafts/blob/master/scroll-customization-api/UseCases.md) of scroll-driven effects.
46+
47+
* Gesture driven effects:
48+
* [Image manipulator](https://github.com/w3c/csswg-drafts/issues/2493#issuecomment-422153926) that scales, rotates etc.
49+
* Swipe to dismiss.
50+
* Drag-N-Drop.
51+
* Tiled panning e.g., Google maps.
52+
* Stateful script driven effects:
53+
* [Spring timing emulations](https://googlechromelabs.github.io/houdini-samples/animation-worklet/spring-timing/).
54+
* [Spring-Sticky effect](http://googlechromelabs.github.io/houdini-samples/animation-worklet/spring-sticky/).
55+
* Touch-driven physical environments.
56+
* [Expando](http://googlechromelabs.github.io/houdini-samples/animation-worklet/expando/): Procedural animations with multiple elements.
57+
* Animated scroll offsets:
58+
* Having multiple scrollers scroll in sync e.g. diff viewer keeping old/new in sync when you
59+
scroll either ([demo](https://googlechromelabs.github.io/houdini-samples/animation-worklet/sync-scroller/))
60+
* Custom smooth scroll animations (e.g., physic based fling curves)
61+
* Animation Extensibility:
62+
* Custom timing functions (particularly those that are not calculable a priori)
63+
* Custom animation sequencing which involves complex coordination across multiple effects.
64+
65+
66+
Not all of these usecases are immediately enabled by the current proposed API. However Animation
67+
Worklet provides a powerfull primitive (off main-thread scriped animation) which when combined with
68+
other upcoming features (e.g.,
69+
[Event in Worklets](https://github.com/w3c/css-houdini-drafts/issues/834),
70+
[ScrollTimeline](https://wicg.github.io/scroll-animations/),
71+
[GroupEffect](https://github.com/w3c/csswg-drafts/issues/2071)) can address all these usecases and
72+
allows many of currently main-thread rAF-based animations to move off thread with significant
73+
improvement to their smoothness.
74+
See [Animation Worklet design principles and goals](principles.md) for a more extended discussion
75+
of this.
5476

5577

56-
These usecases are enabled by the current proposed but [additional usecases](principles.md
57-
#animation-worklet-vision) including input-driven animations are going to be addressed by extension
58-
of the API.
5978

6079
***Note***: Demos work best in the latest Chrome Canary with the experimental
6180
web platform features enabled (`--enable-experimental-web-platform-features`

0 commit comments

Comments
 (0)