fix: requestBeforeFrame三函数循环调用

This commit is contained in:
unanmed 2024-11-21 20:29:15 +08:00
parent 582fdf5fe9
commit 21a4f62dcb

View File

@ -468,17 +468,21 @@ export abstract class RenderItem<E extends ERenderItemEvent = ERenderItemEvent>
} }
RenderItem.ticker.add(() => { RenderItem.ticker.add(() => {
// slice 是为了让函数里面的 request 进入下一帧执行
if (beforeFrame.length > 0) { if (beforeFrame.length > 0) {
beforeFrame.forEach(v => v()); const arr = beforeFrame.slice();
beforeFrame.splice(0); beforeFrame.splice(0);
arr.forEach(v => v());
} }
if (renderFrame.length > 0) { if (renderFrame.length > 0) {
renderFrame.forEach(v => v()); const arr = renderFrame.slice();
renderFrame.splice(0); renderFrame.splice(0);
arr.forEach(v => v());
} }
if (afterFrame.length > 0) { if (afterFrame.length > 0) {
afterFrame.forEach(v => v()); const arr = afterFrame.slice();
afterFrame.splice(0); afterFrame.splice(0);
arr.forEach(v => v());
} }
}); });