Skip to content

Commit

Permalink
fix(core): add requestidlecallback polyfill for safari (#5231)
Browse files Browse the repository at this point in the history
  • Loading branch information
EYHN committed Dec 8, 2023
1 parent 17d584b commit df43987
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/frontend/core/src/index.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
19 changes: 19 additions & 0 deletions packages/frontend/core/src/polyfill/request-idle-callback.ts
Original file line number Diff line number Diff line change
@@ -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);
};

0 comments on commit df43987

Please sign in to comment.