Skip to content

Commit

Permalink
fix: fixed behavior where the combination of 'initialSlide:0' and 'sl…
Browse files Browse the repository at this point in the history
…idesPerView: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 <[email protected]>
  • Loading branch information
yasuhiro-yamamoto and nolimits4web authored Feb 5, 2024
1 parent 661266c commit e5c04c3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/core.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit e5c04c3

Please sign in to comment.