From 48543e39dd77f6e3fd19b6907a0a62ca8f638948 Mon Sep 17 00:00:00 2001 From: niaccurshi Date: Wed, 18 Nov 2015 13:36:55 +0000 Subject: [PATCH] Correctly center slider Ensure the slides are centered if slideCount is less than slidesToShow --- slick/slick.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/slick/slick.js b/slick/slick.js index 376bfca6f..56c720c41 100644 --- a/slick/slick.js +++ b/slick/slick.js @@ -1055,7 +1055,12 @@ } if (_.options.centerMode === true && _.options.infinite === true) { - _.slideOffset += _.slideWidth * Math.floor(_.options.slidesToShow / 2) - _.slideWidth; + if (_.slideCount <= _.options.slidesToShow) { + _.slideOffset += (_.slideWidth * (_.options.slidesToShow / 2)) - (_.slideWidth * (_.slideCount/2)); + } else { + _.slideOffset += _.slideWidth * Math.floor(_.options.slidesToShow / 2) - _.slideWidth; + } + } else if (_.options.centerMode === true) { _.slideOffset = 0; _.slideOffset += _.slideWidth * Math.floor(_.options.slidesToShow / 2);