优化绘图

This commit is contained in:
CN-JS-HuiBai
2026-04-06 02:20:32 +08:00
parent 43d2b80fb2
commit e4b97be54e

View File

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