You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The active slide is calculated wrongly when using virtual slides. This happens only for slides in the low digits slide indexes and depends on e.g. the values of addSlidesAfter and addSlidesBefore.
From my analysis, this is where it goes wrong (in the instance of the virtual main swiper). See comment after // >>>.
functionupdateActiveIndex(newActiveIndex){// ... snip ...// Get real indexletrealIndex;if(swiper.virtual&¶ms.virtual.enabled&¶ms.loop){realIndex=getVirtualRealIndex(activeIndex);}elseif(gridEnabled){constfirstSlideInColumn=swiper.slides.find(slideEl=>slideEl.column===activeIndex);letactiveSlideIndex=parseInt(firstSlideInColumn.getAttribute('data-swiper-slide-index'),10);if(Number.isNaN(activeSlideIndex)){activeSlideIndex=Math.max(swiper.slides.indexOf(firstSlideInColumn),0);}realIndex=Math.floor(activeSlideIndex/params.grid.rows);}elseif(swiper.slides[activeIndex]){// >>> activeIndex is from the virtual index, but swiper.slides[] just contains // `addSlidesAfter` + 1 + `addSlidesBefore` slides. If activeIndex is quite// low, then it enters this branch, and retrieves a wrong index from the// attribute in the next line.constslideIndex=swiper.slides[activeIndex].getAttribute('data-swiper-slide-index');if(slideIndex){realIndex=parseInt(slideIndex,10);}else{realIndex=activeIndex;}}else{realIndex=activeIndex;}// ... snip ...}
These issues could have the same root cause, but I'm not sure: #7918#7669#7377
Expected Behavior
Thumbs are synced with the main swiper correctly.
Actual Behavior
The wrong thumb is highlighted when using the paginators while going through the slides. There are similar effects when clicking on the thumbs itself. Depending on the screen size and thumb widths, the thumb swiper scrolls to the wrong thumb.
Check that this is really a bug
Reproduction link
https://codesandbox.io/p/sandbox/bug-repro-virtual-slides-thumbs-forked-287y2w
Bug description
The active slide is calculated wrongly when using virtual slides. This happens only for slides in the low digits slide indexes and depends on e.g. the values of
addSlidesAfter
andaddSlidesBefore
.From my analysis, this is where it goes wrong (in the instance of the virtual main swiper). See comment after
// >>>
.These issues could have the same root cause, but I'm not sure: #7918 #7669 #7377
Expected Behavior
Thumbs are synced with the main swiper correctly.
Actual Behavior
The wrong thumb is highlighted when using the paginators while going through the slides. There are similar effects when clicking on the thumbs itself. Depending on the screen size and thumb widths, the thumb swiper scrolls to the wrong thumb.
Swiper version
11.2.6
Platform/Target and Browser Versions
Firefox, Chrome
Validations
Would you like to open a PR for this bug?
The text was updated successfully, but these errors were encountered: