From bf8ce57e42f4a5a463ae5806e8676044be1dc71d Mon Sep 17 00:00:00 2001 From: neverland Date: Fri, 26 Oct 2018 14:34:50 +0800 Subject: [PATCH] [improvement] Swipe: can set cross axis size (#1982) --- packages/swipe/index.vue | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/swipe/index.vue b/packages/swipe/index.vue index 0c038366b..706127f90 100644 --- a/packages/swipe/index.vue +++ b/packages/swipe/index.vue @@ -36,16 +36,10 @@ export default create({ mixins: [Touch], props: { + width: Number, + height: Number, autoplay: Number, vertical: Boolean, - width: { - type: Number, - default: 0 - }, - height: { - type: Number, - default: 0 - }, loop: { type: Boolean, default: true @@ -137,8 +131,11 @@ export default create({ }, trackStyle() { + const mainAxis = this.vertical ? 'height' : 'width'; + const crossAxis = this.vertical ? 'width' : 'height'; return { - [this.vertical ? 'height' : 'width']: `${this.trackSize}px`, + [mainAxis]: `${this.trackSize}px`, + [crossAxis]: this[crossAxis] ? `${this[crossAxis]}px` : '', transitionDuration: `${this.swiping ? 0 : this.duration}ms`, transform: `translate${this.vertical ? 'Y' : 'X'}(${this.offset}px)` };