Jump to content

Search In
  • More options...
Find results that contain...
Find results in...

Function to fetch point values in 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


I have a timeline I am building with GSAP JS that has several sequenced tweens. When building the tweens, I would like to set the duration of each of those tweens based on an overall ease.

My question is this:

If I have 10 tweens, and I want the duration of each of those tweens to be the result of a Strong.easeOut tween, Is there a method or way to get 10 values from a 10 second tween where I can get an array back of the values for each second of that tween?






var points_array = getPointsFromTo(10,10,0,1,ease:Strong.easeOut);

// points_array might be (did not do the math) [0,.1,.2,.4.,6.,8.,87,.92,.98,1]

// In this way, I could then use the points_array items as multiplier against duration number as follows:
var duration = 5;
var timeline = new TimelineMax();
for(var i = 0;i<point.array.length;i++){
   timeline.add(TweenLite.to(t, (duration * point_array[i]), {alpha:0});




Does this capability already exist, or is there a way to do this?



Link to comment
Share on other sites

Each Ease has a getRatio() method


So to generate your durations you could do something like this:



var ease = Strong.easeOut;

for(var i = 1; i <= 10; i++){
  $("body").append(ease.getRatio(i/10) + "<br>");



which would output


See the Pen a186c5a09d9fb4c5784c05e14cbecd02 by GreenSock (@GreenSock) on CodePen


Also, not sure if its what you want, but you can tween the progress of a timeline with any type of ease  as illustrated in the first demo here: http://www.snorkl.tv/2011/03/tween-a-timelinelite-for-ultimate-sequencing-control-and-flexibillity/


Although that is an older Flash example, the concept still applies to JavaScript.

  • Like 3
Link to comment
Share on other sites

This is exactly what I was looking for! 


Thanks Carl!

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