Jump to content
Search Community

Stagger elements randomly

celli 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

I have a staggered effect with GSAP with a random rotationX property. The 'groups' render randomly with the random property each time I reload the page--but I am trying to get each piece to render randomly with different degrees of the rotationX property in the same animation. So, in effect each 'group' would be starting from a completely different randomX position, and they would all be flipping from different positions relative to each other.... How is this possible ?

See the Pen xGmddW by celli (@celli) on CodePen

  • Like 1
Link to comment
Share on other sites

The stagger methods were written to make it easy to animate multiple properties (to or from) the same values with offset start times.

If you want unique values for each tween, you will need to use a loop. Since you are using jQuery already, each() makes it pretty easy


//loop through each shape and create a tween with random values for each
shapes.each(function(index, element){
  tl.from(element, 0.9, {autoAlpha:0, scale:Math.random() * 2, rotationX:randomNumber(-80, 180),
                               transformOrigin:"bottom center"}, index * 0.02)


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