UNPKG

hongluan-ui

Version:
26 lines (23 loc) 600 B
import './browser.mjs'; import { isClient } from '@vueuse/core'; const rAF = (fn) => isClient ? window.requestAnimationFrame(fn) : setTimeout(fn, 16); const cAF = (handle) => isClient ? window.cancelAnimationFrame(handle) : clearTimeout(handle); const throttleByRaf = (cb) => { let timer = 0; const throttle = (...args) => { if (timer) { cAF(timer); } timer = rAF(() => { cb(...args); timer = 0; }); }; throttle.cancel = () => { cAF(timer); timer = 0; }; return throttle; }; export { cAF, rAF, throttleByRaf }; //# sourceMappingURL=raf.mjs.map