gitlab-org--gitlab-foss/app/assets/javascripts/commons/polyfills/request_idle_callback.js
2018-08-08 02:50:01 +00:00

17 lines
398 B
JavaScript

window.requestIdleCallback =
window.requestIdleCallback ||
function requestShim(cb) {
const start = Date.now();
return setTimeout(() => {
cb({
didTimeout: false,
timeRemaining: () => Math.max(0, 50 - (Date.now() - start)),
});
}, 1);
};
window.cancelIdleCallback =
window.cancelIdleCallback ||
function cancelShim(id) {
clearTimeout(id);
};