Forked from matthacksteiner/swiper multiple instances - vanilla JS
Created
March 16, 2023 04:46
-
-
Save Ibochkarev/2e1367d3a88db34069eb6d2f87c66988 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Swiper from "swiper/bundle"; | |
import "swiper/swiper-bundle.css"; | |
window.addEventListener( | |
"load", | |
() => { | |
// swiper | |
var slider = document.querySelectorAll(".swiper-container"); | |
for (let index = 0; index < slider.length; index++) { | |
slider[index].classList.add("swiper-container-" + index); | |
var mySwiper = new Swiper(".swiper-container-" + index, { | |
slidesPerView: 2, | |
centeredSlides: true, | |
spaceBetween: 5, | |
initialSlide: 2, | |
}); | |
} | |
}, | |
false | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment