javascript - Slick - doesn't scroll the correct number of slide on swipe - Stack Overflow

I have a slick slider that doesn't scroll more than one slide when I swipe on it. I think the code

I have a slick slider that doesn't scroll more than one slide when I swipe on it. I think the code is right but I can't understand why it doesn't scroll 7 slide at time as I want. Maybe I'm not seeing something obvious...

HTML

<div class="slideshow-wrapper">
  <div class="preloader"></div>
  <div class="homeslick">
    <div><img src=""></div>
    <div><img src=""></div>
    <div><img src=""></div>
    <div><img src=""></div>
    <div><img src=""></div>
    <div><img src=""></div>
    <div><img src=""></div>
    <div><img src=""></div>
    <div><img src=""></div>
    <div><img src=""></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
        }
      }
    ]
  });
});

I have a slick slider that doesn't scroll more than one slide when I swipe on it. I think the code is right but I can't understand why it doesn't scroll 7 slide at time as I want. Maybe I'm not seeing something obvious...

HTML

<div class="slideshow-wrapper">
  <div class="preloader"></div>
  <div class="homeslick">
    <div><img src="https://via.placeholder./150x150"></div>
    <div><img src="https://via.placeholder./150x150"></div>
    <div><img src="https://via.placeholder./150x150"></div>
    <div><img src="https://via.placeholder./150x150"></div>
    <div><img src="https://via.placeholder./150x150"></div>
    <div><img src="https://via.placeholder./150x150"></div>
    <div><img src="https://via.placeholder./150x150"></div>
    <div><img src="https://via.placeholder./150x150"></div>
    <div><img src="https://via.placeholder./150x150"></div>
    <div><img src="https://via.placeholder./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
        }
      }
    ]
  });
});
Share Improve this question edited May 2, 2020 at 17:28 Richard Dallaway 4,3301 gold badge29 silver badges39 bronze badges asked Dec 22, 2017 at 11:52 DaFoisDaFois 2,2238 gold badges28 silver badges47 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

Just add the swipeToSlide: true property.

swipeToSlide - Allow users to drag or swipe directly to a slide irrespective of slidesToScroll.

Type: boolean
Default: false

Documentations Link

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744211018a4563331.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信