Jump to content
Search Community

Timeline Length

Guest Pusher
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

Guest Pusher

Hi there,

 

Is there a basic way to calculate the length of a TimelineMax animation?

 

I do alot of banner work with Greensock and publishers have strict 15sec limits.

 

I can't find an example anywhere.

 

Thanks,

 

Phil

Link to comment
Share on other sites

Absolutely. That's what the duration() is for. Or totalDuration() if you want to include all the repeats and repeatDelays. 

var tl = new TimelineMax();
tl.to(...).to(....); //add stuff

console.log("duration is: " + tl.duration());

If you want it to stop after 15 seconds, you have a lot of options...

tl.addPause(15);

or

TweenLite.delayedCall(15, function() {
    tl.pause();
});

or if you want to be fancy and gradually slow it down after 15 seconds (instead of an abrupt stop):

TweenLite.delayedCall(15, function() {
    TweenLite.to(tl, 1, {timeScale:0, onComplete:function() { tl.pause(); }});
});

Does that help?

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