gpt4 book ai didi

javascript - Slick - 滑动时不会滚动正确数量的幻灯片

转载 作者:行者123 更新时间:2023-11-29 23:29:11 25 4
gpt4 key购买 nike

我有一个光滑的 slider ,当我在上面滑动时,它不会滚动超过一张幻灯片。我认为代码是正确的,但我不明白为什么它不能按我的意愿一次滚动 7 张幻灯片。也许我没有看到明显的东西......

HTML

<div class="slideshow-wrapper">
<div class="preloader"></div>
<div class="homeslick">
<div><img src="https://via.placeholder.com/150x150"></div>
<div><img src="https://via.placeholder.com/150x150"></div>
<div><img src="https://via.placeholder.com/150x150"></div>
<div><img src="https://via.placeholder.com/150x150"></div>
<div><img src="https://via.placeholder.com/150x150"></div>
<div><img src="https://via.placeholder.com/150x150"></div>
<div><img src="https://via.placeholder.com/150x150"></div>
<div><img src="https://via.placeholder.com/150x150"></div>
<div><img src="https://via.placeholder.com/150x150"></div>
<div><img src="https://via.placeholder.com/150x150"></div>
</div>
</div>

JS

$(document).ready(function(){
$('.homeslick').slick({
infinite: true,
centerMode: true,
centerPadding: '60px',
slidesToShow: 7,
slidesToScroll: 7,
autoplay: true,
autoplaySpeed: 2000,
responsive: [
{
breakpoint: 768,
settings: {
arrows: false,
centerMode: true,
centerPadding: '40px',
slidesToScroll: 7,
slidesToShow: 7
}
},
{
breakpoint: 480,
settings: {
arrows: false,
centerMode: true,
centerPadding: '40px',
slidesToScroll: 3,
slidesToShow: 3
}
}
]
});
});

最佳答案

只需添加 swipeToSlide: true 属性即可。

swipeToSlide - 允许用户直接拖动或滑动到幻灯片,而不管 slidesToScroll。

Type: boolean
Default: false

Documentations Link

关于javascript - Slick - 滑动时不会滚动正确数量的幻灯片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47941083/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com