Jump to content
Search Community

Two animations at the same time, finish both when first one is complete

dragoon test
Moderator Tag

Go to solution Solved by Cassie,

Recommended Posts

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

  • Solution

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()},
});

 

  • Thanks 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...