Skip to content

Commit

Permalink
fix(virtual): fix bypassing initial translate check if Virtual is ena…
Browse files Browse the repository at this point in the history
…bled

fixes #7699
  • Loading branch information
nolimits4web committed Aug 28, 2024
1 parent f26036f commit df957bb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/core/slide/slideTo.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,14 @@ export default function slideTo(index = 0, speed, runCallbacks = true, internal,
else if (slideIndex < activeIndex) direction = 'prev';
else direction = 'reset';

// initial virtual
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
const isInitialVirtual = isVirtual && initial;
// Update Index
if ((rtl && -translate === swiper.translate) || (!rtl && translate === swiper.translate)) {
if (
!isInitialVirtual &&
((rtl && -translate === swiper.translate) || (!rtl && translate === swiper.translate))
) {
swiper.updateActiveIndex(slideIndex);
// Update Height
if (params.autoHeight) {
Expand All @@ -114,7 +120,6 @@ export default function slideTo(index = 0, speed, runCallbacks = true, internal,
const isH = swiper.isHorizontal();
const t = rtl ? translate : -translate;
if (speed === 0) {
const isVirtual = swiper.virtual && swiper.params.virtual.enabled;
if (isVirtual) {
swiper.wrapperEl.style.scrollSnapType = 'none';
swiper._immediateVirtual = true;
Expand Down

0 comments on commit df957bb

Please sign in to comment.