Jump to content
Search Community

Recursive callback onComplete - play random timelines at the end of each other

dghez test
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

Hi everyone!

I'm currently trying to create a function that plays a timeline, add to that a callback function that play another random timeline, with a callback to another etc.. (something like a recursion)

In example: In have some timelines (7/8) and I want to play them one after one completely random, endless. 
I really can't find any error, in my mind this can work but in real it doesn't. I works for the first one / two  iterations then it goes in a insanely loop

 

function playRoutes(){
  var randValue = Math.floor(Math.random() * (globeHandler.routes.length));
  var route = globeHandler.routes[randValue].timeline;
  route.timeline.eventCallback('onComplete', playRoutes);				
  route.timeline.play();
}
playRoutes();

 

 

Here is the console.log o the random value, as you can see is called very fast.

5a6b8eee98ce7_Schermata2018-01-26alle17_31_27.png.10d3be7df7cd53d3e3f53e4f686dfe65.png

 

 

Any idea?

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