Test migration to jest by hand
Apparently using regular expressions is way easier.
This commit is contained in:
21
test/recordAnimationFrames/recordAnimationFrames.js
Normal file
21
test/recordAnimationFrames/recordAnimationFrames.js
Normal file
@ -0,0 +1,21 @@
|
||||
const recordAnimationFrames = (callback, autoStart = true) => {
|
||||
let running = true,
|
||||
raf;
|
||||
const stop = () => {
|
||||
running = false;
|
||||
cancelAnimationFrame(raf);
|
||||
};
|
||||
const start = () => {
|
||||
running = true;
|
||||
run();
|
||||
};
|
||||
const run = () => {
|
||||
raf = requestAnimationFrame(() => {
|
||||
callback();
|
||||
if (running) run();
|
||||
|
||||
};
|
||||
if (autoStart) start();
|
||||
return { start, stop };
|
||||
};
|
||||
module.exports = recordAnimationFrames;
|
||||
Reference in New Issue
Block a user