momo12 Posted November 30, 2022 Share Posted November 30, 2022 Hello guys, A question. I'm trying to store the even and odd columns with the help of two values (evenRows and oddRows) but it's not working. Can someone please shed light on what I'm doing wrong? See the Pen oNyMJQQ by emdesigner-or (@emdesigner-or) on CodePen Link to comment Share on other sites More sharing options...
GreenSock Posted November 30, 2022 Share Posted November 30, 2022 @momo12 I spent a bunch of time writing a custom helper function for you in the other thread you created about this same topic - did you see that?: Your demo code has several problems: You are only checking to see if each iteration through the loop is odd or even, but that has [almost] nothing to do with how those elements are actually being displayed in the grid. Y You're looping through the elements that serve as the column containers, not the boxes themselves. You're treating columns as if they're rows You're setting a singular variable every time through the loop. So at the end, you'll just have one element rather than an Array of elements. It looks like you're trying to treat a variable name as a string and feeding it into a tween which will be treated as selector text. In other words, gsap.set("evenColumns", ...) is like telling GSAP to animate the elements document.querySelectorAll("evenColumns") (literally <evenColumns> HTML tags) None of this is related to GSAP - it's all plain JavaScript and logic issues. I'd strongly recommend that you just use the helper function I made for you. See the Pen BaVOOjv?editors=1010 by GreenSock (@GreenSock) on CodePen 1 Link to comment Share on other sites More sharing options...
momo12 Posted November 30, 2022 Author Share Posted November 30, 2022 Just now, GreenSock said: " 1 minute ago, GreenSock said: @momo12 I spent a bunch of time writing a custom helper function for you in the other thread you created about this same topic - did you see that?: Your demo code has several problems: You are only checking to see if each iteration through the loop is odd or even, but that has [almost] nothing to do with how those elements are actually being displayed in the grid. Y You're looping through the elements that serve as the column containers, not the boxes themselves. You're treating columns as if they're rows You're setting a singular variable every time through the loop. So at the end, you'll just have one element rather than an Array of elements. It looks like you're trying to treat a variable name as a string and feeding it into a tween which will be treated as selector text. In other words, gsap.set("evenColumns", ...) is like telling GSAP to animate the elements document.querySelectorAll("evenColumns") (literally <evenColumns> HTML tags) None of this is related to GSAP - it's all plain JavaScript and logic issues. I'd strongly recommend that you just use the helper function I made for you. Thanks for sharing this. I know. I'm just trying to learn more with different solutions to learn better GSAP. 1 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