Skip to content

Instantly share code, notes, and snippets.

@ramzs
Created November 11, 2024 06:36
Show Gist options
  • Save ramzs/f6a9c9f2b50ae35a4e3a2115f5c39744 to your computer and use it in GitHub Desktop.
Save ramzs/f6a9c9f2b50ae35a4e3a2115f5c39744 to your computer and use it in GitHub Desktop.
Swiper loop index slide
function getSlideDataIndex(swipe) {
var activeIndex = swipe.activeIndex;
var slidesLen = swipe.slides.length;
if (swipe.params.loop) {
switch (swipe.activeIndex) {
case 0:
activeIndex = slidesLen - 3;
break;
case slidesLen - 1:
activeIndex = 0;
break;
default:
--activeIndex;
}
}
return activeIndex;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment