Jump to content
Search Community

Using gsaps new random feature

sirhclluk test
Moderator Tag

Recommended Posts

Hey sirhclluk and welcome. 

 

It seems that you need to include the unit if you're going to use the string form:

x:"random(['0px', '100px', '200px', '500px'])"

 

I find it more intuitive to use the utils version:

gsap.utils.random([0, 100, 200, 500])

 

You could pair it with repeatRefresh for a different random value each time if you'd like:

gsap.timeline({repeat:-1, yoyo:true, repeatRefresh:true})
.to(circ_1, {x:gsap.utils.random([0, 100, 200, 500], true), ...})

 

  • Like 1
Link to comment
Share on other sites

There was indeed a minor bug in GSAP that affected string-based "random()" values when the Array form was used, like "random([-100, 20, 80])". That'll be resolved in the next release which you can preview at https://assets.codepen.io/16327/gsap-latest-beta.min.js

 

Of course as @ZachSaucier mentioned, you can just use the regular gsap.utils.random() method directly instead in the meantime. 👍

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