mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 08:02:39 +08:00
fix resizeObserver loop limit exceeded (#9159)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"ver": "2.0.14",
|
||||
"ver": "2.1.3",
|
||||
"importer": "fbx",
|
||||
"imported": true,
|
||||
"uuid": "1263d74c-8167-4928-91a6-4e2672411f47",
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user