웹 퍼블리싱/제이쿼리 플러그인

(Swiper) 해상도에 따라 스와이퍼 기능 없애기

꼬지비 2020. 12. 18. 13:13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
var Swiper = undefined;
    function initSwiper(){ 
        var screenWidth = $(window).width();
        if(screenWidth < 992 && secSwiper == undefined){
           secSwiper = new Swiper('.sec-swiper .swiper-container',{
                slidesPerView: 'auto',    
            });
        }else if(screenWidth > 991 && Swiper != undefined){
           Swiper.destroy();
           Swiper = undefined;
            $('.swiper-wrapper').removeAttr('style');
            $('.swiper-slide').removeAttr('style');
        }
    }
 
    initSwiper();
 
    $(window).on('resize'function(){
        initSwiper();
    });     
cs