Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #6460 for margin-right #6475

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/core/slide/slideTo.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ export default function slideTo(
const skip = Math.min(swiper.params.slidesPerGroupSkip, slideIndex);
let snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup);
if (snapIndex >= snapGrid.length) snapIndex = snapGrid.length - 1;

const slidesPerView = swiper.passedParams.slidesPerView;
if (swiper.params.loop && slidesPerView > 1 && snapGrid.length < swiper.slides.length) {
while (swiper.slides.length > snapGrid.length) {
snapGrid.push(snapGrid[snapGrid.length - 1] + swiper.size / slidesPerView);
}
snapIndex = snapGrid.length;
}
const translate = -snapGrid[snapIndex];
// Normalize slideIndex
if (params.normalizeSlideIndex) {
Expand Down
4 changes: 4 additions & 0 deletions src/core/slide/slideToLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default function slideToLoop(
}

const swiper = this;
const slidesPerView = swiper.passedParams.slidesPerView;
let newIndex = index;
if (swiper.params.loop) {
if (swiper.virtual && swiper.params.virtual.enabled) {
Expand All @@ -24,6 +25,9 @@ export default function slideToLoop(
(slideEl) => slideEl.getAttribute('data-swiper-slide-index') * 1 === newIndex,
)[0],
);
if (slidesPerView > 1 && swiper.slides.length < newIndex + slidesPerView) {
setTimeout(() => swiper.loopFix({ direction: 'next' }), speed);
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/core/update/updateSlides.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ export default function updateSlides() {
// reset margins
slides.forEach((slideEl) => {
if (rtl) {
slideEl.style.marginLeft = '';
slideEl.style.marginLeft = '0';
} else {
slideEl.style.marginRight = '';
slideEl.style.marginRight = '0';
}
slideEl.style.marginBottom = '';
slideEl.style.marginTop = '';
slideEl.style.marginBottom = '0';
slideEl.style.marginTop = '0';
});

// reset cssMode offsets
Expand Down