Skip to content

Commit

Permalink
fix: fix window
Browse files Browse the repository at this point in the history
  • Loading branch information
daybrush committed Dec 15, 2022
1 parent a11e915 commit d03be72
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,16 +531,18 @@ requestAnimationFrame((timestamp) => {
*/
export const requestAnimationFrame = /*#__PURE__*/(() => {
const firstTime = now();

const raf = IS_WINDOW
&& (window.requestAnimationFrame || (window as any).webkitRequestAnimationFrame
|| (window as any).mozRequestAnimationFrame || (window as any).msRequestAnimationFrame);

return raf ? (raf.bind(window) as (callback: FrameRequestCallback) => number) : ((callback: FrameRequestCallback) => {
const currTime = now();
const id = window.setTimeout(() => {
const id = setTimeout(() => {
callback(currTime - firstTime);
}, 1000 / 60);
return id;

return id as any as number;
});
})();

Expand Down

0 comments on commit d03be72

Please sign in to comment.