raf.ts 290 B

123456789
  1. import { isClient } from '@vueuse/core'
  2. export const rAF = (fn: () => void) =>
  3. isClient
  4. ? window.requestAnimationFrame(fn)
  5. : (setTimeout(fn, 16) as unknown as number)
  6. export const cAF = (handle: number) =>
  7. isClient ? window.cancelAnimationFrame(handle) : clearTimeout(handle)