kenwheeler / slick

the last carousel you'll ever need
kenwheeler.github.io/slick
MIT License
28.34k stars 5.88k forks source link

When using initialSlide param, slides which are less than slidesToShow param are inaccessible #4074

Open PrinceOfAbyss opened 3 years ago

PrinceOfAbyss commented 3 years ago

I'm using Slick slider to present and choose among dates. Those date slides are URLs, so I had to use initialSlide setting to calculate the "landing" slide when a new page loads that has a date param in its querystring (on the server I use a custom data tag to write a data-initial value, which I then read through jQuery in the browser to set the initialSlide param). The problem is that when you select a date where initialSlide < slidesToShow, all previous slides are inaccessible.

I created a smal Codepen to see this in action.

In the Codepen, notice the data-initial="today" at line 146 of the HTML pane, that's for the date January 25. The dates start at January 1, but those dates are not accessible. To fix that (with the bug in effect), you either have to put the "today" for the data-initial param of January 26 date, or change the slidesToShow in the JS to ie. 24. Basically whatever works as long as initialSlide > slidesToShow

The Codepen link is https://codepen.io/PrinceOfAbyss/pen/ExNqLjr