From 5e6f3537b402977bb25d42dd2e894658486235c8 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Fri, 17 Jul 2020 17:06:40 +1000 Subject: [PATCH] Fix bug with map transform resetting when a new resolution is loaded --- src/components/map/MapInteraction.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/map/MapInteraction.js b/src/components/map/MapInteraction.js index 671f5a9..f49d6f9 100644 --- a/src/components/map/MapInteraction.js +++ b/src/components/map/MapInteraction.js @@ -76,7 +76,7 @@ function MapInteraction({ // Reset transform when map changes useEffect(() => { const layer = mapLayerRef.current; - if (map && layer) { + if (map && layer && !mapLoaded) { const mapHeight = stageWidthRef.current * (map.height / map.width); const newTranslate = { x: 0, @@ -89,7 +89,7 @@ function MapInteraction({ setStageScale(1); } - }, [map]); + }, [map, mapLoaded]); const pinchPreviousDistanceRef = useRef(); const pinchPreviousOriginRef = useRef();