[improvement] Swipe: can set cross axis size (#1982)

This commit is contained in:
neverland 2018-10-26 14:34:50 +08:00 committed by GitHub
parent 28d380f25a
commit bf8ce57e42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)`
};