We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 461ee5a commit f272d40Copy full SHA for f272d40
src/raf.ts
@@ -1,9 +1,10 @@
1
-let raf = (fn: () => void) => +setTimeout(fn, 16);
+let raf = (callback: FrameRequestCallback) => +setTimeout(callback, 16);
2
let caf = (num: number) => clearTimeout(num);
3
4
-if (typeof window !== 'undefined') {
5
- raf = requestAnimationFrame;
6
- caf = cancelAnimationFrame;
+if (typeof window !== 'undefined' && 'requestAnimationFrame' in window) {
+ raf = (callback: FrameRequestCallback) =>
+ window.requestAnimationFrame(callback);
7
+ caf = (handle: number) => window.cancelAnimationFrame(handle);
8
}
9
10
export default function wrapperRaf(callback: () => void): number {
0 commit comments