diff --git a/glider.js b/glider.js index 95d3d1a..b6f66e5 100644 --- a/glider.js +++ b/glider.js @@ -221,7 +221,11 @@ _.dots.setAttribute('role', 'tablist') _.dots.classList.add('glider-dots') - for (var i = 0; i < Math.ceil(_.slides.length / _.opt.slidesToShow); ++i) { + for ( + var i = 0; + i < Math.ceil(_.slides.length / Math.floor(_.opt.slidesToShow)); + ++i + ) { var dot = document.createElement('button') dot.dataset.index = i dot.setAttribute('aria-label', 'Page ' + (i + 1)) @@ -297,7 +301,9 @@ } _.slide = Math.round(_.ele.scrollLeft / _.itemWidth) - _.page = Math.round(_.ele.scrollLeft / _.containerWidth) + _.page = Math.round( + _.ele.scrollLeft / (_.itemWidth * Math.floor(_.opt.slidesToShow)) + ) var middle = _.slide + Math.floor(Math.floor(_.opt.slidesToShow) / 2) @@ -391,7 +397,7 @@ var position if (dot === true) { - slide = Math.round((slide * _.containerWidth) / _.itemWidth) + slide = slide * Math.floor(_.opt.slidesToShow) position = slide * _.itemWidth } else { if (typeof slide === 'string') {