mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
Fixed: one page Swipe components error (#70)
This commit is contained in:
parent
93db67b964
commit
7bc8c5022a
@ -69,12 +69,6 @@ extend(Scroll.prototype, {
|
||||
var leftOffset = offset - wrapWidth;
|
||||
var rightOffset = offset + wrapWidth;
|
||||
|
||||
page = this.getCurrentPage();
|
||||
if (page) {
|
||||
page.style['-webkit-transform'] = 'translate3d(' + offset + 'px, 0, 0)';
|
||||
page.style['display'] = 'block';
|
||||
}
|
||||
|
||||
leftPage = this.pages[this.mapLoopPage(currentOffsetPage - 1)];
|
||||
if (leftPage) {
|
||||
if (Math.abs(leftOffset) <= wrapWidth) {
|
||||
@ -96,6 +90,12 @@ extend(Scroll.prototype, {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
page = this.getCurrentPage();
|
||||
if (page) {
|
||||
page.style['-webkit-transform'] = 'translate3d(' + offset + 'px, 0, 0)';
|
||||
page.style['display'] = 'block';
|
||||
}
|
||||
},
|
||||
|
||||
movePage: function(dist, isEnd) {
|
||||
|
@ -10,6 +10,13 @@ export default {
|
||||
|
||||
beforeCreate() {
|
||||
this.$parent.swipes.push(this);
|
||||
},
|
||||
|
||||
destroyed() {
|
||||
const index = this.$parent.swipes.indexOf(this)
|
||||
if (index > -1) {
|
||||
this.$parent.swipes.splice(index, 1)
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@ -36,11 +36,6 @@ export default {
|
||||
},
|
||||
|
||||
mounted() {
|
||||
const pages = this.$el.querySelectorAll('.van-swipe-item')
|
||||
if (pages.length <= 1) {
|
||||
return
|
||||
}
|
||||
|
||||
this.input = new Input(this.$el, {
|
||||
listenMoving: true
|
||||
});
|
||||
@ -66,10 +61,28 @@ export default {
|
||||
}).on('autoPlay', function(dist, isEnd) {
|
||||
scroll.movePage(dist.x, isEnd);
|
||||
});
|
||||
this.dummy = dummy
|
||||
},
|
||||
|
||||
updated() {
|
||||
this.scroll.update();
|
||||
watch: {
|
||||
swipes(value) {
|
||||
if (this.autoPlay && value.length > 1) {
|
||||
this.dummy.initMove()
|
||||
} else {
|
||||
this.dummy.clearMove()
|
||||
}
|
||||
this.scroll.update();
|
||||
return value
|
||||
},
|
||||
|
||||
autoPlay(value) {
|
||||
if (value && this.swipes.length > 1) {
|
||||
this.dummy.initMove()
|
||||
} else {
|
||||
this.dummy.clearMove()
|
||||
}
|
||||
return value
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user