Skip to content

Commit

Permalink
Merge pull request #81 from branberry/animationframe-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ckifer committed Oct 10, 2023
2 parents af6f83f + c3fdcb9 commit eecb6b0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/setRafTimeout.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
function safeRequestAnimationFrame(callback) {
if (typeof requestAnimationFrame !== 'undefined') requestAnimationFrame(callback);
}

export default function setRafTimeout(callback, timeout = 0) {
let currTime = -1;

Expand All @@ -10,7 +14,7 @@ export default function setRafTimeout(callback, timeout = 0) {
callback(now);
currTime = -1;
} else {
requestAnimationFrame(shouldUpdate);
safeRequestAnimationFrame(shouldUpdate);
}
};

Expand Down

0 comments on commit eecb6b0

Please sign in to comment.