diff options
Diffstat (limited to 'app/assets/javascripts/commons/polyfills/request_idle_callback.js')
-rw-r--r-- | app/assets/javascripts/commons/polyfills/request_idle_callback.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/app/assets/javascripts/commons/polyfills/request_idle_callback.js b/app/assets/javascripts/commons/polyfills/request_idle_callback.js new file mode 100644 index 00000000000..2356569d06e --- /dev/null +++ b/app/assets/javascripts/commons/polyfills/request_idle_callback.js @@ -0,0 +1,17 @@ +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); + }; |