Fix bug with map transform resetting when a new resolution is loaded

This commit is contained in:
Mitchell McCaffrey 2020-07-17 17:06:40 +10:00
parent 5ba4817398
commit 5e6f3537b4

View File

@ -76,7 +76,7 @@ function MapInteraction({
// Reset transform when map changes // Reset transform when map changes
useEffect(() => { useEffect(() => {
const layer = mapLayerRef.current; const layer = mapLayerRef.current;
if (map && layer) { if (map && layer && !mapLoaded) {
const mapHeight = stageWidthRef.current * (map.height / map.width); const mapHeight = stageWidthRef.current * (map.height / map.width);
const newTranslate = { const newTranslate = {
x: 0, x: 0,
@ -89,7 +89,7 @@ function MapInteraction({
setStageScale(1); setStageScale(1);
} }
}, [map]); }, [map, mapLoaded]);
const pinchPreviousDistanceRef = useRef(); const pinchPreviousDistanceRef = useRef();
const pinchPreviousOriginRef = useRef(); const pinchPreviousOriginRef = useRef();