Jump to content
Search Community

onComplete and the call stack

BladePoint test
Moderator Tag

Recommended Posts

Lets say I've got 10 functions, and each one does some stuff and does a tween, and I want to execute the functions in succession. If I use onComplete on each function's tween to call the next function, will I end up with a huge call stack? Would using delayedCall instead also result in a big call stack? If I used addEventListener and dispatchEvent to call the successive function instead, would that not create a large call stack?

Link to comment
Share on other sites

I'm not sure I understand your question. I can, however, say that using event listeners instead of regular callbacks would NOT reap any performance benefits. Callbacks are typically faster. And a delayedCall() is just a zero-duration tween with an onComplete and delay anyway, so there's no specific reason to (or not to) use those over a standard tween. 

 

In terms of the call stack, there isn't anything special you need to do specifically for GSAP, but if you write code that spawns tweens that each spawn more tweens that each spawn more tweens (infinitely), that's a logic issue and yes you could definitely bog the system down. That'd be true regardless of what animation tool/technique you use. 

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