Last active
February 28, 2023 20:53
-
-
Save 2thecrow/a9677d90c9d2adf46d1c7c70e5a40ea7 to your computer and use it in GitHub Desktop.
SwiperJS launch with check
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
const nameOfConst = document.querySelector('.swiper-class'); | |
if (nameOfConst) { | |
let someName = new Swiper(nameOfConst, { | |
// Optional parameters | |
slidesPerView: 1, | |
loop: true, | |
// If we need pagination | |
pagination: { | |
el: '.swiper-pagination', | |
}, | |
// Navigation arrows | |
navigation: { | |
nextEl: '.swiper-button-next', | |
prevEl: '.swiper-button-prev', | |
}, | |
// And if we need scrollbar | |
scrollbar: { | |
el: '.swiper-scrollbar', | |
}, | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment