Skip to content

Commit 1c2cb7d

Browse files
committed
cancelAnimationFrame based on id (ref #123)
1 parent 3e92a09 commit 1c2cb7d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/react-ape/renderer/core/render.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,20 @@ function renderApeQueue(
2323
) {
2424
if (apeContextGlobal && apeContextGlobal.renderQueue.length) {
2525
const queue = apeContextGlobal.renderQueue;
26+
let req;
27+
2628
const frame = () => {
27-
requestAnimationFrame(frame);
29+
req = requestAnimationFrame(frame);
2830
const element = queue.shift();
2931
element.render(apeContextGlobal, element.parentLayout);
3032

3133
requestAnimationFrame(frame);
3234

3335
if (!queue.length) {
34-
cancelAnimationFrame(frame);
36+
cancelAnimationFrame(req);
3537
onFinish();
3638
}
37-
}
39+
};
3840
frame();
3941
}
4042
}

0 commit comments

Comments
 (0)