Jump to content
Search Community

Something like on onInit?

niko 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

Hi there!

 

In the AS version there was something called onInit, I think I might need something similar. Creating a game where there's a speech bubble, it's a div that can vary in width/height, depending on the amount of content, this div is reused throughout the game. When an animation is run, onStart fires a function for replacing the content of the bubble, I give the contents of the bubble as onStartParams. The problem is, this speech bubble should always be centered (both vertically and horizontally), but this won't work the first time the animation runs, I suspect this is because the onStart runs after the tween inits.

 

Any way to give the onStart and onStartParams before the tween inits? 

Link to comment
Share on other sites

Yep, there's a sneaky way to do this: just leverage the fact that startAt values get set before initialization, and startAt is basically just a zero-duration tween that runs first, so you could do this:

TweenLite.to(element, 1, {startAt:{onComplete:yourFunc, onCompleteParams:[whatever]}, width:100});
Link to comment
Share on other sites

Hi,

 

Maybe you could try a TweenMax.set instance to center the element before everything else happens. Also you could add an opacity to it as well, like that when the main animation starts everything will be on the right place.

 

Hope this helps,

Cheers,

Rodrigo.

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