Slick: "initialSlide" breaks slider if slide cannot be first slide to be shown

Created on 29 Sep 2017  路  4Comments  路  Source: kenwheeler/slick

The "initialSlide" functionality breaks the slider if

  • centerMode=false
  • and: infinite=false
  • and: slidesToShow > 1
  • and: initialSlide > numberOfSlides - slidesToShow

Then it will not be possible anymore to drag the slides (the slider immediately returns to its initial position) and "next" and "prev" links are not working either.

see:

Steps to reproduce the problem

  1. create a new slider
  2. add multiple slides
  3. configure the slider with centerMode, infinite, slidesToShow and initialSlide settings as described above

What is the expected behaviour?

  • the slide with "initialSlide" number should be visible
  • the slider should work as usual, allowing the user to navigate to other slides

What is the observed behaviour?

  • it is not possible to navigate to another slide, neither by drag nor by click on buttons

Most helpful comment

Don't use slick for your projects, is the workaround.

All 4 comments

I have the same problem. Maybe somebody have some workaround solution for it ?

Don't use slick for your projects, is the workaround.

You can handle the situation yourself, just ensure that you don't exceed the limit:

initialSlide = initialSlide > numberOfSlides - slidesToShow 
    ? numberOfSlides - slidesToShow 
    : initialSlide;

Ok, thanks. Already did something similar, but just used slickGoTo instead of initialSlide, like:

initialSlide = initialSlide > numberOfSlides - slidesToShow
    ?  initialSlide - (slidesToShow - 1) 
    : initialSlide
$('.slider).slick('slickGoTo', initialSlide, true );

and active slide visible and slider still works ok.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hoghamburg picture hoghamburg  路  3Comments

Luneya picture Luneya  路  3Comments

crstauf picture crstauf  路  3Comments

Libig picture Libig  路  3Comments

barzev picture barzev  路  3Comments