Jump to content


TimelineMax not firing TweenLite onStart function when repeating

Go to solution Solved by Carl,

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

Great topic title I know, sorry about that.


Hi I'm trying to build a TimelineMax animation dynamically by adding TweenLites which is working fine.

As part of the code I need a function to be called when each of the TweenLite animations start. I'm doing this by calling onStart:. Again this works fine.


I am repeating the timeline as I want to play it backwards which again is visually working as expected. I don't however seem to be able to get the onStart function to call when the TimelineMax animation is in reverse.


In case this description makes no sense I have a codepen demo, you can see that the count is only increasing whilst the animation is playing forwards. 


I've also tried TimelineMax.reverse but this also only calles the onStart when going forwards. 


I'm sure there is an easy way to achieve this can anyone point me in the right direction.



See the Pen MYoXKb by anon (@anon) on CodePen

Link to comment
Share on other sites

  • Solution

Thanks for the demo, very helpful.


onStart only fires when the tween starts playing from a time of 0 and moves forward.

If you want a callback to fire whenever the playhead reaches the beginning of a tween, regardless of direction, I would suggest adding a separate callback directly to the timeline at the same time the tween is added like so:


while (i--) {
    .to('#redBox', 0.05, {x: "+=10"});

function updateCount() {

see it here: http://codepen.io/GreenSock/pen/EaXRPw?editors=001


Does that work for you?

  • Like 1
Link to comment
Share on other sites

Of course so simple when you know how :)


That will work just fine for what I need, I knew there would be a way around it as you guys seems to have thought of most things.


Thanks very much for such a speedy response.

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