From 92f434ec074cb29e91c2460bdb7d3ebe36af72ed Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Mon, 9 Feb 2026 23:28:34 +0900 Subject: [PATCH] Invalidate map and geolocate only when visible Move the setTimeout and its contents inside the visible check so map.invalidateSize() and navigator.geolocation.getCurrentPosition(...) are only invoked when the map container is shown. This avoids unnecessary map invalidation and geolocation requests when the view is hidden; try/catch and the 0ms defer are preserved. --- WelsonJS.Augmented/WelsonJS.Launcher/editor.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/editor.html b/WelsonJS.Augmented/WelsonJS.Launcher/editor.html index d71aae2..dd8c33b 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/editor.html +++ b/WelsonJS.Augmented/WelsonJS.Launcher/editor.html @@ -367,17 +367,17 @@ containerRef.current.style.display = (visible ? "block" : "none"); // defer until after layout/display change - setTimeout(function () { - try { - map.invalidateSize(); - - if (visible) { + if (visible) { + setTimeout(function () { + try { + map.invalidateSize(); + navigator.geolocation.getCurrentPosition(pos => { mark(pos.coords.latitude, pos.coords.longitude, `My Location: (${pos.coords.latitude}, ${pos.coords.longitude})`); }); - } - } catch (e) {} - }, 0); + } catch (e) {} + }, 0); + } }, [visible]); return _e('div', { id: 'mapView', ref: containerRef });