Jump to content
Search Community

Slider with index (linking animations)

popland test
Moderator Tag

Recommended Posts

based on a sample i got here on the forum i come up with an infinite slider, now my goal is to have a sort of index below it that indicates the slide i'm in

so that the the index grow and shrink (at the moment is static with the first active) based on the slide, and also clicking the index will move to the correct slide

 

basically i need to know which slide number i'm in (so i know which is next slider too) and trigger a shrink animation on the current index and grow animation to the next index synced with the slide movement, hoping my explaination make sense!

 

any help will be appreciated

See the Pen XWNRKbB by lenna-the-vuer (@lenna-the-vuer) on CodePen

Link to comment
Share on other sites

You just need to create a wrapping function for the indexes like this (place it somewhere near but after your slides variable):

const wrap = gsap.utils.wrap(0, slides.length);

Then inside the animateSlides function you'll need to call it like so:

const index = wrap(-x / slideWidth);
console.log(index);

 

  • Like 2
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...