+
@@ -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);
}
};
diff --git a/packages/swipe/index.vue b/packages/swipe/index.vue
index efad94805..eb5b05a7c 100644
--- a/packages/swipe/index.vue
+++ b/packages/swipe/index.vue
@@ -1,97 +1,161 @@