From c0073db859c4e4e5767bc10b959ce7d618c64dcd Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Mon, 6 May 2024 13:35:18 -0500 Subject: [PATCH] fix touch events (#11265) --- web/src/components/timeline/SummaryTimeline.tsx | 6 +++--- web/src/hooks/use-draggable-element.ts | 4 ++-- web/src/views/live/LiveCameraView.tsx | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/web/src/components/timeline/SummaryTimeline.tsx b/web/src/components/timeline/SummaryTimeline.tsx index 54573c4f4..db1200546 100644 --- a/web/src/components/timeline/SummaryTimeline.tsx +++ b/web/src/components/timeline/SummaryTimeline.tsx @@ -187,7 +187,7 @@ export function SummaryTimeline({ e.stopPropagation(); let clientY; - if (e.nativeEvent instanceof TouchEvent) { + if ("TouchEvent" in window && e.nativeEvent instanceof TouchEvent) { clientY = e.nativeEvent.touches[0].clientY; } else if (e.nativeEvent instanceof MouseEvent) { clientY = e.nativeEvent.clientY; @@ -238,7 +238,7 @@ export function SummaryTimeline({ setIsDragging(true); let clientY; - if (e.nativeEvent instanceof TouchEvent) { + if ("TouchEvent" in window && e.nativeEvent instanceof TouchEvent) { clientY = e.nativeEvent.touches[0].clientY; } else if (e.nativeEvent instanceof MouseEvent) { clientY = e.nativeEvent.clientY; @@ -276,7 +276,7 @@ export function SummaryTimeline({ } e.stopPropagation(); let clientY; - if (e instanceof TouchEvent) { + if ("TouchEvent" in window && e instanceof TouchEvent) { clientY = e.touches[0].clientY; } else if (e instanceof MouseEvent) { clientY = e.clientY; diff --git a/web/src/hooks/use-draggable-element.ts b/web/src/hooks/use-draggable-element.ts index f18cae152..8cc61d451 100644 --- a/web/src/hooks/use-draggable-element.ts +++ b/web/src/hooks/use-draggable-element.ts @@ -87,7 +87,7 @@ function useDraggableElement({ const getClientYPosition = useCallback( (e: MouseEvent | TouchEvent) => { let clientY; - if (e instanceof TouchEvent) { + if ("TouchEvent" in window && e instanceof TouchEvent) { clientY = e.touches[0].clientY; } else if (e instanceof MouseEvent) { clientY = e.clientY; @@ -113,7 +113,7 @@ function useDraggableElement({ setIsDragging(true); let clientY; - if (e.nativeEvent instanceof TouchEvent) { + if ("TouchEvent" in window && e.nativeEvent instanceof TouchEvent) { clientY = e.nativeEvent.touches[0].clientY; } else if (e.nativeEvent instanceof MouseEvent) { clientY = e.nativeEvent.clientY; diff --git a/web/src/views/live/LiveCameraView.tsx b/web/src/views/live/LiveCameraView.tsx index bc27234bb..aef3453e7 100644 --- a/web/src/views/live/LiveCameraView.tsx +++ b/web/src/views/live/LiveCameraView.tsx @@ -98,7 +98,7 @@ export default function LiveCameraView({ camera }: LiveCameraViewProps) { let clientX; let clientY; - if (e.nativeEvent instanceof TouchEvent) { + if ("TouchEvent" in window && e.nativeEvent instanceof TouchEvent) { clientX = e.nativeEvent.touches[0].clientX; clientY = e.nativeEvent.touches[0].clientY; } else if (e.nativeEvent instanceof MouseEvent) {