pm1122dev의 비밀노트

swiperjs 특정 수 이상에서 동작하도록 작업 본문

javascript&jquery

swiperjs 특정 수 이상에서 동작하도록 작업

pm1122Dev 2021. 1. 23. 14:03
728x90
반응형
<script>
    $(function(){

        let options = {};
        if ( $(".swiper-container .swiper-slide").length == 1 ) {
            options = {
                slidesPerView: 1,
                centeredSlides: true,
                spaceBetween: 0,
                grabCursor: true,
                pagination: {
                    el: '.ticket_pagination',
                    clickable: true,
                },
                loop:true,
                autoplay: {
                    delay: 135000,
                },
            }
        } else {
            options = {
                loop: false,
                autoplay: false,
                pagination: {
                    el: '.ticket_pagination',
                    clickable: true,
                },
            }
        }
        var swiper = new Swiper('.myticket_slider', options);
    })
</script>
728x90
반응형
Comments