mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
fix(font load): fix when font load timeout
This commit is contained in:
parent
d355366724
commit
24688ac608
@ -109,8 +109,18 @@ export class DocumentCloner {
|
||||
return Promise.reject(`Error finding the ${this.referenceElement.nodeName} in the cloned document`);
|
||||
}
|
||||
|
||||
if (documentClone.fonts && documentClone.fonts.status === 'loading' && documentClone.fonts.ready) {
|
||||
await documentClone.fonts.ready;
|
||||
if (documentClone.fonts && documentClone.fonts.status === 'loading') {
|
||||
return Promise.race([
|
||||
documentClone.fonts.ready,
|
||||
new Promise<void>((resolve) => {
|
||||
const fontLoadTimer = setInterval(() => {
|
||||
if (documentClone.fonts.status === 'loaded') {
|
||||
clearInterval(fontLoadTimer);
|
||||
resolve();
|
||||
}
|
||||
}, 1000);
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
||||
if (/(AppleWebKit)/g.test(navigator.userAgent)) {
|
||||
|
Loading…
Reference in New Issue
Block a user