From 74a3eea203a600d96760f12505d3b45e31b0fc77 Mon Sep 17 00:00:00 2001 From: neverland Date: Fri, 3 Nov 2017 04:50:58 -0500 Subject: [PATCH] [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 --- docs/examples-docs/en-US/swipe.md | 1 + docs/examples-docs/zh-CN/swipe.md | 3 ++- packages/swipe/index.vue | 8 ++++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/examples-docs/en-US/swipe.md b/docs/examples-docs/en-US/swipe.md index 57fa76f6d..5c2287909 100644 --- a/docs/examples-docs/en-US/swipe.md +++ b/docs/examples-docs/en-US/swipe.md @@ -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 diff --git a/docs/examples-docs/zh-CN/swipe.md b/docs/examples-docs/zh-CN/swipe.md index 26d014a68..5470707b8 100644 --- a/docs/examples-docs/zh-CN/swipe.md +++ b/docs/examples-docs/zh-CN/swipe.md @@ -80,7 +80,7 @@ Vue.component(SwipeItem.name, SwipeItem); :::demo 图片懒加载 ```html - + @@ -108,6 +108,7 @@ export default { | autoplay | 自动轮播间隔,单位为 ms | `Number` | - | - | | duration | 动画时长,单位为 ms | `Number` | `500` | - | | showIndicators | 是否显示指示器 | `Boolean` | `true` | - | +| initialSwipe | 初始位置,从 0 开始算 | `Number` | `0` | - | ### 事件 diff --git a/packages/swipe/index.vue b/packages/swipe/index.vue index ca9e427d1..f0af6ec74 100644 --- a/packages/swipe/index.vue +++ b/packages/swipe/index.vue @@ -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; });