From 21a4f62dcb41dc2eb9dfc92cd2a790e66f9dbaf5 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Thu, 21 Nov 2024 20:29:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20requestBeforeFrame=E4=B8=89=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E5=BE=AA=E7=8E=AF=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/render/item.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/core/render/item.ts b/src/core/render/item.ts index 2b31c42..62eb142 100644 --- a/src/core/render/item.ts +++ b/src/core/render/item.ts @@ -468,17 +468,21 @@ export abstract class RenderItem } RenderItem.ticker.add(() => { + // slice 是为了让函数里面的 request 进入下一帧执行 if (beforeFrame.length > 0) { - beforeFrame.forEach(v => v()); + const arr = beforeFrame.slice(); beforeFrame.splice(0); + arr.forEach(v => v()); } if (renderFrame.length > 0) { - renderFrame.forEach(v => v()); + const arr = renderFrame.slice(); renderFrame.splice(0); + arr.forEach(v => v()); } if (afterFrame.length > 0) { - afterFrame.forEach(v => v()); + const arr = afterFrame.slice(); afterFrame.splice(0); + arr.forEach(v => v()); } });