Jump to content
Search Community

Play animation when in viewport AND previous animation has finished

Olly Grunt test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

I would like an animation to play when it enters the viewport, but it must wait until an earlier animation has finished. If the earlier animation has already finished it can play immediately on entering the viewport.

 

Can someone point me in the right direction as to how to approach this? Thanks

Link to comment
Share on other sites

  • Solution

Yeah, here's a quick rough idea: 

ScrollTrigger.create({
	trigger: ...,
	start: ...,
	once: true,
	onEnter: () => {
		gsap.to(..., {
			...
			// add a delay based on how much of the other animation is left to play
			delay: otherAnimation.totalDuration() - otherAnimation.totalTime()
		});
	}
});

 

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...