[new feature] Swipe add 'initialSwipe' prop (#279)

* [bugfix] CouponList always show empty info

* [bugfix] add click feedback of buttons in components

* [Doc] add custom theme document

* [new feature] Notice bar support more props

* [bugfix] PullRefresh test cases

* [bugfix] unused NoticeBar style

* [bugfix] Swipe width calc error

* [Doc] english document of all action components

* [Doc] change document site path to /zanui/vant

* [Doc] fix

* [bugfix] uploader style error

* [bugfix] tabs document demo

* [new feature] Cell support vue-router target route

* [bugfix] add cell test cases

* update yarn.lock

* [bugfix] Tabbar cann't display info when use icon slot

* [Doc] update document title

* [bugfix] Dialog should reset button text when showed

* [new feature] CouponList add showCloseButton prop

* [new feature] Swipe add 'initialSwipe' prop
This commit is contained in:
neverland 2017-11-03 04:50:58 -05:00 committed by GitHub
parent 7a3fef0a09
commit 74a3eea203
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

View File

@ -72,6 +72,7 @@ export default {
| autoplay | Autoplay interval (ms) | `Number` | - | - |
| duration | Animation duration (ms) | `Number` | `500` | - |
| showIndicators | Whether to show indocators | `Boolean` | `true` | - |
| initialSwipe | Index of initial swipe, start from 0 | `Number` | `0` | - |
### Event

View File

@ -80,7 +80,7 @@ Vue.component(SwipeItem.name, SwipeItem);
:::demo 图片懒加载
```html
<van-swipe>
<van-swipe :autoplay="3000">
<van-swipe-item v-for="(image, index) in images" :key="index">
<img v-lazy="image" />
</van-swipe-item>
@ -108,6 +108,7 @@ export default {
| autoplay | 自动轮播间隔,单位为 ms | `Number` | - | - |
| duration | 动画时长,单位为 ms | `Number` | `500` | - |
| showIndicators | 是否显示指示器 | `Boolean` | `true` | - |
| initialSwipe | 初始位置,从 0 开始算 | `Number` | `0` | - |
### 事件

View File

@ -30,6 +30,10 @@ export default {
props: {
autoplay: Number,
initialSwipe: {
type: Number,
default: 0
},
showIndicators: {
type: Boolean,
default: true
@ -92,9 +96,9 @@ export default {
// reset offset when children changes
clearTimeout(this.timer);
this.width = this.$el.getBoundingClientRect().width;
this.active = 0;
this.active = this.initialSwipe;
this.currentDuration = 0;
this.offset = this.count > 1 ? -this.width : 0;
this.offset = this.count > 1 ? -this.width * (this.active + 1) : 0;
this.swipes.forEach(swipe => {
swipe.offset = 0;
});