Files
iD/modules/id.js
Bryan Housel a8c6ab4d67 Move requestIdleCallback polyfill to id.js, remove utilIdleWorker
`utilIdleWorker` was only used one place.
It just processes a list in an idle callback.

I'm working towards removing the util functions for handling idle work.
We can still do `requestIdleCallback` work throughout the code, however
each place we use it needs to have a strategy for cancellation, which
the existing util functions don't allow for.
2019-05-16 21:19:25 -04:00

26 lines
679 B
JavaScript

import 'browser-polyfills';
import 'abortcontroller-polyfill/dist/polyfill-patch-fetch';
// polyfill requestIdleCallback
window.requestIdleCallback = window.requestIdleCallback ||
function(cb) {
var start = Date.now();
return window.requestAnimationFrame(function() {
cb({
didTimeout: false,
timeRemaining: function() {
return Math.max(0, 50 - (Date.now() - start));
}
});
});
};
window.cancelIdleCallback = window.cancelIdleCallback ||
function(id) {
window.cancelAnimationFrame(id);
};
import * as iD from './index';
window.iD = iD;