Skip to content
Snippets Groups Projects
Commit 7a1c4086 authored by DD Liu's avatar DD Liu
Browse files

Fix on Mac Chrome

parent b6796889
No related branches found
No related tags found
No related merge requests found
...@@ -47,23 +47,27 @@ class GUI extends React.Component { ...@@ -47,23 +47,27 @@ class GUI extends React.Component {
this.audioEngine = new AudioEngine(); this.audioEngine = new AudioEngine();
this.props.vm.attachAudioEngine(this.audioEngine); this.props.vm.attachAudioEngine(this.audioEngine);
this.props.vm.initialized = true; this.props.vm.initialized = true;
const fontPromises = [];
if (document.fonts && const getFontPromises = () => {
typeof document.fonts.values === 'function' && const fontPromises = [];
typeof document.fonts.values()[Symbol.iterator] === 'function') { if (document.fonts &&
for (const fontFace of document.fonts.values()) { typeof document.fonts.values === 'function' &&
fontPromises.push(fontFace.loaded); typeof document.fonts.values()[Symbol.iterator] === 'function') {
fontFace.load(); for (const fontFace of document.fonts.values()) {
fontPromises.push(fontFace.loaded);
fontFace.load();
}
} }
} return fontPromises;
};
if (document.readyState === 'complete') { if (document.readyState === 'complete') {
Promise.all(fontPromises).then(this.loadProject); Promise.all(getFontPromises()).then(this.loadProject);
} else { } else {
document.onreadystatechange = () => { document.onreadystatechange = () => {
if (document.readyState !== 'complete') return; if (document.readyState !== 'complete') return;
document.onreadystatechange = null; document.onreadystatechange = null;
Promise.all(fontPromises).then(this.loadProject); Promise.all(getFontPromises()).then(this.loadProject);
}; };
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment