@@ -36,34 +36,33 @@ address this problem.
36
36
# Motivating Use Cases
37
37
38
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 ) .
39
+ * Hidey-bar ( [ demo ] ( https://googlechromelabs.github.io/houdini-samples/animation-worklet/twitter-header/ ) ) : animation depends on both scroll and time input.
40
+ * Parallax ( [ demo ] ( https://googlechromelabs.github.io/houdini-samples/animation-worklet/parallax-scrolling/ ) ): simplest scroll-driven effect.
41
+ * Custom paginated slider ( [ demo ] ( http://aw-playground.glitch.me/amp-scroller.html ) ).
42
42
* Pull-to-refresh: animation depends on both touch and time inputs.
43
43
* Custom scrollbars.
44
44
* High-fidelity location tracking and positioning
45
45
* [ More examples] ( https://github.com/w3c/css-houdini-drafts/blob/master/scroll-customization-api/UseCases.md ) of scroll-driven effects.
46
46
* Gesture driven effects:
47
47
* [ Image manipulator] ( https://github.com/w3c/csswg-drafts/issues/2493#issuecomment-422153926 ) that scales, rotates etc.
48
- * Swipe to dismiss .
48
+ * Swipe to Action .
49
49
* Drag-N-Drop.
50
50
* Tiled panning e.g., Google maps.
51
51
* Stateful script driven effects:
52
- * [ Spring timing emulations] ( https://googlechromelabs.github.io/houdini-samples/animation-worklet/spring-timing/ ) .
53
- * [ Spring-Sticky effect] ( http://googlechromelabs.github.io/houdini-samples/animation-worklet/spring-sticky/ ) .
52
+ * Spring-Sticky effect ([ demo] ( http://googlechromelabs.github.io/houdini-samples/animation-worklet/spring-sticky/ ) ).
54
53
* Touch-driven physical environments.
55
- * [ Expando] ( http://googlechromelabs.github.io/houdini-samples/animation-worklet/expando/ ) : Procedural animations with multiple elements.
54
+ * Expando ( [ demo ] ( http://googlechromelabs.github.io/houdini-samples/animation-worklet/expando/ ) ): Procedural animations with multiple elements.
56
55
* Animated scroll offsets:
57
56
* Having multiple scrollers scroll in sync e.g. diff viewer keeping old/new in sync when you
58
57
scroll either ([ demo] ( https://googlechromelabs.github.io/houdini-samples/animation-worklet/sync-scroller/ ) )
59
58
* Custom smooth scroll animations (e.g., physic based fling curves)
60
59
* Animation Extensibility:
61
- * Custom timing functions (particularly those that are not calculable a priori)
60
+ * Custom animation timings (particularly those that are not calculable a priori e.g., [ spring demo ] ( https://googlechromelabs.github.io/houdini-samples/animation-worklet/spring-timing/ ) )
62
61
* Custom animation sequencing which involves complex coordination across multiple effects.
63
62
64
63
65
64
Not all of these usecases are immediately enabled by the current proposed API. However Animation
66
- Worklet provides a powerfull primitive (off main-thread scriped animation) which when combined with
65
+ Worklet provides a powerfull primitive (off main-thread scripted animation) which when combined with
67
66
other upcoming features (e.g.,
68
67
[ Event in Worklets] ( https://github.com/w3c/css-houdini-drafts/issues/834 ) ,
69
68
[ ScrollTimeline] ( https://wicg.github.io/scroll-animations/ ) ,
@@ -74,7 +73,6 @@ See [Animation Worklet design principles and goals](principles.md) for a more ex
74
73
of this.
75
74
76
75
77
-
78
76
*** Note*** : Demos work best in the latest Chrome Canary with the experimental
79
77
web platform features enabled (` --enable-experimental-web-platform-features `
80
78
flag) otherwise they fallback to using main thread rAF to emulate the behaviour.
@@ -83,14 +81,15 @@ flag) otherwise they fallback to using main thread rAF to emulate the behaviour.
83
81
# Animation Worklet
84
82
85
83
Animation Worklet attempts to address the above usecases by introducing a new primitive that enables
86
- extensibility in the web's core animation model [ WebAnimations] [ WA ] ): custom animate function!
84
+ extensibility in the web's core animation model [ WebAnimations] [ WA ] ): custom frame-by-frame animate
85
+ function!
87
86
88
87
89
88
## How It Works
90
89
91
- Normally, an active animation takes its timeline time and according to its running state (e.g., playing,
92
- finished) and playback rate, computes its own ** current time** which it then uses to set its
93
- keyframe effect ** local time** . Here is a simple example of a simple animation:
90
+ Normally, an active animation takes its timeline time and according to its running state (e.g.,
91
+ playing, finished) and playback rate, computes its own ** current time** which it then uses to set
92
+ its keyframe effect ** local time** . Here is a simple example of a simple animation:
94
93
95
94
``` js
96
95
const effect = new KeyframeEffect (targetEl,
@@ -289,7 +288,7 @@ registerAnimator('twitter-header', class TwitterHeader extends StatelessAnimator
289
288
});
290
289
```
291
290
292
- ## Swipe-to-Dissmiss
291
+ ## Swipe-to-Action
293
292
294
293
Another usecase for Animation Worklet is to enable interactive input-driven animation effects that
295
294
are driven both by input events and time.
@@ -301,7 +300,7 @@ also allow [playback controls](https://github.com/w3c/css-houdini-drafts/issues/
301
300
worklets. Both of these are natural planned additions to Animation Worklet.
302
301
303
302
304
- Consider a simple swipe-to-dismiss effect which follows the user swipe gesture and when finger lifts
303
+ Consider a simple swipe-to-action effect which follows the user swipe gesture and when finger lifts
305
304
then continues to completion (either dismissed or returned to origin) with a curve that matches the
306
305
swipe gesture's velocity. (See this [ example] ( https://twitter.com/kzzzf/status/917444054887124992 ) )
307
306
@@ -324,10 +323,10 @@ Note that while in (3), if the user touches down we go back to (2) which ensures
324
323
user touch input.
325
324
326
325
To make this more concrete, here is how this may be implemented (assuming strawman proposed APIs for
327
- playback controls and also receiving pointer events). Note that all the state machine transitions and
328
- various state data (velocity, phase) and internal to the animator. Main thread only needs to provide
329
- appropriate keyframes that can used to translate the element on the viewport as appropriate (e.g.,
330
- ` Keyframes(target, {transform: ['translateX(-100vw)', 'translateX(100vw)']}) ` ).
326
+ playback controls and also receiving pointer events). Note that all the state machine transitions
327
+ and various state data (velocity, phase) and internal to the animator. Main thread only needs to
328
+ provide appropriate keyframes that can used to translate the element on the viewport as appropriate
329
+ (e.g., ` Keyframes(target, {transform: ['translateX(-100vw)', 'translateX(100vw)']}) ` ).
331
330
332
331
333
332
``` javascript
@@ -596,8 +595,8 @@ scroll-linked animation proposal. It defines an animation timeline whose time va
596
595
scroll position of a scroll container. ` ScrollTimeline ` can be used an an input timeline for
597
596
worklet animations and it is the intended mechanisms to give read access to scroll position.
598
597
599
- We can later add additional properties to this timeline (e.g., scroll phase (active, inertial, overscroll),
600
- velocity, direction) that can further be used by Animation Worklet.
598
+ We can later add additional properties to this timeline (e.g., scroll phase (active, inertial,
599
+ overscroll), velocity, direction) that can further be used by Animation Worklet.
601
600
602
601
## GroupEffect
603
602
@@ -615,6 +614,7 @@ benefitial to Animation Worklet as it provides an ergonomic and low latency way
615
614
Worklet to receive pointer events thus enabling it to implement input driven animations more
616
615
effectively.
617
616
617
+
618
618
# WEBIDL
619
619
620
620
` WorkletAnimation ` extends ` Animation ` and adds a getter for its timelines.
0 commit comments