From c11172a50ae67d79a625ad35c9460feceff478c6 Mon Sep 17 00:00:00 2001 From: AzA-95 <52655410+AzA-95@users.noreply.github.com> Date: Mon, 26 Aug 2024 22:30:56 +0500 Subject: [PATCH] fix: centeredSlides with centeredSlidesBounds don't work correct when slidesPerView: 'auto' and width of the swiper-container bigger then width of slides (#7696) --- src/core/update/updateSlides.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/update/updateSlides.mjs b/src/core/update/updateSlides.mjs index fc6a76d89..6cbc8b483 100644 --- a/src/core/update/updateSlides.mjs +++ b/src/core/update/updateSlides.mjs @@ -255,7 +255,7 @@ export default function updateSlides() { allSlidesSize += slideSizeValue + (spaceBetween || 0); }); allSlidesSize -= spaceBetween; - const maxSnap = allSlidesSize - swiperSize; + const maxSnap = allSlidesSize > swiperSize ? allSlidesSize - swiperSize : 0; snapGrid = snapGrid.map((snap) => { if (snap <= 0) return -offsetBefore; if (snap > maxSnap) return maxSnap + offsetAfter;