dragoon Posted July 7, 2022 Share Posted July 7, 2022 Hello, I would like to have 2 animations that start at the same time, one with a fixed duration and another is an infinite yoyo animation. I would like to stop yoyo animation when the first animation is complete. Here is my current code: gsap.fromTo(flake, {x: x, y: y}, { duration: fall_duration, y: endY, onComplete: this.onSnowEnd.bind(this), onCompleteParams: [flake], ease: Power0.easeIn }); gsap.to(flake, {duration: 3, x: x + (Math.random() * 150 - 75), repeat: -1, yoyo: true, ease: Power1.easeInOut}); I would like to stop yoyo as soon as the first animation is complete. Link to comment Share on other sites More sharing options...
Solution Cassie Posted July 7, 2022 Solution Share Posted July 7, 2022 Heya! Sure thing, you can use an onComplete callback to pause the yoyo tween. Something like this. let yoyoTween = gsap.to(flake, {...}); gsap.to(flake,{ ... onComplete: () => { yoyoTween.pause()}, }); 1 Link to comment Share on other sites More sharing options...
dragoon Posted July 7, 2022 Author Share Posted July 7, 2022 Thank you. Didn't understand it was that easy! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now