From aee7650d473c4e0a7e0e6e41ceaad946d07155da Mon Sep 17 00:00:00 2001 From: Pawel Urbanek Date: Fri, 24 Mar 2023 15:33:46 +0100 Subject: [PATCH 1/2] add touch events on touch monitor --- client/src/components/video.vue | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/client/src/components/video.vue b/client/src/components/video.vue index 6f13e42..c55f1bf 100644 --- a/client/src/components/video.vue +++ b/client/src/components/video.vue @@ -21,6 +21,9 @@ @mouseup.stop.prevent="onMouseUp" @mouseenter.stop.prevent="onMouseEnter" @mouseleave.stop.prevent="onMouseLeave" + @touchmove.stop.prevent="onTouchHandler" + @touchstart.stop.prevent="onTouchHandler" + @touchend.stop.prevent="onTouchHandler" />
@@ -687,6 +690,35 @@ }, 100) } } + onTouchHandler(event: TouchEvent) { + let touches = event.changedTouches + let first = touches[0] + let type = '' + switch (event.type) { + case 'touchstart': + type = 'mousedown' + break + case 'touchmove': + type = 'mousemove' + break + case 'touchend': + type = 'mouseup' + break + default: + return + } + + const simulatedEvent = new MouseEvent(type, { + bubbles: true, + cancelable: true, + view: window, + screenX: first.screenX, + screenY: first.screenY, + clientX: first.clientX, + clientY: first.clientY, + }) + first.target.dispatchEvent(simulatedEvent) + } onMouseDown(e: MouseEvent) { if (!this.hosting) { From df634be1c514ad6b1a5a4f9520c0344176632585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Mon, 27 Mar 2023 21:47:41 +0200 Subject: [PATCH 2/2] lint. --- client/src/components/video.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/src/components/video.vue b/client/src/components/video.vue index c55f1bf..e97c4fc 100644 --- a/client/src/components/video.vue +++ b/client/src/components/video.vue @@ -690,11 +690,11 @@ }, 100) } } - onTouchHandler(event: TouchEvent) { - let touches = event.changedTouches - let first = touches[0] + + onTouchHandler(e: TouchEvent) { + let first = e.changedTouches[0] let type = '' - switch (event.type) { + switch (e.type) { case 'touchstart': type = 'mousedown' break