Skip to content

Commit

Permalink
fix(pagination): fix dynamic bullets position with loop enabled
Browse files Browse the repository at this point in the history
fixes #5304
  • Loading branch information
nolimits4web committed Dec 24, 2021
1 parent 8eeeb45 commit 3d377c2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/modules/pagination/pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ export default function Pagination({ swiper, extendParams, on, emit }) {
`${bulletSize * (params.dynamicMainBullets + 4)}px`,
);
if (params.dynamicMainBullets > 1 && swiper.previousIndex !== undefined) {
dynamicBulletIndex += current - swiper.previousIndex;
dynamicBulletIndex += current - (swiper.previousIndex - swiper.loopedSlides || 0);
if (dynamicBulletIndex > params.dynamicMainBullets - 1) {
dynamicBulletIndex = params.dynamicMainBullets - 1;
} else if (dynamicBulletIndex < 0) {
dynamicBulletIndex = 0;
}
}
firstIndex = current - dynamicBulletIndex;
firstIndex = Math.max(current - dynamicBulletIndex, 0);
lastIndex = firstIndex + (Math.min(bullets.length, params.dynamicMainBullets) - 1);
midIndex = (lastIndex + firstIndex) / 2;
}
Expand Down Expand Up @@ -153,7 +153,7 @@ export default function Pagination({ swiper, extendParams, on, emit }) {
bullets.eq(i).addClass(`${params.bulletActiveClass}-main`);
}
if (swiper.params.loop) {
if (bulletIndex >= bullets.length - params.dynamicMainBullets) {
if (bulletIndex >= bullets.length) {
for (let i = params.dynamicMainBullets; i >= 0; i -= 1) {
bullets.eq(bullets.length - i).addClass(`${params.bulletActiveClass}-main`);
}
Expand Down

0 comments on commit 3d377c2

Please sign in to comment.