bd6c53f7ec8ae55c78622e3d79c28ee107a3b40c7b09a3954e70c66448a5e8745f1d8bee59f8901e4f983bc92dd5ad25fb88abde8faf6096440af91fc64b44 635 B

123456789101112131415161718
  1. import global from './global.js';
  2. /**
  3. * A shim for the requestAnimationFrame which falls back to the setTimeout if
  4. * first one is not supported.
  5. *
  6. * @returns {number} Requests' identifier.
  7. */
  8. export default (() => {
  9. if (typeof requestAnimationFrame === 'function') {
  10. // It's required to use a bounded function because IE sometimes throws
  11. // an "Invalid calling object" error if rAF is invoked without the global
  12. // object on the left hand side.
  13. return requestAnimationFrame.bind(global);
  14. }
  15. return callback => setTimeout(() => callback(Date.now()), 1000 / 60);
  16. })();