UNPKG

@arco-design/web-vue

Version:

Arco Design Vue 2.0: A Vue.js 3 UI Library

20 lines (19 loc) 342 B
import { caf, raf } from "./raf.js"; function 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 { throttleByRaf };