From 22beb23c0d7074ff83d08e74b25d0f55fa4acde7 Mon Sep 17 00:00:00 2001 From: Adam Britto Date: Thu, 2 May 2019 10:42:41 +0800 Subject: [PATCH] Fixed bug when adding agile__slide--current class to slides when infinite == true and centerMode == false. --- src/Agile.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Agile.vue b/src/Agile.vue index 4173426..d7bbee0 100644 --- a/src/Agile.vue +++ b/src/Agile.vue @@ -503,7 +503,8 @@ start -= (Math.floor(this.settings.slidesToShow / 2) - +(this.settings.slidesToShow % 2 === 0)) } - for (let i = start; i < start + this.settings.slidesToShow; i++) { + // To account for the combination of infinite = false and centerMode = true, ensure we don't overrun the bounds of the slide count. + for (let i = Math.max(start, 0); i < Math.min(start + this.settings.slidesToShow, this.slidesCount) ; i++) { this.allSlides[i].classList.add('agile__slide--current') } },