移动端内通知手势上滑动关闭

This commit is contained in:
kuaifan 2022-06-04 22:22:48 +08:00
parent 8358a10ce8
commit 8a49eb742e

View File

@ -1,6 +1,11 @@
<template>
<transition v-if="show && userid > 0" name="mobile-notify">
<div class="mobile-notification" :class="{show}" @click.stop="onClick">
<div
class="mobile-notification"
:class="{show}"
@click.stop="onClick"
@touchstart="onTouchstart"
@touchmove="onTouchmove">
<UserAvatar :userid="userid" :size="40" show-name/>
<div class="notification-desc">{{desc}}</div>
</div>
@ -19,6 +24,8 @@ export default {
show: false,
timer: null,
startY: 0,
};
},
@ -56,7 +63,18 @@ export default {
if (typeof this.callback === "function") {
this.callback();
}
}
},
onTouchstart(e) {
this.startY = e.touches[0].clientY;
},
onTouchmove(e) {
if (this.startY > 0 && this.startY - e.touches[0].clientY > 10) {
this.startY = 0;
this.close();
}
},
},
};
</script>