优化绘图
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user