added offset function
This commit is contained in:
parent
90f77e4060
commit
77d460e8c4
2 changed files with 17 additions and 6 deletions
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<div :class="classes">
|
||||
<div :class="[prefixCls + '-arrow', 'left']">
|
||||
<div :class="[prefixCls + '-arrow', 'left']" @click="add(-1)">
|
||||
<div class='placeholder'></div>
|
||||
<Icon type="arrow-left-b"></Icon>
|
||||
</div>
|
||||
|
@ -10,7 +10,7 @@
|
|||
<slot></slot>
|
||||
</div>
|
||||
</div>
|
||||
<div :class="[prefixCls + '-arrow', 'right']">
|
||||
<div :class="[prefixCls + '-arrow', 'right']" @click="add(1)">
|
||||
<div class='placeholder'></div>
|
||||
<Icon type="arrow-right-b"></Icon>
|
||||
</div>
|
||||
|
@ -144,6 +144,12 @@
|
|||
this.updatePos();
|
||||
});
|
||||
},
|
||||
add (offset) {
|
||||
let index = this.currentIndex;
|
||||
index += offset;
|
||||
if (index === this.slides.length) index = 0;
|
||||
this.currentIndex = index;
|
||||
},
|
||||
slide () {
|
||||
this.trackLeft = this.currentIndex * this.listWidth;
|
||||
},
|
||||
|
@ -151,10 +157,7 @@
|
|||
window.clearInterval(this.timer);
|
||||
if (this.autoplay) {
|
||||
this.timer = window.setInterval(() => {
|
||||
let index = this.currentIndex;
|
||||
index ++;
|
||||
if (index === this.slides.length) index = 0;
|
||||
this.currentIndex = index;
|
||||
this.add(1);
|
||||
}, this.autoplaySpeed);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,14 @@
|
|||
<i-col span="4">
|
||||
Speed <Slider :value.sync="autoplaySpeed" :min="300" :max="5000"></Slider>
|
||||
</i-col>
|
||||
<i-col span="4">
|
||||
Switch To
|
||||
<Button-group>
|
||||
<i-button @click="currentIndex = 0">0</i-button>
|
||||
<i-button @click="currentIndex = 1">1</i-button>
|
||||
<i-button @click="currentIndex = 2">2</i-button>
|
||||
</Button-group>
|
||||
</i-col>
|
||||
</Row>
|
||||
<Carousel style="width: 50%; border: solid 1px #000"
|
||||
:current-index.sync="currentIndex"
|
||||
|
|
Loading…
Add table
Reference in a new issue