From 3e3340db169be90acfc63b550f386f64bf22f3b8 Mon Sep 17 00:00:00 2001 From: Owen Moogk Date: Tue, 19 Aug 2025 13:14:02 -0400 Subject: [PATCH] fix: Add check if TouchEvent is defined on browser --- src/ReactCompareImage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ReactCompareImage.tsx b/src/ReactCompareImage.tsx index 91a9bab..23ef192 100644 --- a/src/ReactCompareImage.tsx +++ b/src/ReactCompareImage.tsx @@ -134,7 +134,7 @@ const ReactCompareImage = (props: ReactCompareImageProps) => { const rect = containerRef.current.getBoundingClientRect() let clientX: number let clientY: number - if (e instanceof TouchEvent) { + if (window.TouchEvent && e instanceof TouchEvent) { const touch = e.touches[0] invariant(touch) clientX = touch.clientX