mimeartist Posted July 10, 2023 Share Posted July 10, 2023 Having a bit of a brain melt with this having not done any gsap for a while... i'm trying to see when each tween in a loop of stuff starts by returning it's index, or even just it's ID, so I can then get various values from it... I'm actually using splitText, but this is a very simple version of what I'm trying to achieve... how do I get the index of the for loop when each tween starts? Thank you!! See the Pen yLQPxJg by mimeArtist (@mimeArtist) on CodePen Link to comment Share on other sites More sharing options...
GreenSock Posted July 10, 2023 Share Posted July 10, 2023 Are you trying to do this?: See the Pen VwVrGQN?editors=1010 by GreenSock (@GreenSock) on CodePen 1 Link to comment Share on other sites More sharing options...
mimeartist Posted July 10, 2023 Author Share Posted July 10, 2023 thank you, that works. Is there no other way of parsing a value using my for loop, as I may not want to use stagger as I'm going to be using it for things that also aren't splitText etc? Link to comment Share on other sites More sharing options...
Solution GreenSock Posted July 10, 2023 Solution Share Posted July 10, 2023 There are plenty of ways to do it, sure. I just think it's clunky to use a for loop like that because you lose clean access to the index since it iterates every time through the loop. See the Pen yLQPRXx?editors=0010 by GreenSock (@GreenSock) on CodePen The way I coded it in the first response doesn't require any stagger at all - I was just giving you that option if you wanted it. If I were you, I'd certainly be doing the .forEach() like I showed in the first reply. 1 Link to comment Share on other sites More sharing options...
mimeartist Posted July 10, 2023 Author Share Posted July 10, 2023 Thanks Jack, clunky is my middle name - I'll use the targets for now, but agree I should be seeking out more elegant ways 👍 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