resize-observer-polyfill
Version:
A polyfill for IntersectionObserver API
19 lines (17 loc) • 473 B
JavaScript
/**
* A shim for requestAnimationFrame which falls back
* to setTimeout if the first one is not supported.
*
* @returns {Number} Requests' identifier.
*/
export default (() => {
if (
window.requestAnimationFrame &&
typeof window.requestAnimationFrame === 'function'
) {
return window.requestAnimationFrame;
}
return callback => {
return setTimeout(() => callback(Date.now()), 1000 / 60);
};
})();