From e4b97be54ed9db4c9d8303196878f6afdd7b5775 Mon Sep 17 00:00:00 2001 From: CN-JS-HuiBai Date: Mon, 6 Apr 2026 02:20:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BB=98=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/js/app.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) 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()); } } });