Aitor Posted June 24, 2021 Share Posted June 24, 2021 Trying to change background color to different color for each loop iteration using onRepeat callback. It doesn't work. How can I acheve this? Thanks. let R, G, B, dur; const setVars = () => { R = Math.floor((Math.random() * 255)), G = Math.floor((Math.random() * 255)), B = Math.floor((Math.random() * 255)), dur = Math.floor((Math.random() * 4)); } const getColor = () => { setVars(); return `rgb(${R}, ${G}, ${B})`; }; setVars(); TweenMax.to(".colores", { duration: dur, backgroundColor: getColor, repeat: -1, onRepeat: getColor(), }); See the Pen RwpzzPJ by aitormendez (@aitormendez) on CodePen Link to comment Share on other sites More sharing options...
Solution OSUblake Posted June 24, 2021 Solution Share Posted June 24, 2021 Hi Aitor! It looks like you're using an old syntax. Please check our migration and getting started guides. See the Pen WNpqVNG by GreenSock (@GreenSock) on CodePen 4 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