nolimits4web / swiper

Most modern mobile touch slider with hardware accelerated transitions

Home Page:https://swiperjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Virtual + loop with amount of slides less or equal to 3 leads to rendering duplicates

artur-pipchenko opened this issue · comments

Check that this is really a bug

  • I confirm

Reproduction link

https://codesandbox.io/p/devbox/swiper-vue-virtual-slides-forked-v5kyft

Bug description

when we pass props :virtual="true" and :loop="true" with small amount of slides, we get duplicates due to the logic of creating an array of rendered elements. If this amount is less than or equal to 3, logic still tries to create an array of 4 elements, which leads to one element always be a duplicate. Hence we receive warning in console, and DOM tree starts to grow with each swipe

image

Expected Behavior

No duplicate warnings in console

Actual Behavior

Warning about duplicates when sliding left/right and continuosly growing list of DOM elements representing slides

Swiper version

11.1.3

Platform/Target and Browser Versions

Chrome 125.0.6422.77

Validations

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
  • Make sure this is a Swiper issue and not a framework-specific issue

Would you like to open a PR for this bug?

  • I'm willing to open a PR