Browse Source

长按菜单优化

master
xsx 1 year ago
parent
commit
b319f37f84
  1. 16
      im-uniapp/components/pop-menu/pop-menu.vue

16
im-uniapp/components/pop-menu/pop-menu.vue

@ -1,6 +1,6 @@
<template> <template>
<view> <view>
<view @longpress.stop="onLongPress($event)" @touchmove="onTouchMove"> <view @longpress.stop="onLongPress($event)" @touchmove="onTouchMove" @touchend="onTouchEnd">
<slot></slot> <slot></slot>
</view> </view>
<view v-if="isShowMenu" class="pop-menu" @touchstart="onClose()" @contextmenu.prevent=""></view> <view v-if="isShowMenu" class="pop-menu" @touchstart="onClose()" @contextmenu.prevent=""></view>
@ -19,6 +19,7 @@
data() { data() {
return { return {
isShowMenu : false, isShowMenu : false,
isTouchMove: false,
style : "" style : ""
} }
}, },
@ -29,6 +30,10 @@
}, },
methods: { methods: {
onLongPress(e){ onLongPress(e){
if(this.isTouchMove){
//
return;
}
uni.getSystemInfo({ uni.getSystemInfo({
success: (res) => { success: (res) => {
let touches = e.touches[0]; let touches = e.touches[0];
@ -53,7 +58,11 @@
}) })
}, },
onTouchMove(){ onTouchMove(){
this.onClose() this.onClose();
this.isTouchMove = true;
},
onTouchEnd(){
this.isTouchMove = false;
}, },
onSelectMenu(item) { onSelectMenu(item) {
this.$emit("select", item); this.$emit("select", item);
@ -84,6 +93,7 @@
background-color: #333; background-color: #333;
z-index: 999; z-index: 999;
opacity: 0.5; opacity: 0.5;
} }
.menu { .menu {
@ -108,6 +118,4 @@
} }
} }
} }
</style> </style>
Loading…
Cancel
Save