yujiokayama
5/15/2018 - 6:42 AM

slickslideでデバイスサイズごとに挙動を変更する

            $(function () {

                $slick_slider = $('.center');
                settings = {
                    arrows: false,
                    centerMode: true,
                    centerPadding: '40px',
                    initialSlide: 1,
                    infinite: false,
                    slidesToShow: 1
                }
                $slick_slider.slick(settings);
                $(window).on('resize load', function () {
                    if ($(window).width() > 767) {
                        if ($slick_slider.hasClass('slick-initialized')) {
                            $slick_slider.slick('unslick');
                        }
                        return
                    }
                    if (!$slick_slider.hasClass('slick-initialized')) {
                        return $slick_slider.slick(settings);
                    }
                });
            });