diff --git a/public/js/app.js b/public/js/app.js index b1aec11..bcc43a5 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -213,17 +213,10 @@ dom.globeCard.classList.toggle('expanded'); dom.btnExpandGlobe.classList.toggle('active'); if (myMap2D) { - // Immediately hide and then show map or just resize? - // ECharts can sometimes glitch when position:fixed + transform happens. - // Since we removed transform, resize should be smoother. - myMap2D.resize(); - - let resizeCount = 0; - const timer = setInterval(() => { + // Single deferred resize after the DOM has applied the new layout + requestAnimationFrame(() => { myMap2D.resize(); - resizeCount++; - if (resizeCount >= 5) clearInterval(timer); - }, 100); + }); } }); } @@ -237,7 +230,7 @@ if (dom.globeCard && dom.globeCard.classList.contains('expanded')) { dom.globeCard.classList.remove('expanded'); dom.btnExpandGlobe.classList.remove('active'); - if (myMap2D) setTimeout(() => myMap2D.resize(), 100); + if (myMap2D) requestAnimationFrame(() => myMap2D.resize()); } } });