Rebeca Posted April 9, 2021 Share Posted April 9, 2021 I need to randomize the colors to each .box. I tried utils.wrap but it places them in an order, and with "random" they all get painted a color and the color changes when updating .... What can I do? I've been with gsap for two weeks and I'm a bit dizzy with so much information See the Pen dyNJOrj by rebecakarenok (@rebecakarenok) on CodePen Link to comment Share on other sites More sharing options...
Solution OSUblake Posted April 9, 2021 Solution Share Posted April 9, 2021 You just need it to return a function so it gets called for every element. Notice the true at the end. gsap.set('.box', { backgroundColor: gsap.utils.random(['#efecca', '#a9cbb7', '#f7ff58', '#ff934f', '#5e565a'], true), }) 1 Link to comment Share on other sites More sharing options...
OSUblake Posted April 9, 2021 Share Posted April 9, 2021 Forgot you can also do everything as a string. gsap.set('.box', { backgroundColor: "random(['#efecca', '#a9cbb7', '#f7ff58', '#ff934f', '#5e565a'])", }) Link to comment Share on other sites More sharing options...
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