'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var raf = require('./raf.js');

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

exports.default = throttleByAnimationFrame;
//# sourceMappingURL=throttleByAnimationFrame.js.map
