From 3e35f229ad3b598c863afc6e76a16730ff8243d6 Mon Sep 17 00:00:00 2001
From: handongxun <handongxun@dcloud.io>
Date: Sat, 21 Sep 2019 16:39:54 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20H5=E5=B9=B3=E5=8F=B0=20longpress=20?=
 =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E5=9B=9E=E8=B0=83=20touches/changedTouches?=
 =?UTF-8?q?=20=E4=B8=BA=20[]=20Bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/core/view/plugins/events.js | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/core/view/plugins/events.js b/src/core/view/plugins/events.js
index ff44b3bcae..09a2a3a3f0 100644
--- a/src/core/view/plugins/events.js
+++ b/src/core/view/plugins/events.js
@@ -83,8 +83,8 @@ export function processEvent (name, $event = {}, detail = {}, target = {}, curre
     target: processTarget(target, detail),
     currentTarget: processTarget(currentTarget),
     // 只处理系统事件
-    touches: $event instanceof Event ? processTouches($event.touches) : $event.touches,
-    changedTouches: $event instanceof Event ? processTouches($event.changedTouches) : $event.changedTouches,
+    touches: ($event instanceof Event || $event instanceof CustomEvent) ? processTouches($event.touches) : $event.touches,
+    changedTouches: ($event instanceof Event || $event instanceof CustomEvent) ? processTouches($event.changedTouches) : $event.changedTouches,
     preventDefault () { },
     stopPropagation () { }
   })
@@ -124,15 +124,16 @@ function touchstart (evt) {
   startPageX = pageX
   startPageY = pageY
 
-  longPressTimer = setTimeout(function () {
-    evt.target.dispatchEvent(new CustomEvent('longpress', {
+  longPressTimer = setTimeout(function () {
+    let customEvent = new CustomEvent('longpress', {
       bubbles: true,
       cancelable: true,
       target: evt.target,
-      currentTarget: evt.currentTarget,
-      touches: evt.touches,
-      changedTouches: evt.changedTouches
-    }))
+      currentTarget: evt.currentTarget
+    })
+    customEvent.touches = evt.touches
+    customEvent.changedTouches = evt.changedTouches
+    evt.target.dispatchEvent(customEvent)
   }, LONGPRESS_TIMEOUT)
 }
 
-- 
GitLab