You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{ trigger: new ScrollTrigger({ scrollSource: scrollableElement,
74
-
scrollOffset: 'auto',
75
-
endScrollOffset: 'auto' })});
102
+
var abstractMenuAnimation = abstractMenuDiv.getAnimations()[0];
103
+
abstractMenuAnimation.timeline = new DocumentTimeline(
104
+
{ trigger: new ScrollTrigger({ scrollSource: scrollableMainContent,
105
+
orientation: "vertical",
106
+
scrollOffset: '0px' })});
76
107
</pre>
77
108
78
-
DocumentTimeline with ScrollTringger {#document-timeline-with-scrolltrigger-use-case}
79
-
-----------------------------------
80
-
The animations will use the document timeline, but some people will want to trigger these animation when reaching certain position in the content.
109
+
### The navigation position effect ### {#navigation-position-effect-usecase}
110
+
Several contents are separating the initial page and main content page. So if we build single page content, we may need to use the scroll-triggered animation.
111
+
112
+
Here's example for using the scroll-triggered animations.
113
+
This content has a navigation bar, this navigation icon is displayed a large icon when viewing initial view. However, this navigation will become a small icon , when scrolling contents.
114
+
115
+
<figure>
116
+
<img src="img/usecase1-2.svg" width="600"
117
+
alt="Use case 1-2: Scroll based animation.">
118
+
<figcaption>
119
+
Use case 1-2: Scroll based animations.<br>
120
+
The left figure is before scroll, menu icon is large.<br>
121
+
The right figure is after scroll, menu icon become small.
### Scrollable picture-story show ### {#scrollable-animation-usecase}
193
+
There are many animation contents which used the 3rd vendor plugins. These content can detect scroll event, and this content has interactive animation.
194
+
195
+
Here's content has interactive animation too, it is a picture-story show. If we scrolled this content, the character of story will move.
196
+
197
+
If we scrolled opposite direction, this animation move to the opposite direction(reverse).
198
+
199
+
<figure>
200
+
<img src="img/usecase3-1.svg" width="600"
201
+
alt="Use case 3-1: The picture-story show.">
202
+
<figcaption>
203
+
Use case 3-1: The picture-story show.<br>
204
+
The left figure is before scroll, this picture-story show didn't start.<br>
205
+
The right figure is after scroll, this story will start.
206
+
</figcaption>
207
+
</figure>
208
+
209
+
If we use animation-timeline, example code will be as follow.
unionCircleAnimation.timeline = new ScrollTimeline({
266
+
trigger: new ScrollTrigger({
267
+
scrollSource:scrollableElement,
268
+
scrollOffset: '250px',
269
+
endScrollOffset: '300px'})});
96
270
</pre>
97
271
98
-
ScrollTimeline with scroll range {#scroll-timeline-with-scroll-range-use-case}
99
-
-----------------------------------
100
-
This use case is similar to ScrollTimeline.
101
-
The difference is that there are scroll range in order to enable the animation.
102
-
Once scroll position will be out of range, the animation will cancel.
103
-
104
-
This use case is as follow:
105
-
106
-
Here’s an example content like picture-story show with animated element.
107
-
The developer want to show the animated element when scroll position reach the certain position,
108
-
and she want to cancel the animation when scroll position is out of range.(perhaps when we can’t see these element.)
109
-
110
-
<img src="img/usecase3.png" width="600"
111
-
alt="Usecase 3: ScrollTimeline with scroll range">
272
+
### The content progress bar ### {#content-progress-bar-usecase}
273
+
There is much content that using to scroll linked animations.
274
+
Here's one of these animation content, this content has a long article.
275
+
And this content has a progress bar which indicates the current position of the article.
276
+
277
+
If we scroll the content, this progress bar increased / decreased.
278
+
279
+
<figure>
280
+
<img src="img/usecase3-2.svg" width="600"
281
+
alt="Use case 3-2: Scroll based styling">
282
+
<figcaption>
283
+
Use case 3-2: Content progress bar.<br>
284
+
The left figure is before scroll, the progress bar is not displayed.<br>
285
+
The right figure is after scroll, the progress bar advanced.
286
+
</figcaption>
287
+
</figure>
288
+
289
+
Usually, we won't need to this progress bar, because the scroll bar indicated the progress. But some content will want to hide the scroll bar, like this content.
290
+
291
+
If we use animation-timeline, this example code will be as follow.
If we use this API for this case, the example code will be as follow:
114
312
<pre class='lang-javascript'>
115
-
// We enable the animation within the range[300px-800px].
116
-
var animation = div.getAnimations()[0];
117
-
animation.timeline = new ScrollTimeline(
118
-
{ trigger: new ScrollTrigger({ scrollSource: scrollableElement,
119
-
scrollOffset: '300px',
120
-
endScrollOffset: '800px'}) });
313
+
var animation = div.getAnimations()[0];
314
+
animation.timeline = new ScrollTimeline(
315
+
{ trigger: new ScrollTrigger({ scrollSource: scrollableElement,
316
+
scrollOffset: '0px'}) });
121
317
</pre>
122
318
123
-
ScrollTimeline with scroll range and interval {#scroll-timeline-with-scroll-range-and-interval-use-case}
124
-
-----------------------------------
125
-
This use case is similar to ScrollTimeline with scroll range.
126
-
The difference is behavior of out of range.
127
-
Once scroll position is out of range, the animation will continue until animation is finish.
128
-
But some animation have infinity duration, so we use the interval property of ScrollTrigger in such case.
319
+
## Combination scroll and time-base animations ## {#combination-scroll-and-time-base-animations-usecase}
129
320
130
-
This use case is as follow:
321
+
### The photo viewer ### {#movie-show-case-usecase}
322
+
Maybe the developer will want to use the scroll based timeline and the time-based timeline.
131
323
132
-
Basically, this use case is same to the ScrollTimeline with scroll range.
133
-
However developer will want to continue some animation’s effect.
324
+
Here's an example content which showing the photos.
325
+
If scroll position is out of specified range, the animation of the slideshow will start. The progress of this slideshow is related to scroll volume. And if scroll position is within the specified range, the animation of the slideshow will continue automatically.
134
326
135
-
<img src="img/Usecase4.png" width="600"
136
-
alt="Usecase4 : ScrollTimeline with scroll range and interval">
327
+
<figure>
328
+
<img src="img/usecase4.svg" width="600"
329
+
alt="Use case 4: Scrollable slide show.">
330
+
<figcaption>
331
+
Use case 4: Scrollable slide show.<br>
332
+
The left figure is before scroll, the slide show will start as scroll-linked animation.<br>
333
+
The right figure is after scroll, the slide show will start as related to the time animation.
334
+
</figcaption>
335
+
</figure>
137
336
138
-
If we use this API for this case, the example code will be as follow:
337
+
This content can't build the CSS only.
139
338
<pre class='lang-javascript'>
140
-
var animation = div.getAnimations()[0];
141
-
142
-
// We will animate this animation 1000ms after exceed range.
143
-
animation.timeline = new DocumentTimeline(
144
-
{ trigger: new ScrollTrigger({ scrollSource: scrollableElement,
145
-
scrollOffset: '300px',
146
-
endScrollOffset: '800px',
147
-
interval: '1000ms'}) });
339
+
var animation = slideTarget.getAnimation()[0];
340
+
var scrollTimeline = new ScrollTimeline(
341
+
{ trigger: new ScrollTrigger({ scrollSource: scrollableElement,
342
+
orientation: "vertical",
343
+
scrollOffset: '0px',
344
+
endScrollOffset: '200px'})});
345
+
animation.timeline = scrollTimeline;
346
+
347
+
// We use scroll event in order to change the timeline.
0 commit comments