From 1937c6a5d88bd887d47d7f73d81836a3d7f46e81 Mon Sep 17 00:00:00 2001 From: Anton Vasilev Date: Sat, 5 Aug 2023 10:53:36 +0500 Subject: [PATCH] I have a plenty sentry errors indicated that Chrome WebView users faced with issue that targetTouch is undefined. I don't know the reason and can't repeat this issue by myself. --- src/events.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/events.ts b/src/events.ts index 146a75dd..4a2f446a 100644 --- a/src/events.ts +++ b/src/events.ts @@ -680,8 +680,8 @@ export class Events { private getEventClientYX(ev, name) { const targetTouch = ev.type === name && ev.targetTouches && (ev.targetTouches[0] || ev.changedTouches[0]); - const clientY: number = ev.type === name ? targetTouch.clientY : ev.clientY; - const clientX: number = ev.type === name ? targetTouch.clientX : ev.clientX; + const clientY: number = (ev.type === name && targetTouch) ? targetTouch.clientY : ev.clientY; + const clientX: number = (ev.type === name && targetTouch) ? targetTouch.clientX : ev.clientX; const timeDiff: number = (Date.now()) - (this.steps[this.steps.length - 1]?.time || 0); const distanceY: number = Math.abs(clientY - (this.steps[this.steps.length - 1]?.posY || 0)); const velocityY: number = distanceY / timeDiff;