From e5c04c38e4261f4afb195bc15ea7417e7c1190dd Mon Sep 17 00:00:00 2001 From: yasuhiro-yamamoto Date: Mon, 5 Feb 2024 17:39:44 +0900 Subject: [PATCH] fix: fixed behavior where the combination of 'initialSlide:0' and 'slidesPerView:auto' would shift the first slide position * fix: initialSlide #7216 Fixed behavior where the combination of 'initialSlide:0' and 'slidesPerView:auto' would shift the first slide position * remove debug --------- Co-authored-by: Vladimir Kharlampidi --- src/core/core.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/core.mjs b/src/core/core.mjs index 939636f57..20fa4903c 100644 --- a/src/core/core.mjs +++ b/src/core/core.mjs @@ -343,11 +343,11 @@ class Swiper { if (typeof params.slidesPerView === 'number') return params.slidesPerView; if (params.centeredSlides) { - let slideSize = slides[activeIndex] ? slides[activeIndex].swiperSlideSize : 0; + let slideSize = slides[activeIndex] ? Math.ceil(slides[activeIndex].swiperSlideSize) : 0; let breakLoop; for (let i = activeIndex + 1; i < slides.length; i += 1) { if (slides[i] && !breakLoop) { - slideSize += slides[i].swiperSlideSize; + slideSize += Math.ceil(slides[i].swiperSlideSize); spv += 1; if (slideSize > swiperSize) breakLoop = true; }