admin管理员组文章数量:1432001
I'm trying to enable Slick Slider (slick.js) to initiate only over 520px wide. Anything below that and the slides just stack (i.e. no slick). Is it possible so that it can work without refreshing the page?
I've done this, but it's really clunky:
$(document).ready(function () {
var $window = $(window),
$slick = $('.slick'),
toggleSlick;
toggleSlick = function () {
if ($window.width() > 520) {
$slick.slick();
} else {
$slick.unslick();
}
}
$window.resize(toggleSlick);
toggleSlick();
});
I also get a Uncaught TypeError: $slick.unslick is not a function
error in the console.
I'm using
I'm trying to enable Slick Slider (slick.js) to initiate only over 520px wide. Anything below that and the slides just stack (i.e. no slick). Is it possible so that it can work without refreshing the page?
I've done this, but it's really clunky:
$(document).ready(function () {
var $window = $(window),
$slick = $('.slick'),
toggleSlick;
toggleSlick = function () {
if ($window.width() > 520) {
$slick.slick();
} else {
$slick.unslick();
}
}
$window.resize(toggleSlick);
toggleSlick();
});
I also get a Uncaught TypeError: $slick.unslick is not a function
error in the console.
I'm using https://github./kenwheeler/slick
Share Improve this question asked Aug 17, 2015 at 14:36 Jack BarhamJack Barham 3,21912 gold badges45 silver badges64 bronze badges1 Answer
Reset to default 6I believe the way you call slick methods has changed.
Instead of $('.slick').unslick();
try $('.slick').slick("unslick");
You can also call this directly inside the responsive option in the slick options
版权声明:本文标题:javascript - I'm trying to enabledisable Slick Slider between a set window width (responsive) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745569506a2663961.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论