mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-01 22:32:26 +03:00
fix(core): add requestidlecallback polyfill for safari (#5231)
This commit is contained in:
parent
17d584b336
commit
df439877bd
@ -1,5 +1,6 @@
|
||||
import './polyfill/ses-lockdown';
|
||||
import './polyfill/intl-segmenter';
|
||||
import './polyfill/request-idle-callback';
|
||||
|
||||
import { WorkspaceFallback } from '@affine/component/workspace';
|
||||
import { assertExists } from '@blocksuite/global/utils';
|
||||
|
19
packages/frontend/core/src/polyfill/request-idle-callback.ts
Normal file
19
packages/frontend/core/src/polyfill/request-idle-callback.ts
Normal file
@ -0,0 +1,19 @@
|
||||
window.requestIdleCallback =
|
||||
window.requestIdleCallback ||
|
||||
function (cb) {
|
||||
const start = Date.now();
|
||||
return setTimeout(function () {
|
||||
cb({
|
||||
didTimeout: false,
|
||||
timeRemaining: function () {
|
||||
return Math.max(0, 50 - (Date.now() - start));
|
||||
},
|
||||
});
|
||||
}, 1);
|
||||
};
|
||||
|
||||
window.cancelIdleCallback =
|
||||
window.cancelIdleCallback ||
|
||||
function (id) {
|
||||
clearTimeout(id);
|
||||
};
|
Loading…
Reference in New Issue
Block a user