debian-mirror-gitlab/app/assets/javascripts/commons/polyfills/request_idle_callback.js

18 lines
398 B
JavaScript
Raw Normal View History

2018-11-18 11:00:15 +05:30
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);
};