sirhclluk Posted July 22, 2020 Posted July 22, 2020 I can't get the random to work. Any help would be so awesome. Thank You See the Pen 7e062de5bfbf4331ef09f711f60ba25f by sirhclluk (@sirhclluk) on CodePen.
ZachSaucier Posted July 22, 2020 Posted July 22, 2020 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), ...}) 1
sirhclluk Posted July 22, 2020 Author Posted July 22, 2020 Thanks @ZachSaucier Yeah I didn't think about the repeat refresh. Even if mine did work, I'd never see the random change. Thank you
GreenSock Posted July 22, 2020 Posted July 22, 2020 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. ? 3
sirhclluk Posted July 22, 2020 Author Posted July 22, 2020 Thanks Jack. I look forward to that one. Great work! 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now