kenwheeler / slick

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

When total slides not in multiple of slidesToShow, clicking last dot doesn't go to last slider page #1088

Open analuisamartins opened 9 years ago

analuisamartins commented 9 years ago

Hi, I found this issue when scroll infinite = false, dots = true and total slides is not multiple of slidesToShow. (Ex: 10 slides, 4 per page) Click in last dot never triggers last page. After digging a little bit the code, I found that the problem may be in the method

Slick.prototype.getNavigableIndexes = function() {... 
I replaced the calculation of max by the following:
        if(_.options.infinite === false) {
            // max = _.slideCount - _.options.slidesToShow + 1;
            max = Math.ceil(_.slideCount / _.options.slidesToShow) * _.options.slidesToShow;

It seems to work fine now, but as I don't know very well the plugin, I don't know if is the right fix (can cause collateral bugs).

Great plugin btw ;)

shabith commented 9 years ago

yeah this did the trick for me as well. @analuisamartins thanks for sharing this. :+1:

marcinkrzeminski commented 9 years ago

Had the same problem. Thanks @analuisamartins for quick fix ;).

carasmo commented 9 years ago

When will this be corrected in the repository?

BTW: Thank you for the fix, it works like it did in 1.3.x

carasmo commented 9 years ago

Thank you for this slider too, didn't mean to sound ungrateful. Just spent hours trying figure out why it worked in 1.3 and not worked in 1.5, so slightly grumpy, but whatever :-)

star-szr commented 9 years ago

Thanks @analuisamartins, this was almost a show stopping issue on a project I'm working on. @kenwheeler would a PR help in moving this forward? JSFiddle/JSBin/etc. test case?

Edit: And yes, this slider/carousel is awesome! The responsive settings are fantastic :)

kenwheeler commented 9 years ago

All of the above would be helpful

star-szr commented 9 years ago

Okay, I'm on it.