From c1d4e09cb332ec16e19ea0b9f53b651835e61224 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Thu, 26 Mar 2020 15:43:52 +1100 Subject: [PATCH] Added a reset for the map when the source is changed --- src/components/Map.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/components/Map.js b/src/components/Map.js index 6d41743..0d3ad8a 100644 --- a/src/components/Map.js +++ b/src/components/Map.js @@ -72,6 +72,12 @@ function Map({ ); } + // Reset map transform when map changes + useEffect(() => { + setMapTranslate({ x: 0, y: 0 }); + setMapScale(1); + }, [mapSource]); + const mapRef = useRef(null); const rows = mapData && mapData.rows; const tokenSizePercent = (1 / rows) * 100;