Hi everyone
I’ve successfully added the Swiper JS Library and CSS to our theme (Narrative).
It’s currently sat in in the assets folder as swiper-bundle.min.js and swiper-bundle.min.css
I’ve been attempting to initialise it but due to the lack of ability to do anything like
import Swiper from 'swiper-bundle.min.js'
or
var swiper = require('swiper-bundle.min.js')
I don’t know how I’ll be able to get my initializing custom.js to run this code.
const swiper = new Swiper('.swiper', {
loop: true,
observer: true,
autoplay: {
delay: 5000,
},
direction: 'horizontal',
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
scrollbar: {
el: '.swiper-scrollbar',
},
slidesPerView: 1,
spaceBetween: 10,
breakpoints: {
320: {
slidesPerView: 2,
spaceBetween: 20
},
480: {
slidesPerView: 3,
spaceBetween: 30
},
640: {
slidesPerView: 4,
spaceBetween: 40
}
}
});
Any ideas about how to do this on Shopify would be welcome.
Thanks!