From 8e6f0739cd37a0304b46f62f33aedaaa0fa3e43e Mon Sep 17 00:00:00 2001 From: Julian Boilen Date: Sat, 21 Dec 2024 15:13:55 -0500 Subject: [PATCH] CLICK in the hit area, but allow panning everywhere --- frontend/src/screens/App/screens/ViewerPane/index.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/src/screens/App/screens/ViewerPane/index.tsx b/frontend/src/screens/App/screens/ViewerPane/index.tsx index 7af6b32d..ff1b084e 100644 --- a/frontend/src/screens/App/screens/ViewerPane/index.tsx +++ b/frontend/src/screens/App/screens/ViewerPane/index.tsx @@ -38,9 +38,11 @@ const ZOOM_PAN_PINCH_EVENT_TYPES = [ 'mouseenter', 'keyup', 'keydown', - 'click', + // 'click', ] as const; +const HIT_AREA_EVENT_TYPES = ['pointerdown', 'click'] as const; + const INITIAL_SCALE = 1.05; export default function ViewerPane({ @@ -64,11 +66,13 @@ export default function ViewerPane({ // The overlay is on top and normally would capture all events, but we also need the zooming wrapper to see these events // This hook forwards events from the overlay to the wrapper useEventForwarding( - zoomHitAreaEl, + overlayRef.current, wrapperComponent, ZOOM_PAN_PINCH_EVENT_TYPES ); + useEventForwarding(zoomHitAreaEl, wrapperComponent, HIT_AREA_EVENT_TYPES); + // Reset the transform when the photo changes useEffect(() => { if (wrapperRef.current) wrapperRef.current.resetTransform();