Jump to content
Search Community

Cue function on Complete in TimelineMax

Guest Pusher
Moderator Tag

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

Hi there,


Sorry if this is a stupid question.


I am trying to pause a function and only start it when an onComplete happens in TimelineMax. The function works perfectly except that when it plays it is off screen because it is firing as soon as the animation starts.

var tl = new TimelineMax ()
.from("#txt1", 1, {right:-280, ease:Power2.easeInOut}, "+=4")
.from("#counter", 1, {right:-280, ease:Power2.easeInOut, onComplete: startCounter})
.from("#txt2", 1, {right:-280, ease:Power2.easeInOut})
.from("#logo", 1, {top:250, ease:Power2.easeInOut})
.from("#tag", 1, {right:90, autoAlpha:0, ease:Power2.easeInOut})

var distance = {counter:0}, scoreDisplay = document.getElementById("counter");
function add() {
TweenMax.to(distance, 1, {counter:"+=200", roundProps:"counter", onUpdate:updateHandler});
function updateHandler() {
scoreDisplay.innerHTML = distance.counter;


function startCounter() {

Thanks for any help,



Link to comment
Share on other sites



Its a little difficult to follow your description. I think the big problem is that you are trying to play and pause distance like





distance is just an object {counter:0} it doesn't have play or pause methods.


my only guess without seeing a working codepen demo is that this

.from("#counter", 1, {right:-280, ease:Power2.easeInOut, onComplete: startCounter})

should be changed to

.from("#counter", 1, {right:-280, ease:Power2.easeInOut, onComplete: add})

and you should not call add() directly where you are doing


If you need more help please provide a CodePen demo. It will alleviate the guess work.

  • Like 1
Link to comment
Share on other sites

Hi Carl,


Thank you for the advice. Codepen is brilliant! I will definately use it from now on!

The above seems to have worked. Except that the counter has already played by the time it gets to the stage.


Is there a way to pause distance?


My codepen is here if you can still help!


See the Pen GpjgpL by phillip_vale (@phillip_vale) on CodePen


Thanks so much,



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