提交 6dc3a922 编写于 作者: d-u-a's avatar d-u-a

fix: H5平台 longpress 事件回调 touches/changedTouches 为 [] Bug

上级 fa405fa8
...@@ -83,8 +83,8 @@ export function processEvent (name, $event = {}, detail = {}, target = {}, curre ...@@ -83,8 +83,8 @@ export function processEvent (name, $event = {}, detail = {}, target = {}, curre
target: processTarget(target, detail), target: processTarget(target, detail),
currentTarget: processTarget(currentTarget), currentTarget: processTarget(currentTarget),
// 只处理系统事件 // 只处理系统事件
touches: $event instanceof Event ? processTouches($event.touches) : $event.touches, touches: ($event instanceof Event || $event instanceof CustomEvent) ? processTouches($event.touches) : $event.touches,
changedTouches: $event instanceof Event ? processTouches($event.changedTouches) : $event.changedTouches, changedTouches: ($event instanceof Event || $event instanceof CustomEvent) ? processTouches($event.changedTouches) : $event.changedTouches,
preventDefault () { }, preventDefault () { },
stopPropagation () { } stopPropagation () { }
}) })
...@@ -124,15 +124,16 @@ function touchstart (evt) { ...@@ -124,15 +124,16 @@ function touchstart (evt) {
startPageX = pageX startPageX = pageX
startPageY = pageY startPageY = pageY
longPressTimer = setTimeout(function () { longPressTimer = setTimeout(function () {
evt.target.dispatchEvent(new CustomEvent('longpress', { let customEvent = new CustomEvent('longpress', {
bubbles: true, bubbles: true,
cancelable: true, cancelable: true,
target: evt.target, target: evt.target,
currentTarget: evt.currentTarget, currentTarget: evt.currentTarget
touches: evt.touches, })
changedTouches: evt.changedTouches customEvent.touches = evt.touches
})) customEvent.changedTouches = evt.changedTouches
evt.target.dispatchEvent(customEvent)
}, LONGPRESS_TIMEOUT) }, LONGPRESS_TIMEOUT)
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册