fix: added a polyfill for requestIdleCallback to support safari browser

This commit is contained in:
Kavin Venkatachalam 2024-05-28 18:27:49 +05:30
parent 84f70ac208
commit 12c4a0211d
2 changed files with 21 additions and 0 deletions

View file

@ -52,6 +52,7 @@ import { BoundedBox } from '@/Editor/Components/BoundedBox/BoundedBox';
import { isPDFSupported } from '@/_helpers/appUtils';
import { resolveWidgetFieldValue } from '@/_helpers/utils';
import { useEditorStore } from '@/_stores/editorStore';
import './requestIdleCallbackPolyfill';
export function memoizeFunction(func) {
const cache = new Map();

View file

@ -0,0 +1,20 @@
// Polyfill for window.requestIdleCallback to support Safari browser
window.requestIdleCallback =
window.requestIdleCallback ||
function (cb) {
var 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);
};