Jump to content


TimelineLite ignoreAfterTime?

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



Maybe I'm just overlooking something, but what I want is to get all the tweens in a timeline BEFORE a certain time and ignore all the tweens that come after that time.


I saw in the documentation that the method "getChildren" with the parameter "ignoreBeforeTime" set returns all the children after a certain time, but I actually want the opposite.


How can I achieve this?



Link to comment
Share on other sites

1 option would be


  • use getChildren() to get all the children
  • loop through the array of children
  • on each iteration assess the startTime() of each tween
  • if the startTime() is less than some value, then do something to that tween, (remove it,   put it into another timeline, adjust its timeScale or whatever you have in mind)
  • if the startTime() is greater than some value, break the loop and terminate any operations on subsequent tweens.

Here is a little example:



var tl = new TimelineLite({paused:true}),
    afterTweens = [];

tl.to("#box1", 0.5, {left:200})
.to("#box1", 0.5, {left:100})

.to("#box2", 0.5, {rotation:360})
.to("#box2", 0.5, {autoAlpha:360})

var children = tl.getChildren();

//loop the children and assess startTime
for(i = 0; i < children.length; i++){
  if(children[i].startTime() < 1){
     console.log("grab this tween");
     console.log("ignore future tweens");

See the Pen 33bb7f85b0cfb57f7a2b62bbf2fb94c5 by GreenSock (@GreenSock) on CodePen



Another option would be to

  • use getChildren() with ingnoreBeforeTime set to some value
  • place those tweens in timelineB
  • now the original timeline is left with only the tweens before the ignoreBeforeTime.
  • due whatever you want to those tweens

If you need more info, let us know. There could be another more streamlined way to handle this based on exactly what you need to do with both sets of tweens after this operation takes place.

  • Like 2
Link to comment
Share on other sites

Thanks for your answer! I was thinking about that too, but since there was a ignoreBeforeTime parameter I thought there might be a ignoreAfterTime (or something) method/parameter that I wasn't aware of.


I've implemented your code and everything works as it should. Thanks!

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.