Created
November 11, 2024 06:36
-
-
Save ramzs/f6a9c9f2b50ae35a4e3a2115f5c39744 to your computer and use it in GitHub Desktop.
Swiper loop index slide
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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