mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-17 19:23:26 +00:00
no message
This commit is contained in:
parent
45e663fcf8
commit
fc907d23a7
14
resources/assets/js/directives/longpress.js
vendored
14
resources/assets/js/directives/longpress.js
vendored
@ -6,13 +6,15 @@ const longpress = {
|
|||||||
let mode = 'default',
|
let mode = 'default',
|
||||||
isCall = false,
|
isCall = false,
|
||||||
pressTimer = null,
|
pressTimer = null,
|
||||||
delay = 500, // 延迟时间,长按多久触发(毫秒)
|
delay = 500, // 延迟时间,长按多久触发(毫秒)
|
||||||
touchend = null, // 触摸结束回调
|
touchend = null, // 触摸结束回调
|
||||||
callback = binding.value; // 回调函数:第一个参数是事件对象(点到的对象),第二个参数是元素对象(注册绑定的对象)
|
callback = binding.value, // 回调函数:第一个参数是事件对象(点到的对象),第二个参数是元素对象(注册绑定的对象)
|
||||||
|
preventEndEvent = false; // 是否触摸结束阻止(如果触发了callback)
|
||||||
if ($A.isJson(binding.value)) {
|
if ($A.isJson(binding.value)) {
|
||||||
delay = binding.value.delay || 500;
|
delay = binding.value.delay || 500;
|
||||||
touchend = typeof binding.value.touchend === 'function' ? binding.value.touchend : touchend;
|
touchend = typeof binding.value.touchend === 'function' ? binding.value.touchend : touchend;
|
||||||
callback = typeof binding.value.callback === 'function' ? binding.value.callback : callback;
|
callback = typeof binding.value.callback === 'function' ? binding.value.callback : callback;
|
||||||
|
preventEndEvent = binding.value.preventEndEvent || false;
|
||||||
}
|
}
|
||||||
if (typeof callback !== 'function') {
|
if (typeof callback !== 'function') {
|
||||||
throw 'callback must be a function'
|
throw 'callback must be a function'
|
||||||
@ -62,7 +64,11 @@ const longpress = {
|
|||||||
// 触摸结束
|
// 触摸结束
|
||||||
el.__longpressEnd__ = (e) => {
|
el.__longpressEnd__ = (e) => {
|
||||||
if (typeof touchend === 'function') {
|
if (typeof touchend === 'function') {
|
||||||
touchend(e, el)
|
touchend(e, isCall)
|
||||||
|
}
|
||||||
|
if (isCall && preventEndEvent) {
|
||||||
|
e.preventDefault()
|
||||||
|
e.stopPropagation()
|
||||||
}
|
}
|
||||||
el.__longpressCancel__(e)
|
el.__longpressCancel__(e)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -185,7 +185,7 @@
|
|||||||
<div
|
<div
|
||||||
ref="msgs"
|
ref="msgs"
|
||||||
class="dialog-msgs"
|
class="dialog-msgs"
|
||||||
v-longpress="{callback: handleLongpress, delay: 300}">
|
v-longpress="{callback: handleLongpress, preventEndEvent: true, delay: 300}">
|
||||||
<!--定位提示-->
|
<!--定位提示-->
|
||||||
<div v-if="positionShow && positionMsg" class="dialog-position">
|
<div v-if="positionShow && positionMsg" class="dialog-position">
|
||||||
<div class="position-label" @click="onPositionMark(positionMsg.msg_id)">
|
<div class="position-label" @click="onPositionMark(positionMsg.msg_id)">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user