From 43b0ff3e2e91ec11859d7c4e675e871df584311e Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Mon, 25 May 2020 18:56:46 +1000 Subject: [PATCH] Removed double click map reset due to conflicts with other interactions --- src/components/map/MapInteraction.js | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/components/map/MapInteraction.js b/src/components/map/MapInteraction.js index 9f4c562..0348c16 100644 --- a/src/components/map/MapInteraction.js +++ b/src/components/map/MapInteraction.js @@ -1,10 +1,4 @@ -import React, { - useRef, - useEffect, - useState, - useContext, - useCallback, -} from "react"; +import React, { useRef, useEffect, useState, useContext } from "react"; import { Box } from "theme-ui"; import { useGesture } from "react-use-gesture"; import ReactResizeDetector from "react-resize-detector"; @@ -42,7 +36,8 @@ function MapInteraction({ map, children, controls, selectedToolId }) { const stageTranslateRef = useRef({ x: 0, y: 0 }); const mapDragPositionRef = useRef({ x: 0, y: 0 }); - const resetMapTransform = useCallback(() => { + // Reset transform when map changes + useEffect(() => { const layer = mapLayerRef.current; if (map && layer) { const mapHeight = stageWidthRef.current * (map.height / map.width); @@ -59,11 +54,6 @@ function MapInteraction({ map, children, controls, selectedToolId }) { } }, [map]); - // Reset transform when map changes - useEffect(() => { - resetMapTransform(); - }, [map, resetMapTransform]); - // Convert a client space XY to be normalized to the map image function getMapDragPosition(xy) { const [x, y] = xy; @@ -210,7 +200,6 @@ function MapInteraction({ map, children, controls, selectedToolId }) { ref={containerRef} {...bind()} className="map" - onDoubleClick={resetMapTransform} >