Skip to content

Instantly share code, notes, and snippets.

@thinhbg59
Forked from ndunk28/slick-on-mobile.js
Created February 5, 2018 08:55
Show Gist options
  • Save thinhbg59/c2b837b77300e15d567b125912074f4d to your computer and use it in GitHub Desktop.
Save thinhbg59/c2b837b77300e15d567b125912074f4d to your computer and use it in GitHub Desktop.
slick js only on mobile
// slider
$slick_slider = $('.slider');
settings_slider = {
dots: false,
arrows: false
// more settings
}
slick_on_mobile( $slick_slider, settings_slider);
// slick on mobile
function slick_on_mobile(slider, settings){
$(window).on('load resize', function() {
if ($(window).width() > 767) {
if (slider.hasClass('slick-initialized')) {
slider.slick('unslick');
}
return
}
if (!slider.hasClass('slick-initialized')) {
return slider.slick(settings);
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment