[breaking change] reconstruct Swipe component (#194)

* Swipe: reconstruct

* [bugfix]: Swipe autoplay

[bugfix] AddressEdit doc link
This commit is contained in:
neverland
2017-10-12 06:22:12 -05:00
committed by GitHub
parent 77f6a798e4
commit 560ccfdec2
12 changed files with 242 additions and 681 deletions
+19 -5
View File
@@ -1,5 +1,5 @@
<template>
<div class="van-swipe-item">
<div class="van-swipe-item" :style="style">
<slot></slot>
</div>
</template>
@@ -10,13 +10,27 @@ export default {
beforeCreate() {
this.$parent.swipes.push(this);
this.$parent.childrenOffset.push(0);
},
data() {
return {
offset: 0,
index: this.$parent.swipes.indexOf(this)
};
},
computed: {
style() {
return {
width: this.$parent.width + 'px',
transform: `translate3d(${this.offset}px, 0, 0)`
};
}
},
destroyed() {
const index = this.$parent.swipes.indexOf(this);
if (index > -1) {
this.$parent.swipes.splice(index, 1);
}
this.$parent.swipes.splice(this.index, 1);
}
};
</script>