Skip to content

Commit 37484e7

Browse files
majidobfgeek
authored andcommitted
[css-animationworklet] update ScrollTimeline usage in examples to match latest syntax (w3c#802)
1 parent 0bcbe0b commit 37484e7

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

css-animationworklet/Overview.bs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,11 @@ animates fully to close or open position depending on its current position.
747747

748748
<script>
749749
await CSS.animationWorklet.addModule('hidey-bar-animator.js');
750-
const scrollTimeline = new ScrollTimeline($scrollingContainer, {timeRange: 1000});
750+
const scrollTimeline = new ScrollTimeline({
751+
scrollSource: $scrollingContainer,
752+
orientation: 'block',
753+
timeRange: 1000
754+
});
751755
const documentTimeline = document.timeline;
752756

753757
// Note we pass in two timelines in the options bag which allows the animation to read their
@@ -829,7 +833,12 @@ const animation = new WorkletAnimation(
829833
new KeyframeEffect($header, /* loses transparency as we scroll up */
830834
[{opacity: 0}, {opacity: 0.8}],
831835
{duration: 1000, iterations: 1})],
832-
new ScrollTimeline($scrollingContainer, {timeRange: 1000, startScrollOffset: 0, endScrollOffset: $header.clientHeight}));
836+
new ScrollTimeline({
837+
scrollSource: $scrollingContainer,
838+
orientation: 'block',
839+
timeRange: 1000,
840+
startScrollOffset: 0,
841+
endScrollOffset: $header.clientHeight}));
833842
animation.play();
834843

835844
// Since this animation is using a group effect, the same animation instance
@@ -880,7 +889,11 @@ A simple parallax background example.
880889

881890
<script>
882891
await CSS.animationWorklet.addModule('parallax-animator.js');
883-
const scrollTimeline = new ScrollTimeline($scrollingContainer, {timeRange: 1000});
892+
const scrollTimeline = new ScrollTimeline({
893+
scrollSource: $scrollingContainer,
894+
orientation: 'block',
895+
timeRange: 1000
896+
});
884897
const scrollRange = $scrollingContainer.scrollHeight - $scrollingContainer.clientHeight;
885898

886899
const slowParallax = new WorkletAnimation(

css-animationworklet/README.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,12 @@ it animates fully to close or open position depending on its current position.
177177

178178
<script>
179179
await CSS.animationWorklet.addModule('hidey-bar-animator.js');
180-
const scrollTimeline = new ScrollTimeline($scrollingContainer, {timeRange: 100});
180+
181+
const scrollTimeline = new ScrollTimeline({
182+
scrollSource: $scrollingContainer,
183+
orientation: 'block',
184+
timeRange: 100
185+
});
181186
const documentTimeline = document.timeline;
182187
183188
@@ -249,8 +254,13 @@ const animation = new WorkletAnimation('twitter-header',
249254
{duration: 1000, iterations: 1}),
250255
new KeyframeEffect($header, /* loses transparency as we scroll up */
251256
[{opacity: 0}, {opacity: 0.8}],
252-
{duration: 1000, iterations: 1})] ,
253-
new ScrollTimeline($scrollingContainer, {timeRange: 1000, startScrollOffset: 0, endScrollOffset: $header.clientHeight}),
257+
{duration: 1000, iterations: 1})],
258+
new ScrollTimeline({
259+
scrollSource: $scrollingContainer,
260+
timeRange: 1000,
261+
orientation: 'block',
262+
startScrollOffset: 0,
263+
endScrollOffset: $header.clientHeight}),
254264
);
255265
animation.play();
256266
</script>
@@ -296,7 +306,11 @@ registerAnimator('twitter-header', class {
296306

297307
<script>
298308
await CSS.animationWorklet.addModule('parallax-animator.js');
299-
const scrollTimeline = new ScrollTimeline($scrollingContainer, {timeRange: 1000});
309+
const scrollTimeline = new ScrollTimeline({
310+
scrollSource: $scrollingContainer,
311+
orientation: 'block',
312+
timeRange: 1000
313+
});
300314
const scrollRange = $scrollingContainer.scrollHeight - $scrollingContainer.clientHeight;
301315

302316
const slowParallax = new WorkletAnimation(

0 commit comments

Comments
 (0)