This commit is contained in:
2026-01-05 12:47:14 +08:00
commit 1fc846fae3
1614 changed files with 162035 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
const _window = window as any
export const inBrowser = typeof window !== 'undefined'
function requestAniFrame() {
if (typeof _window !== 'undefined') {
return (
_window.requestAnimationFrame
|| _window.webkitRequestAnimationFrame
|| function (callback: () => void) {
_window.setTimeout(callback, 1000 / 60)
}
)
}
else {
return function (callback: () => void) {
setTimeout(callback, 1000 / 60)
}
}
}
export function cancelRaf(id: number) {
if (inBrowser)
cancelAnimationFrame(id)
else
clearTimeout(id)
}
export default requestAniFrame()