Skip to content

Commit

Permalink
cancelAnimationFrame based on id (ref #123)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphamorim committed Jun 21, 2022
1 parent 3e92a09 commit 1c2cb7d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/react-ape/renderer/core/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,20 @@ function renderApeQueue(
) {
if (apeContextGlobal && apeContextGlobal.renderQueue.length) {
const queue = apeContextGlobal.renderQueue;
let req;

const frame = () => {
requestAnimationFrame(frame);
req = requestAnimationFrame(frame);
const element = queue.shift();
element.render(apeContextGlobal, element.parentLayout);

requestAnimationFrame(frame);

if (!queue.length) {
cancelAnimationFrame(frame);
cancelAnimationFrame(req);
onFinish();
}
}
};
frame();
}
}
Expand Down

0 comments on commit 1c2cb7d

Please sign in to comment.