Skip to content

Instantly share code, notes, and snippets.

@kisildev
Created May 27, 2019 12:37
Show Gist options
  • Save kisildev/106289e54fdc292ec5bcc8eaaff220f5 to your computer and use it in GitHub Desktop.
Save kisildev/106289e54fdc292ec5bcc8eaaff220f5 to your computer and use it in GitHub Desktop.
Slick slider on mobile
$(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