Skip to content

Commit

Permalink
fix(virtual): don't render first slides when initialSlide set
Browse files Browse the repository at this point in the history
fixes #7353
  • Loading branch information
nolimits4web committed Mar 28, 2024
1 parent e853908 commit bab9230
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/modules/virtual/virtual.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,17 @@ export default function Virtual({ swiper, extendParams, on, emit }) {
return slideEl;
}

function update(force) {
const { slidesPerView, slidesPerGroup, centeredSlides, loop: isLoop } = swiper.params;
function update(force, beforeInit) {
const {
slidesPerView,
slidesPerGroup,
centeredSlides,
loop: isLoop,
initialSlide,
} = swiper.params;
if (beforeInit && !isLoop && initialSlide > 0) {
return;
}
const { addSlidesBefore, addSlidesAfter } = swiper.params.virtual;
const {
from: previousFrom,
Expand Down Expand Up @@ -337,7 +346,7 @@ export default function Virtual({ swiper, extendParams, on, emit }) {
swiper.params.watchSlidesProgress = true;
swiper.originalParams.watchSlidesProgress = true;

update();
update(false, true);
});
on('setTranslate', () => {
if (!swiper.params.virtual.enabled) return;
Expand Down

0 comments on commit bab9230

Please sign in to comment.