Skip to content

Instantly share code, notes, and snippets.

@2thecrow
Last active February 28, 2023 20:53
Show Gist options
  • Save 2thecrow/a9677d90c9d2adf46d1c7c70e5a40ea7 to your computer and use it in GitHub Desktop.
Save 2thecrow/a9677d90c9d2adf46d1c7c70e5a40ea7 to your computer and use it in GitHub Desktop.
SwiperJS launch with check
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