[new feature] Swipe: support custom item width & height (#1664)

This commit is contained in:
xliez
2018-08-22 16:03:49 +08:00
committed by neverland
parent c96ef7cc47
commit ed2911f667
6 changed files with 65 additions and 8 deletions

View File

@@ -36,6 +36,14 @@ export default create({
props: {
autoplay: Number,
vertical: Boolean,
width: {
type: Number,
default: 0
},
height: {
type: Number,
default: 0
},
loop: {
type: Boolean,
default: true
@@ -60,8 +68,8 @@ export default create({
data() {
return {
width: 0,
height: 0,
computedWidth: 0,
computedHeight: 0,
offset: 0,
active: 0,
deltaX: 0,
@@ -115,7 +123,7 @@ export default create({
},
size() {
return this[this.vertical ? 'height' : 'width'];
return this[this.vertical ? 'computedHeight' : 'computedWidth'];
},
trackSize() {
@@ -141,8 +149,8 @@ export default create({
clearTimeout(this.timer);
if (this.$el) {
const rect = this.$el.getBoundingClientRect();
this.width = rect.width;
this.height = rect.height;
this.computedWidth = this.width || rect.width;
this.computedHeight = this.height || rect.height;
}
this.swiping = true;
this.active = active;