From c1af3facb0c8af179ae06bcf17a824a90c63b66e Mon Sep 17 00:00:00 2001 From: Rijn Date: Tue, 17 Jan 2017 14:35:23 -0600 Subject: [PATCH] added on-change event emitter --- src/components/carousel/carousel.vue | 5 +++-- test/routers/carousel.vue | 10 +++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/carousel/carousel.vue b/src/components/carousel/carousel.vue index a219d43..4ab1ad9 100644 --- a/src/components/carousel/carousel.vue +++ b/src/components/carousel/carousel.vue @@ -186,7 +186,7 @@ this.currentIndex = index; }, dotsEvent (event, n) { - if (event === this.trigger) { + if (event === this.trigger && this.currentIndex !== n) { this.$emit('on-change', this.currentIndex, n); this.currentIndex = n; } @@ -210,7 +210,8 @@ autoplaySpeed () { this.setAutoplay(); }, - currentIndex () { + currentIndex (val, oldVal) { + this.$emit('on-change', oldVal, val); this.$nextTick(() => { this.trackLeft = this.currentIndex * this.listWidth; }); diff --git a/test/routers/carousel.vue b/test/routers/carousel.vue index 8d43584..20e3ad4 100644 --- a/test/routers/carousel.vue +++ b/test/routers/carousel.vue @@ -54,6 +54,7 @@ :dots="dots" :trigger="trigger" :arrow="arrow" + @on-change="slideChange" easing="linear"> @@ -71,6 +72,9 @@ {{item}} +
+

{{item}}

+