Jump to content
Search Community

Best way to fill timeline

multivac test
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

I know this is a very simple question ... with multiple solutions. I'm just curious to see what would be your best solution.

 

My requirement states that the timeline duration must be at least 30 seconds. My actual animation lasts 27 seconds. I would like to "fill" the timeline with absolutely nothing happening for the last 3 seconds, without changing the time scale. The timeline doesn't repeat and the initial timeline duration is unknown.

 

What would you do ?

Link to comment
Share on other sites

Two other minor comments:

  1. You don't even need to use a real target on that final (blank) tween, like tl.to({}, 30 - tl.duration(), {}) or even tl.set({}, {}, 30 - duration()).
  2. If your goal is to stretch the timeline so that it fills 30 seconds exactly (rather than putting an empty filler at the end), you can set its duration after populating it with all your tweens, like tl.duration(30) which will set the timeScale accordingly. 

Happy tweening!

  • Like 4
Link to comment
Share on other sites

  • 1 month later...

Hi,

 

I tried your solution because I got the same issue. I had some animations declined I several instance with different animations in it. The must call en function at the end (calling next animation) the duration must be at least 10 second.

When I call the tl duration it returns 11s if if time the animation it's duration is around 7s. So calculating 10 - tl.duration() is -1s... (when played in firefox).

How to be sure of the real duration of the timeline ?

Link to comment
Share on other sites

Quote

Fill your timeline using the position parameter.

 

Oh right, you can use position parameter with absolute value 0. So irrespective of whether your animation is long or short, it will always be at least 10 second long.  You don't need all the unnecessary calculation or duration etc. :D

 

See the Pen MORKzG?editors=0011 by Sahil89 (@Sahil89) on CodePen

 

  • Like 1
Link to comment
Share on other sites

The next animation need to call a function (when the animation are on a media player). I call this function in an onComplete callback, calling the parent to let it know that the current animation is finished, the next could be a video or an image, not always an other animation, I use a software which control what to display independently.
 

Sahil duration should return 7s, which is the timed duration, and not 11s that's my problem.

 

Link to comment
Share on other sites

The duration (tl.duration()) is computed on all the duration information of the tweens ? So it depends on the hardware and browser whith which it is played, the same animation which duration is 10s (calculated) could be 7s on a fast computer or 12s on a slow computer ?

Link to comment
Share on other sites

2 minutes ago, Regis said:

I call this function in an onComplete callback, calling the parent to let it know that the current animation is finished, the next could be a video or an image, not always an other animation, I use a software which control what to display independently.

 

Put your onComplete callback there. Same thing.

 

The duration is based on all the tweens.

 

If you're having issues, please make a simple demo so we can see what the problem is.

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