Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Mr. Ynk

TimelineMax.tweenTo as a TweenMax?

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!

 

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 } ); 

Share this post


Link to post
Share on other sites

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");
tl.pause();
TweenMax.fromTo(tl, Math.abs(to - from), {time:from}, {time:to, ease:Linear.easeNone, repeat:-1, yoyo:true});

Does that help? 

  • Like 5

Share this post


Link to post
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:
https://github.com/greensock/GreenSock-JS/blob/master/src/uncompressed/TimelineLite.js

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)

Share this post


Link to post
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

Share this post


Link to post
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

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. 


  • Recently Browsing   0 members

    No registered users viewing this page.

×