bpms_site/.svn/pristine/d8/d89094f805fa34c4359c6c2ba35c5eedc81f15b1.svn-base
2025-11-02 16:38:49 +03:30

19 lines
617 B
Plaintext

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