Skip to content

Commit 93635a2

Browse files
committed
update jest window prop
1 parent 1c2cb7d commit 93635a2

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,16 @@ function renderApeQueue(
2323
) {
2424
if (apeContextGlobal && apeContextGlobal.renderQueue.length) {
2525
const queue = apeContextGlobal.renderQueue;
26-
let req;
2726

27+
let reqId;
2828
const frame = () => {
29-
req = requestAnimationFrame(frame);
30-
const element = queue.shift();
31-
element.render(apeContextGlobal, element.parentLayout);
29+
if (queue.length) {
30+
const element = queue.shift();
31+
element.render(apeContextGlobal, element.parentLayout);
3232

33-
requestAnimationFrame(frame);
34-
35-
if (!queue.length) {
36-
cancelAnimationFrame(req);
33+
reqId = requestAnimationFrame(frame);
34+
} else {
35+
cancelAnimationFrame(reqId);
3736
onFinish();
3837
}
3938
};

tests/setup.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const jsdom = new JSDOM('<!doctype html><html><body></body></html>', {
66
url: 'http://localhost/',
77
});
88
const { window } = jsdom;
9+
window.requestAnimationFrame = (cb) => window.setTimeout(cb, 1000 / 60);
10+
window.cancelAnimationFrame = () => null;
911

1012
function copyProps(src, target) {
1113
const props = Object.getOwnPropertyNames(src)

0 commit comments

Comments
 (0)