Jump to content


TimelineMax Convenience Methods and Tween Classes

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

Do TimelineMax convenience methods only create TweenLite Classes, or can they create TweenMax Classes?


I want to create TweenMax Objects, not TweenLite Objects. If I want to do this, will I have to use TimelineMax.add(TweenMax.convenienceMethod())?

Link to comment
Share on other sites

Yes, you need to use add() in order to add a TweenMax, the timeline convenience methods only return TweenLite instances.

timeline.add(TweenMax.to(elem, 1, {opacity:0, repeat:1, yoyo:true})
.add(TweenMax.staggerTo(elements, 2, {left:100}, 0.2), "+=1");
Link to comment
Share on other sites

Thank you.


Any thoughts/plans for the future to make timeline convenience methods intelligently determine whether to use a TweenLite vs. TweenMax based on what's needed to achieve the special properties (basic/advanced) passed in the vars param of the tween?


That would truly be a convenience method with complete flexibility.


Just a thought on my part. It would be nice to have.


Thanks again!

Link to comment
Share on other sites

The challenge is just that the convenience methods are in TimelineLite (notice the "Lite" ;) ). It's always a tough balancing act between cramming all sorts of conveniences in there, and keeping things lightweight and fast. That's why we split the platform into "Lite" and "Max" flavors. One thought would be to make convenience methods in TimelineMax use TweenMax instances whereas TimelineLite would use TweenLite instances. But frankly, it's very rare that TweenMax instances are required. The only time I can think of is if you need to use the repeat feature (and yoyo and/or repeatDelay). For those cases it's pretty easy to just use add( TweenMax.to(...) ) so I'm very apprehensive about creating a dependency inside TimelineMax on TweenMax. Especially in JS because TweenMax is quite a bit larger as it includes a bunch of other plugins and eases. 


Adding code internally to sense whether or not TweenMax is loaded would certainly work, but again it's additional logic that eats up kb. Not sure it's really worthwhile. I assume you'd vote for that code to be included, though, right? If there's enough demand, we'd probably tuck it in there, but like I said, we're pretty protective of the file size.

  • Like 1
Link to comment
Share on other sites

I understand.  Yes, I would definitely vote for that functionality. Although, I am able to work with the current functionality as is.  Again, it's just the convenience of it (using convenience methods the way I would like). I am working on my first applications of Greensock, and I already have a need for using repeat functionality in my tweens and nesting them inside a timeline.


But like you said, I just had to create my TweenMax, and then add it to the timeline. Maybe one day there will be enough demand or need to add the convenience methods as a part of TimelineMax to use TweenMax.

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.