-
-
Save VelichkoAlexander/791625ba59eb22c8bd4df55c4f0889c3 to your computer and use it in GitHub Desktop.
slick js only 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
// 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