Jump to content


Getting percentage complete of tween

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

Is there a way to easily get the percentage complete of a tween on an object?

Link to comment
Share on other sites



The engine has the progress() method, which allows to get or set a particular instance's (Tween or Timeline) progress.


The value goes between 0 and 1 so it can be easily translated to percentage, in this cae it would be like this:


In order to get the value on a given event, for example a click event:

var tn = TweenLite.to(element, time, {vars});

var button = document.getElementById("button"),

button.onclick = function()
  tweenProgress = tn.progress();

To get the value as the tween plays:

var tn = TweenLite.to(element, time, {vars, onUpdate:updateFunction}),

function updateFunction()
  tweenProgress = tn.progress();

Finally to set the tween/timeline progress you just pass a number between 0 and 1 in the progress call:

var tn = TweenLite.to(element, time, {vars});

//set the tween's to be at half it's playtime

 Here is a codepen that show how you can get the tween's progress:

See the Pen Batoc by rhernando (@rhernando) on CodePen



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