From 5e8be9b390e88ec056c41ecfcbf8cf6b71e4b1f4 Mon Sep 17 00:00:00 2001 From: Rijn Date: Mon, 16 Jan 2017 17:51:03 -0600 Subject: [PATCH] fixed add bug. added push test --- src/components/carousel/carousel.vue | 3 ++- test/routers/carousel.vue | 14 +++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/components/carousel/carousel.vue b/src/components/carousel/carousel.vue index 6cc4331..dd7fd60 100644 --- a/src/components/carousel/carousel.vue +++ b/src/components/carousel/carousel.vue @@ -147,7 +147,8 @@ add (offset) { let index = this.currentIndex; index += offset; - if (index === this.slides.length) index = 0; + while (index < 0) index += this.slides.length; + index = index % this.slides.length; this.currentIndex = index; }, slide () { diff --git a/test/routers/carousel.vue b/test/routers/carousel.vue index b6f9ee8..a73652f 100644 --- a/test/routers/carousel.vue +++ b/test/routers/carousel.vue @@ -19,6 +19,9 @@ 2 + + Push + test3 + + {{item}} +