Skip to content

Commit

Permalink
fix(pagination): fixed issue in loop mode when sometimes it switches …
Browse files Browse the repository at this point in the history
…slides with transiton

fixes #6856
  • Loading branch information
nolimits4web committed Aug 9, 2023
1 parent fbb84fe commit 3d7dc58
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/modules/pagination/pagination.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ export default function Pagination({ swiper, extendParams, on, emit }) {
let bulletSize;
let dynamicBulletIndex = 0;

const makeElementsArray = el =>
(Array.isArray(el) ? el : [el]).filter((e) => !!e)
const makeElementsArray = (el) => (Array.isArray(el) ? el : [el]).filter((e) => !!e);

function isPaginationDisabled() {
return (
Expand Down Expand Up @@ -77,14 +76,20 @@ export default function Pagination({ swiper, extendParams, on, emit }) {
const index = elementIndex(bulletEl) * swiper.params.slidesPerGroup;
if (swiper.params.loop) {
if (swiper.realIndex === index) return;
const realIndex = swiper.realIndex;
const newSlideIndex = swiper.getSlideIndexByData(index);
const currentSlideIndex = swiper.getSlideIndexByData(swiper.realIndex);
if (newSlideIndex > swiper.slides.length - swiper.loopedSlides) {
const indexBeforeLoopFix = swiper.activeIndex;
swiper.loopFix({
direction: newSlideIndex > currentSlideIndex ? 'next' : 'prev',
activeSlideIndex: newSlideIndex,
slideTo: false,
});
const indexAfterFix = swiper.activeIndex;
if (indexBeforeLoopFix === indexAfterFix) {
swiper.slideToLoop(realIndex, 0, false, true);
}
}

swiper.slideToLoop(index);
Expand Down

0 comments on commit 3d7dc58

Please sign in to comment.