fix resizeObserver loop limit exceeded (#9159)

This commit is contained in:
黄森斌
2021-08-11 14:30:04 +08:00
committed by GitHub
parent 2f861cd38d
commit 8c4e850df4
2 changed files with 7 additions and 4 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
{
"ver": "2.0.14",
"ver": "2.1.3",
"importer": "fbx",
"imported": true,
"uuid": "1263d74c-8167-4928-91a6-4e2672411f47",
+6 -3
View File
@@ -129,9 +129,12 @@ const Elements = {
}
function observer() {
const { clientWidth, clientHeight } = panel.$.container;
const size = Math.round(Math.min((clientWidth - 40) / 4, (clientHeight - 40) / 3));
panel.$.container.style.setProperty('--size', `${size}px`);
cancelAnimationFrame(panel.animationFrameId);
panel.animationFrameId = window.requestAnimationFrame(() => {
const { clientWidth, clientHeight } = panel.$.container;
const size = Math.round(Math.min((clientWidth - 40) / 4, (clientHeight - 40) / 3));
panel.$.container.style.setProperty('--size', `${size}px`);
});
}
panel.resizeObserver = new window.ResizeObserver(observer);