Jump to content
GreenSock

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

Stagger Animation Question

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 guys, I am wondering is there is a way to create a stagger animation with random stagging time, using the stagger methods.

 

Thanks in advance...

Link to comment
Share on other sites

Hello @asilverio and welcome to the GreenSock Forum!

 

You can do this with the GSAP ModifiersPlugin.

 

Below shows a staggerTo() tween with random end values for CSS x (translateX) property, but could be done with any property:

 

See the Pen zdxZZb by jonathan (@jonathan) on CodePen

 

Please see the following blog and docs page on function based values:

 

ModifiersPlugin Docs: https://greensock.com/docs/Plugins/ModifiersPlugin
Whats new in GSAP 1.19.0: https://greensock.com/1-19-0/

 

Happy Tweening :)

 

  • Like 3
Link to comment
Share on other sites

Yup, Jonathan is right that you can use function-based values for any of the end values of the tweens. 

You can't really mess with the stagger amount, but you can use cycle to change the delay of each tween like this:

 

TweenMax.staggerTo(".box", 1, {
  x: 200,
  cycle:{
    delay:function() {
      return Math.random() * 3
    }
  }
});

 

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

 

You can learn more about cycle in any of the docs for the stagger methods: https://greensock.com/docs/TweenMax/static.staggerTo()

 

Watch:

 

https://youtu.be/0HhjSPVuRHA

  • Like 4
Link to comment
Share on other sites

Hi there, thanks for the quick responses guys I really appreciate it, I will try those approaches, anything that comes up I will let you know...  

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