Need a way to get the accurate activeIndex in loop mode
See original GitHub issueI’m using Swiper for a user to set their ‘current active image’, and so hooking into the onSlideChangeEnd() callback.
As you know, when in loop mode, the activeIndex property is offset by the duplicated slides, although what I need is essentially the data-swiper-slide-index attribute of the currently selected slide. I can’t find a way to get the currently selected slide or it’s index.
I looked repeatedly for this value in the API, although I can’t find anything, it seems like it should be there somewhere. The only other way I can think to get this value, would be to query the DOM for the slide with the active class on it, and grab it’s data-swiper-slide-index value, although that’s a pretty messy way to get a simple value.
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
iDangero.us Swiper slide count when loop is true
activeIndex property and mySwiper.slides but the problem is that when loop is true they don't give correct index and count. Is there any...
Read more >swiper get active index | The AI Search Engine You Control
How do I get the previously active index of a slide using Swiper.js? ... nolimits4web/swiperNeed a way to get the accurate activeIndex in...
Read more >How to Fix iPhone That Is Stuck in Recovery Mode Loop (No ...
This is a short story about how a girl fixed her iPhone that is stuck in a Recovery Mode loop. Free Download for...
Read more >When class is toggled on `html` change Swiper JS settings
I have a Swiper JS instance which works as expected. ... loop (need to figure out how to do autoplay) and changing the...
Read more >Swiper API
Now, when we have Swiper's HTML, we need to initialize it using the following ... with loop mode you should tell to Swiper...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

in loop mode active index value will be always shifted on a number of looped/duplicated slides. you can get attribute ‘data-swiper-slide-index’ whit function like:
usage:
@phongmedia
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.