Jump to content
Search Community

getting the index?

mimeartist test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

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

  • Solution

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. 

  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...