Jump to content


Unable to use gsap.utils.random function to generate random timeline duration.

Go to solution Solved by GreenSock,

Recommended Posts

  • Solution

I noticed a few problems: 

  1. You were trying to set a duration on a timeline, but timelines are just wrappers for other tweens/timelines, so their duration is determined by their contents. 
  2. You were trying to make the interval between 1000 and 2000 seconds (a long time!) 
  3. Since you didn't populate the timeline with anything, it had no duration at all, thus onRepeat is pretty meaningless.

I assume you were looking for something more like this?: 

See the Pen YzvMZJX?editors=1010 by GreenSock (@GreenSock) on CodePen


Just so you know, gsap.utils.random() is magical in that you can give it an Array and it'll automatically return a random element from that Array, so you don't have to manage the index. 



  • Like 2
Link to comment
Share on other sites

* face palms *


They were left over from when I was using setInterval! Totally missed it... twice!

Cheers Jack, and thanks for the additional info.


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