From ee37e8c90b4f03d1183ef88352c694bcfc313dcd Mon Sep 17 00:00:00 2001 From: Michael Stopa Date: Wed, 19 Jul 2023 14:53:18 +0930 Subject: [PATCH] Ensure touch is relative to absolute location of parent rect (#316) (cherry picked from commit 4e370e5439dc1583317acedcd78f172ed9cf87e9) --- Frontend/library/src/Inputs/TouchController.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Frontend/library/src/Inputs/TouchController.ts b/Frontend/library/src/Inputs/TouchController.ts index 83aec684..e2520933 100644 --- a/Frontend/library/src/Inputs/TouchController.ts +++ b/Frontend/library/src/Inputs/TouchController.ts @@ -152,16 +152,15 @@ export class TouchController implements ITouchController { if (!this.videoElementProvider.isVideoReady()) { return; } - const videoElementParent = - this.videoElementProvider.getVideoParentElement(); + const offset = this.videoElementProvider.getVideoParentElement().getBoundingClientRect(); const toStreamerHandlers = this.toStreamerMessagesProvider.toStreamerHandlers; for (let t = 0; t < touches.length; t++) { const numTouches = 1; // the number of touches to be sent this message const touch = touches[t]; - const x = touch.clientX - videoElementParent.offsetLeft; - const y = touch.clientY - videoElementParent.offsetTop; + const x = touch.clientX - offset.left; + const y = touch.clientY - offset.top; Logger.Log( Logger.GetStackTrace(), `F${this.fingerIds.get(touch.identifier)}=(${x}, ${y})`,