-
-
Save Korveld/69146301129e588fdfe4cd8ca4068090 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
var slick_slider = $('.latest-topics') | |
var settings_slider = { | |
infinite: false, | |
autoplay: false, | |
dots: false, | |
arrows: false, | |
slidesToShow: 1, | |
slidesToScroll: 1, | |
cssEase: 'ease', | |
speed: 300, | |
variableWidth: true, | |
} | |
var slickOnMobile = function(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) | |
} | |
}) | |
} | |
slickOnMobile(slick_slider, settings_slider) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment