Skip to content

Commit 0bcbe0b

Browse files
majidobfgeek
authored andcommitted
[css-workletanimation] merge changes from original repo since migration (w3c#801)
* Fixed typos and mistakes in code examples. (w3c#107) * fixed: wrong camelCase: KeyFrameEffect -> KeyframeEffect * fixed typo: WorklerAnimation -> WorkletAnimation * added missing CSS object, and * updated index.html * Add [Exposed] to interfaces (w3c#109) Add appropriate [Exposed] to interfaces. https://heycam.github.io/webidl/#idl-interfaces says: "Non-callback interfaces which are not annotated with a [NoInterfaceObject] extended attribute, and callback interfaces which declare constants must be annotated with an [Exposed] extended attribute."
1 parent 5261c1a commit 0bcbe0b

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

css-animationworklet/Overview.bs

+8-8
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,14 @@ The {{animationWorklet}}'s <a>worklet global scope type</a> is {{AnimationWorkle
176176
{{AnimationWorkletGlobalScope}} represents the global execution context of {{animationWorklet}}.
177177

178178
<xmp class='idl'>
179+
[Exposed=Window]
179180
partial namespace CSS {
180181
[SameObject] readonly attribute Worklet animationWorklet;
181182
};
182183
</xmp>
183184

184185
<xmp class='idl'>
185-
[ Exposed=AnimationWorklet, Global=AnimationWorklet ]
186+
[Exposed=AnimationWorklet, Global=AnimationWorklet]
186187
interface AnimationWorkletGlobalScope : WorkletGlobalScope {
187188
void registerAnimator(DOMString name, VoidFunction animatorCtor);
188189
};
@@ -511,9 +512,8 @@ Creating a Worklet Animation {#creating-worklet-animation}
511512
-----------------------------------------------------------
512513

513514
<xmp class='idl'>
514-
515-
516-
[Constructor (DOMString animatorName,
515+
[Exposed=Window,
516+
Constructor (DOMString animatorName,
517517
optional (AnimationEffect or sequence<AnimationEffect>)? effects = null,
518518
optional AnimationTimeline? timeline,
519519
optional any options)]
@@ -689,7 +689,7 @@ times</a>. This allows a single worklet animation to coordinate multiple effects
689689
[[#example-2]] for an example of such a use-case.
690690

691691
<xmp class='idl'>
692-
692+
[Exposed=AnimationWorklet]
693693
interface WorkletGroupEffect {
694694
sequence<AnimationEffect> getChildren();
695695
};
@@ -754,7 +754,7 @@ const documentTimeline = document.timeline;
754754
// currenTime values directly.
755755
const animation = new WorkletAnimation(
756756
'hidey-bar',
757-
new KeyFrameEffect($header,
757+
new KeyframeEffect($header,
758758
[{transform: 'translateX(100px)'}, {transform: 'translateX(0px)'}],
759759
{duration: 1000, iterations: 1, fill: 'both' }]),
760760
scrollTimeline,
@@ -823,10 +823,10 @@ sync with scroll offset.
823823
await CSS.animationWorklet.addModule('twitter-header-animator.js');
824824
const animation = new WorkletAnimation(
825825
'twitter-header',
826-
[new KeyFrameEffect($avatar, /* scales down as we scroll up */
826+
[new KeyframeEffect($avatar, /* scales down as we scroll up */
827827
[{transform: 'scale(1)'}, {transform: 'scale(0.5)'}],
828828
{duration: 1000, iterations: 1}),
829-
new KeyFrameEffect($header, /* loses transparency as we scroll up */
829+
new KeyframeEffect($header, /* loses transparency as we scroll up */
830830
[{opacity: 0}, {opacity: 0.8}],
831831
{duration: 1000, iterations: 1})],
832832
new ScrollTimeline($scrollingContainer, {timeRange: 1000, startScrollOffset: 0, endScrollOffset: $header.clientHeight}));

css-animationworklet/README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ hooks:
132132

133133
```js
134134
// in document scope
135-
new WorklerAnimation('animation-with-local-state', [], [], {value: 1});
135+
new WorkletAnimation('animation-with-local-state', [], [], {value: 1});
136136
```
137137

138138

@@ -176,16 +176,16 @@ it animates fully to close or open position depending on its current position.
176176
</div>
177177

178178
<script>
179-
animationWorklet.addModule('hidey-bar-animator.js');
179+
await CSS.animationWorklet.addModule('hidey-bar-animator.js');
180180
const scrollTimeline = new ScrollTimeline($scrollingContainer, {timeRange: 100});
181181
const documentTimeline = document.timeline;
182182
183183
184184
const animation = new WorkletAnimation('hidey-bar',
185-
new KeyFrameEffect($header,
185+
new KeyframeEffect($header,
186186
[{transform: 'translateX(100px)'}, {transform: 'translateX(0px)'}],
187187
{duration: 100, iterations: 1, fill: 'both' })
188-
scrollTimeline,
188+
scrollTimeline,
189189
{scrollTimeline, documentTimeline},
190190
);
191191
animation.play();
@@ -242,12 +242,12 @@ sync with scroll offset.
242242
</div>
243243

244244
<script>
245-
await animationWorklet.addModule('twitter-header-animator.js');
245+
await CSS.animationWorklet.addModule('twitter-header-animator.js');
246246
const animation = new WorkletAnimation('twitter-header',
247-
[new KeyFrameEffect($avatar, /* scales down as we scroll up */
247+
[new KeyframeEffect($avatar, /* scales down as we scroll up */
248248
[{transform: 'scale(1)'}, {transform: 'scale(0.5)'}],
249249
{duration: 1000, iterations: 1}),
250-
new KeyFrameEffect($header, /* loses transparency as we scroll up */
250+
new KeyframeEffect($header, /* loses transparency as we scroll up */
251251
[{opacity: 0}, {opacity: 0.8}],
252252
{duration: 1000, iterations: 1})] ,
253253
new ScrollTimeline($scrollingContainer, {timeRange: 1000, startScrollOffset: 0, endScrollOffset: $header.clientHeight}),
@@ -295,7 +295,7 @@ registerAnimator('twitter-header', class {
295295
</div>
296296

297297
<script>
298-
await animationWorklet.addModule('parallax-animator.js');
298+
await CSS.animationWorklet.addModule('parallax-animator.js');
299299
const scrollTimeline = new ScrollTimeline($scrollingContainer, {timeRange: 1000});
300300
const scrollRange = $scrollingContainer.scrollHeight - $scrollingContainer.clientHeight;
301301

0 commit comments

Comments
 (0)