Lark Posted December 7, 2021 Share Posted December 7, 2021 In the codepen, the spinning box should swap colors every iteration. I used `onComplete` to call a function that moves the color index further, and the tween should take the current index color from the array at the top. This... well... doesn't work as I expect it to, but I couldn't quite find a way to do this. Checking the colorIndex in the console after every spin shows that it doesn, in fact, change. But the Tween doesn't pick up the new value on the next spin. I wonder why, and I also wonder what the correct way is to do this. EDIT: I solved it myself by making background into a function, figuring that unlike the value, the function would be called every time. However, this doesn't seem right, and I'd still like to know if there's a better way to do this! See the Pen zYEqNRm by LarkRanger (@LarkRanger) on CodePen Link to comment Share on other sites More sharing options...
Cassie Posted December 7, 2021 Share Posted December 7, 2021 Looks ok to me! If I was nitpicking it might be a good use for gsap.utils.wrap() ? See the Pen KKXzWmr?editors=0010 by GreenSock (@GreenSock) on CodePen https://greensock.com/docs/v3/GSAP/UtilityMethods/wrap() 1 Link to comment Share on other sites More sharing options...
Lark Posted December 7, 2021 Author Share Posted December 7, 2021 Well it still calls a function every single time, but it does look like it fits here. Thanks though Cassie, you've been very helpful the past few days! 1 Link to comment Share on other sites More sharing options...
Cassie Posted December 7, 2021 Share Posted December 7, 2021 My pleasure mate! Happy to help. 🥳 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