Jump to content


CSS3 animation complete callbacks

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

If a step in a timeline sets a class with a transition, is it possible to get a callback when the CSS3 transition has completed rather than immediately after the class is added?

  • Like 1
Link to comment
Share on other sites

Yes. But did you know that you can tween to a CSS class?

TweenLite.to(myElement, 1, { className: "+=myClass", onComplete: myCallback });

Or you can do it the hard way and hope the event fires.

myElement.addEventListener("transitionend", myCallback);
  • Like 3
Link to comment
Share on other sites

  • 2 years later...

Does this only work for TweenLite or TweenMax?
I'm trying to do it at the end of a sequential animation with TimelineMax and it doesn't work.

t3.to(LogoSystems, 3.5, {"left":nLeft+"px", onComplete: doAnim2});

If I remove the onComplete property it works fine.


Link to comment
Share on other sites

That's for a tween. You can add callbacks for a timeline in the constructor.

var tl = new TimelineMax({
  onComplete: doSomething


  • Like 3
Link to comment
Share on other sites

Yeah, Blake is right, the onComplete of the timeline sounds like what you want, but putting it on the last tween that's in a timeline is valid too.

In these cases it really helps to see a reduced CodePen demo as we can get a better sense of exactly what is going on.



  • Like 2
Link to comment
Share on other sites

I tried it on the last timeline and it didn't work. Could'a been a bug I didn't catch.

I tried it Blake's way. Thanks - that worked!

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.