[bugfix] SwipeCell: prevent page scroll

fix #1380
This commit is contained in:
rex 2019-03-17 20:19:27 +08:00 committed by GitHub
parent cb925a2ba5
commit 81e300c06e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View File

@ -43,7 +43,7 @@ VantComponent({
this.swipe = false; this.swipe = false;
}, },
open(position) { open(position: 'left' | 'right') {
const { leftWidth, rightWidth } = this.data; const { leftWidth, rightWidth } = this.data;
const offset = position === 'left' ? leftWidth : -rightWidth; const offset = position === 'left' ? leftWidth : -rightWidth;
this.swipeMove(offset); this.swipeMove(offset);
@ -59,13 +59,13 @@ VantComponent({
this.opened = true; this.opened = true;
}, },
swipeMove(offset = 0) { swipeMove(offset: number = 0) {
this.set({ offset }); this.set({ offset });
offset && (this.swiping = true); offset && (this.swiping = true);
!offset && (this.opened = false); !offset && (this.opened = false);
}, },
swipeLeaveTransition(direction) { swipeLeaveTransition(direction: number) {
const { offset, leftWidth, rightWidth } = this.data; const { offset, leftWidth, rightWidth } = this.data;
const threshold = this.opened ? 1 - THRESHOLD : THRESHOLD; const threshold = this.opened ? 1 - THRESHOLD : THRESHOLD;
@ -80,7 +80,7 @@ VantComponent({
} }
}, },
startDrag(event) { startDrag(event: Weapp.TouchEvent) {
if (this.data.disabled) { if (this.data.disabled) {
return; return;
} }
@ -93,7 +93,7 @@ VantComponent({
} }
}, },
onDrag(event) { onDrag(event: Weapp.TouchEvent) {
if (this.data.disabled) { if (this.data.disabled) {
return; return;
} }
@ -125,7 +125,7 @@ VantComponent({
} }
}, },
onClick(event) { onClick(event: Weapp.Event) {
const { key: position = 'outside' } = event.currentTarget.dataset; const { key: position = 'outside' } = event.currentTarget.dataset;
this.$emit('click', position); this.$emit('click', position);

View File

@ -2,10 +2,10 @@
class="van-swipe-cell" class="van-swipe-cell"
data-key="cell" data-key="cell"
bindtap="onClick" bindtap="onClick"
bindtouchstart="startDrag" catchtouchstart="startDrag"
bindtouchmove="onDrag" catchtouchmove="onDrag"
bindtouchend="endDrag" catchtouchend="endDrag"
bindtouchcancel="endDrag" catchtouchcancel="endDrag"
> >
<view <view
style="{{ wrapperStyle }}" style="{{ wrapperStyle }}"