From 53bcabe3d02760762a9e3241b0ca32f572f8f7f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A1=97=E8=A7=92=E5=B0=8F=E6=9E=97?= <1013335014@qq.com> Date: Tue, 28 May 2024 17:47:49 +0800 Subject: [PATCH] =?UTF-8?q?Fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E7=AB=AF=E9=83=A8=E5=88=86=E6=B5=8F=E8=A7=88=E5=99=A8?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E7=BC=A9=E6=94=BE=E6=97=B6=E4=BC=9A=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E9=A1=B5=E9=9D=A2=E7=BC=A9=E6=94=BE=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/plugins/TouchEvent.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/simple-mind-map/src/plugins/TouchEvent.js b/simple-mind-map/src/plugins/TouchEvent.js index dc25739a..c2e17783 100644 --- a/simple-mind-map/src/plugins/TouchEvent.js +++ b/simple-mind-map/src/plugins/TouchEvent.js @@ -16,10 +16,12 @@ class TouchEvent { this.onTouchmove = this.onTouchmove.bind(this) this.onTouchcancel = this.onTouchcancel.bind(this) this.onTouchend = this.onTouchend.bind(this) - window.addEventListener('touchstart', this.onTouchstart) - window.addEventListener('touchmove', this.onTouchmove) - window.addEventListener('touchcancel', this.onTouchcancel) - window.addEventListener('touchend', this.onTouchend) + window.addEventListener('touchstart', this.onTouchstart, { passive: false }) + window.addEventListener('touchmove', this.onTouchmove, { passive: false }) + window.addEventListener('touchcancel', this.onTouchcancel, { + passive: false + }) + window.addEventListener('touchend', this.onTouchend, { passive: false }) } // 解绑事件 @@ -32,6 +34,7 @@ class TouchEvent { // 手指按下事件 onTouchstart(e) { + e.preventDefault() this.touchesNum = e.touches.length this.touchStartScaleView = null if (this.touchesNum === 1) { @@ -43,6 +46,7 @@ class TouchEvent { // 手指移动事件 onTouchmove(e) { + e.preventDefault() let len = e.touches.length if (len === 1) { let touch = e.touches[0] @@ -103,6 +107,7 @@ class TouchEvent { // 手指松开事件 onTouchend(e) { + e.preventDefault() this.dispatchMouseEvent('mouseup', e.target) if (this.touchesNum === 1) { // 模拟双击事件