Jump to content
Search Community

Is it possible to queue tweens with TweenLite?

dominate test
Moderator Tag

Go to solution Solved by Diaco,

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

What I want to achieve is:

 

- Create a tween on myobj and play, let say x:"+=200"

- Some other time another "additive" tween may be created, ie., x:"+=200" more!.

- So, as a result myobj should go x:"+=400".

 

- To do that, second tween should wait the first one, and then run when it finishes. Moreover, if more tweens come later, they should wait all the previous ones.

- Please note that it is unknown how many tweens would exist. They come dynamically.

 

My question is if it is possible to queue like this using TweenLite, or I need TimelineLite.

 

Thanks.

Link to comment
Share on other sites

  • Solution

Hi dominate :)

 

it's better to use Timeline , you can add tweens to tl and the new tweens will add at the end of timeline , however if you want to just load TweenLite , there's " onComplete " callback for tweens : http://greensock.com/docs/#/HTML5/GSAP/TweenLite/eventCallback/

 

you can define onComplete callback with these ways :

var myAnimation = TweenLite.to(obj,1,{...});
myAnimation.eventCallback("onComplete", myFunction);

or

TweenLite.to(obj,1,{... , onComplete : myFunction });
  • Like 2
Link to comment
Share on other sites

Whatever works best for you situation. It's hard to say if one way is better than the other. A map is nice because you can reorder or remove them fairly easily. Notice how in the example I linked to that it was pulling tweens from the front instead of the back. That would be much harder to do with a timeline.

 

Promises are also nice because you can cancel them and even setup an alternate animation if it gets canceled.

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