mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-08-21 04:03:28 +08:00
parent
cb925a2ba5
commit
81e300c06e
@ -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);
|
||||||
|
|
||||||
|
@ -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 }}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user