throttle-raf.js 274 B

12345678910111213141516
  1. (function (callback) {
  2. var throttled = false;
  3. return function () {
  4. if (throttled) return;
  5. throttled = true;
  6. var args = arguments;
  7. window.requestAnimationFrame(function () {
  8. throttled = false;
  9. callback.apply(null, arguments);
  10. })
  11. }
  12. })