GSAP Timelines
GSAP Timeline
Since in tween we have to set delay property to play one after another and if we change delay of one we must rewrite all timing of other items. But with the help of timeline all these problems are solved:
gsap.to('.box1',{y:200, duration:1, delay:1})
gsap.to('.box2',{x:100, duration:0.5, delay:2})
gsap.to('.box3',{y:400, duration:1, delay:3})
gsap.to('.box4',{y:200, duration:1, delay:4})
We should set delay after each to play this in sequence, if we set delay of box4 to 1 then our box1 and box4 will move together, so also need to estimate time correctly.
A timeline is created with gsap.timeline();
All tweens in a timeline naturally play one after the other.
The same tween code written in timeline is below:
gsap.timeline()
.to(".box1", {y:200, duration:1})
.to(".box2", {x:100, duration:0.5})
.to(".box3", {y:400, duration:1})
.to(".box4", {y:200, duration:1})
now each box will come one after another, I mean when animation of box1 completed animation of box2 starts and after box2 finishes box3 starts and finally when animation of box3 finishes animation of box4 starts. Here there is no use of delay property but our box flow one after another another.
In normal condition the box code which is written at first, that's animation will occur at first.
Comments
Post a Comment