Swiper - loop warning demo
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/Swiper/14.2.0/swiper-bundle.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/14.2.0/swiper-bundle.min.css" integrity="sha512-o7Knr4VAyVWuQ+zWMXH8bbv8zhp2EAQQKSMTiM7S6KjoK5MXagmNbVhUdmojS94zr3cCIERxQyEOoqSdSk2bLA==" crossorigin="anonymous" referrerpolicy="no-referrer">
<div class="swiper">
<div class="swiper-wrapper">
<div class="swiper-slide">
<h2>first slide</h2>
<p>When all items are visible, I would like the slider to disable itself. The current behavior already works like this; the only difference is that the order does not change back to the original order.</p>
</div>
<div class="swiper-slide">
<h2>second slide</h2>
<p>When on smaller screens than the breakpoint I set, the slider should be active and should loop. Also working.</p>
</div>
<div class="swiper-slide">
<h2>third slide</h2>
<p>This slider works almost exactly as intended, but I get warnings in the console each time the breakpoint triggers slidesPerView: 3.</p>
</div>
</div>
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
</div>
<p>The only difference between current functionality and my expected functionality is that after swiping around on small screens, the slides don't rearrange back to normal after resizing the window to a larger width again. This is a low priority and I'm not sure it constitutes an issue.</p>
CSS
body {
font-family: sans-serif;
}
.swiper {
border: 1px solid #d57;
text-align: center;
margin: 50px;
width: 90vw;
max-width: 1200px;
}
JavaScript
new Swiper('.swiper', {
modules: 'Navigation',
slidesPerView: 1,
spaceBetween: 50,
loop: true,
watchOverflow: true,
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev'
},
breakpoints: {
700: {
slidesPerView: 3
}
},
breakpointsBase: 'container'
})