Jump to content
Search Community

Can you dynamically add an 'onComplete' to a TimelineMax instance?

green_machine test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

I know that in the constructor, you can pass a parameter for the 'onComplete' event. But once a TimelineMax instance has been created, can you dynamically add one? I didn't see anything in the docs about it. I'm looking to do something like this:

 

if(...) {
	myTimeline.onComplete(function() {
		// do this stuff
	});
} else if(...) {
	myTimeline.onComplete(function() {
		// do this other stuff
	});
}

 

Link to comment
Share on other sites

I'm not sure how to dynamically add an onComplete function after the timeline is created but there is likely someone more knowledgeable here who would.

 

You could do it the other way around and put the if statements inside the function you're running to determine what happens in an onComplete.

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