Jump to content
Search Community

how to get index of a animated item in Timeline and addClass on elements based on that index

atulraj89 test
Moderator Tag

Recommended Posts

Hello Everyone,

in Timeline, I want to get the index of current animated item, How to do that?
for example when scrolling or dragging in this vertical slider, dots animating and animated dot has active class, I want to get the index of the animated dot, or you can say active dot and add the same active class on the sections, so they can relate and I can style the specific section.


note: This is vertical slider created by CRAIG, I just modified it as per my needs.

See the Pen ExPMoqj by atulraj89 (@atulraj89) on CodePen

Link to comment
Share on other sites

Hello @ZachSaucier,

Yes I have the index in active slide,
I should Edit the main questions headline, 
Actually I need to add class on the section (scroll-able section) with the current index of active slide, So I want to know is there any GSAP way to do this, or I need to add it manually by JS like this.
 

Quote

 for (i in slides) {
    slides.className = ""
    slides[activeSlide].className = "active"
  }



So what I am doing here, removing class active from all the slides and adding the class only on selected index and this is what I need. just want to know is this ok to do it like this or is there any GSAP way to do this?

I mentioned this in question body.

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...