atulraj89 Posted August 6, 2020 Share Posted August 6, 2020 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 More sharing options...
ZachSaucier Posted August 6, 2020 Share Posted August 6, 2020 Hey Atul. If you console.log(activeSlide) after line 108 you can get the index of the currently active item. Is that what you are wanting? 1 Link to comment Share on other sites More sharing options...
atulraj89 Posted August 7, 2020 Author Share Posted August 7, 2020 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 More sharing options...
ZachSaucier Posted August 7, 2020 Share Posted August 7, 2020 8 hours ago, atulraj89 said: I want to know is there any GSAP way to do this, or I need to add it manually by JS like this. It's easiest to use the .classList functionality of JS. 2 Link to comment Share on other sites More sharing options...
atulraj89 Posted August 7, 2020 Author Share Posted August 7, 2020 Thanks @ZachSaucier, I did the same way, Thanks again 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