When using center mode and infinite false with variable width you get extra white space at first slide left side and last slide right side.
Here is the link for JSFiddle.
What I want is that first slide should start from left edge whereas last slide should end at right edge without any white spaces.
In case anyone come across this, here is the code I modified starting at line 1105 in slick.js :
if (_.options.centerMode === true && _.options.infinite === true) {
_.slideOffset += _.slideWidth * Math.floor(_.options.slidesToShow / 2) - _.slideWidth;
} else if (_.options.centerMode === true && _.options.infinite === false) {
if(slideIndex >1 && slideIndex < _.slideCount - 2 ) {
_.slideOffset = 0;
_.slideOffset += _.slideWidth * Math.floor(_.options.slidesToShow / 2);
} else if (slideIndex ===1) {
_.slideOffset = 0;
_.slideOffset += _.slideWidth;
}
} else if (_.options.centerMode === true) {
_.slideOffset = 0;
_.slideOffset += _.slideWidth * Math.floor(_.options.slidesToShow / 2);
}
My slider has 5 slides, so you may need to adjust depending on how many slides you use
@leggomuhgreggo duplicate of what issue exactly?
Hmm, when I closed it, I was pretty sure it was a duplicate of a number of either centerMode + infinite: false issues or variableWidth issues.
I still think chances are good it's related to those, but I will reopen and assign to that topic just to make sure we're factoring for it when those issues get addressed
Take a look at this merge request, his solution worked for me.
https://github.com/kenwheeler/slick/pull/2635
Most helpful comment
In case anyone come across this, here is the code I modified starting at line 1105 in slick.js :
if (_.options.centerMode === true && _.options.infinite === true) { _.slideOffset += _.slideWidth * Math.floor(_.options.slidesToShow / 2) - _.slideWidth; } else if (_.options.centerMode === true && _.options.infinite === false) { if(slideIndex >1 && slideIndex < _.slideCount - 2 ) { _.slideOffset = 0; _.slideOffset += _.slideWidth * Math.floor(_.options.slidesToShow / 2); } else if (slideIndex ===1) { _.slideOffset = 0; _.slideOffset += _.slideWidth; } } else if (_.options.centerMode === true) { _.slideOffset = 0; _.slideOffset += _.slideWidth * Math.floor(_.options.slidesToShow / 2); }My slider has 5 slides, so you may need to adjust depending on how many slides you use