Merge pull request #228 from rijn/carousel
reset autoplay timer after trigger
This commit is contained in:
commit
bade4e13bc
1 changed files with 10 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div :class="classes">
|
<div :class="classes">
|
||||||
<button :class="arrowClasses" class="left" @click="add(-1)">
|
<button :class="arrowClasses" class="left" @click="arrowEvent(-1)">
|
||||||
<Icon type="chevron-left"></Icon>
|
<Icon type="chevron-left"></Icon>
|
||||||
</button>
|
</button>
|
||||||
<div :class="[prefixCls + '-list']">
|
<div :class="[prefixCls + '-list']">
|
||||||
|
@ -8,7 +8,7 @@
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button :class="arrowClasses" class="right" @click="add(1)">
|
<button :class="arrowClasses" class="right" @click="arrowEvent(1)">
|
||||||
<Icon type="chevron-right"></Icon>
|
<Icon type="chevron-right"></Icon>
|
||||||
</button>
|
</button>
|
||||||
<ul :class="dotsClasses">
|
<ul :class="dotsClasses">
|
||||||
|
@ -175,11 +175,13 @@
|
||||||
|
|
||||||
this.updateSlides(true, true);
|
this.updateSlides(true, true);
|
||||||
this.updatePos();
|
this.updatePos();
|
||||||
|
this.updateOffset();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleResize () {
|
handleResize () {
|
||||||
this.listWidth = parseInt(getStyle(this.$el, 'width'));
|
this.listWidth = parseInt(getStyle(this.$el, 'width'));
|
||||||
this.updatePos();
|
this.updatePos();
|
||||||
|
this.updateOffset();
|
||||||
},
|
},
|
||||||
add (offset) {
|
add (offset) {
|
||||||
let index = this.currentIndex;
|
let index = this.currentIndex;
|
||||||
|
@ -188,9 +190,15 @@
|
||||||
index = index % this.slides.length;
|
index = index % this.slides.length;
|
||||||
this.currentIndex = index;
|
this.currentIndex = index;
|
||||||
},
|
},
|
||||||
|
arrowEvent (offset) {
|
||||||
|
this.setAutoplay();
|
||||||
|
this.add(offset);
|
||||||
|
},
|
||||||
dotsEvent (event, n) {
|
dotsEvent (event, n) {
|
||||||
if (event === this.trigger && this.currentIndex !== n) {
|
if (event === this.trigger && this.currentIndex !== n) {
|
||||||
this.currentIndex = n;
|
this.currentIndex = n;
|
||||||
|
// Reset autoplay timer when trigger be activated
|
||||||
|
this.setAutoplay();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setAutoplay () {
|
setAutoplay () {
|
||||||
|
@ -203,7 +211,6 @@
|
||||||
},
|
},
|
||||||
updateOffset () {
|
updateOffset () {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.handleResize();
|
|
||||||
this.trackOffset = this.currentIndex * this.listWidth;
|
this.trackOffset = this.currentIndex * this.listWidth;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue