Jump to content

Mr. Ynk

TimelineMax.tweenTo as a TweenMax?

Go to solution Solved by GreenSock,

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 am a big fan of the tweenFromTo and tweenTo function of TimelineMax.


However, these functions always return a TweenLite instance. Is it in any way possible to make that a TweenMax? I would very much like to have access to repeat and yoyo properties, for example.


In other words, something like this would be cool:

myTimeline.tweenFromTo ( 'nowhere', 'somewhere', { repeat:-1, yoyo:true } ); 

(Or, maybe I'm missing something and this is already possible?)

myTimeline.tweenFromTo ( 'nowhere', 'somewhere', { repeat:-1, yoyo:true } ); 

Link to comment
Share on other sites

  • Solution

Yep, we do that in order to keep the smallest footprint in terms of requirements. You can totally use TweenMax for that stuff if you want. Keep in mind that tweenTo() and tweenFromTo() are just convenience methods that:

  1. Pause the timeline
  2. Create a linear tween of the timeline's "time"

That's it. 


So you could do it yourself like:

var from = tl.getLabelTime("nowhere");
var to = tl.getLabelTime("somewhere");
TweenMax.fromTo(tl, Math.abs(to - from), {time:from}, {time:to, ease:Linear.easeNone, repeat:-1, yoyo:true});

Does that help? 

  • Like 5
Link to comment
Share on other sites

Hey Jack, yes, that works - and I understand the need for a small footprint. For our current situation we chose to override TimelineMax.prototype.tweenTo, by simply copying the existing version and replacing TweenLite for TweenMax :)



Can we suggest to using something like below be an option for a future release?

var TweenEngine = _globals.TweenMax || TweenLite;

Like you use for TimelineLite:

on line 99 for example.


We think that there is no need for using TweenLite ever, if TweenMax is available...? (But we could very well be wrong)

Link to comment
Share on other sites

Sure, that should be doable for the next release. 


For the record, the other reason we default to TweenLite is because it's very **slightly** faster performance-wise :) Though I doubt you'd notice unless you're literally tweening thousands of things simultaneously. 

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