窗口 resize 兜底重绘图表

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
FANGKK
2026-09-10 17:19:56 +08:00
co-authored by Claude Opus 5
parent a183c0976b
commit 2792c7fc6b
+5 -3
View File
@@ -407,13 +407,15 @@ Promise.all([
}); });
let resizeTimer, lastWidth = 0; let resizeTimer, lastWidth = 0;
new ResizeObserver(entries => { function onResize() {
const w = Math.round(entries[0].contentRect.width); const w = document.querySelector('main').clientWidth;
if (w === lastWidth) return; if (w === lastWidth) return;
lastWidth = w; lastWidth = w;
clearTimeout(resizeTimer); clearTimeout(resizeTimer);
resizeTimer = setTimeout(drawCharts, 120); resizeTimer = setTimeout(drawCharts, 120);
}).observe(document.querySelector('main')); }
new ResizeObserver(onResize).observe(document.querySelector('main'));
addEventListener('resize', onResize);
</script> </script>
</body> </body>
</html> </html>