-
-
Save thinhbg59/c2b837b77300e15d567b125912074f4d to your computer and use it in GitHub Desktop.
slick js only on mobile
This file contains 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
// 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