UNPKG

quasar

Version:

Build high-performance VueJS user interfaces (SPA, PWA, SSR, Mobile and Desktop) in record time

23 lines (18 loc) 422 B
export default function (fn) { let wait = false, frame, callArgs function debounced (/* ...args */) { callArgs = arguments if (wait === true) { return } wait = true frame = requestAnimationFrame(() => { fn.apply(this, callArgs) callArgs = void 0 wait = false }) } debounced.cancel = () => { window.cancelAnimationFrame(frame) wait = false } return debounced }