Created
May 27, 2019 12:37
-
-
Save kisildev/106289e54fdc292ec5bcc8eaaff220f5 to your computer and use it in GitHub Desktop.
Slick slider on mobile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(window).on('load resize orientationchange', function() { | |
$('.center-slide').each(function(){ | |
var $center_slide = $(this); | |
/* Initializes a slick center_slide only on mobile screens */ | |
// slick on mobile | |
if ($(window).width() >= 1025) { | |
if ($center_slide.hasClass('slick-initialized')) { | |
$center_slide.slick('unslick'); | |
} | |
} | |
else{ | |
if (!$center_slide.hasClass('slick-initialized')) { | |
$center_slide.slick({ | |
slidesToShow: 1, | |
slidesToScroll: 1, | |
arrows: false, | |
centerMode: true, | |
centerPadding: '60px', | |
infinite: false, | |
mobileFirst: true, | |
responsive: [ | |
{ | |
breakpoint: 640, | |
settings: { | |
slidesToShow: 2, | |
centerMode: false, | |
centerPadding: '0px', | |
infinite: false, | |
arrows: false, | |
} | |
}] | |
}); | |
} | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment