Jump to content
Search Community

duration picked at random from array not working

antialias 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

Well, you've got an infinitely repeating TimelineMax, so the onComplete will never fire (since the timeline never ends). You can just use an onRepeat instead.

 

I assume you meant something like this, right?: 

var durations = [1.0, 3.5, 0.5, 4.75, 3.25, 1.333, 2.666, 4.125, 1.2];

var index = 3 ;

var mouth = new TimelineMax({repeat:-1 , onRepeat:
  function(){ 
    index = (Math.floor((Math.random()*durations.length)));
    console.log(durations[index]);
    mouth.duration(durations[index]);
    }
  });

mouth.from("#profile", (durations[index]), {clip:"rect(0px 100px 100px 100px)"});

 

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