import { raf } from './vue/raf.mjs';

function throttleByAnimationFrame(fn) {
  let requestId;
  const later = (args) => () => {
    requestId = null;
    fn(...args);
  };
  const throttled = (...args) => {
    if (requestId == null)
      requestId = raf(later(args));
  };
  throttled.cancel = () => {
    raf.cancel(requestId);
    requestId = null;
  };
  return throttled;
}

export { throttleByAnimationFrame };
//# sourceMappingURL=throttleByAnimationFrame.mjs.map
