Skip to content

Commit 7a1c408

Browse files
author
DD Liu
committed
Fix on Mac Chrome
1 parent b679688 commit 7a1c408

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/containers/gui.jsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,27 @@ class GUI extends React.Component {
4747
this.audioEngine = new AudioEngine();
4848
this.props.vm.attachAudioEngine(this.audioEngine);
4949
this.props.vm.initialized = true;
50-
const fontPromises = [];
51-
if (document.fonts &&
52-
typeof document.fonts.values === 'function' &&
53-
typeof document.fonts.values()[Symbol.iterator] === 'function') {
54-
for (const fontFace of document.fonts.values()) {
55-
fontPromises.push(fontFace.loaded);
56-
fontFace.load();
50+
51+
const getFontPromises = () => {
52+
const fontPromises = [];
53+
if (document.fonts &&
54+
typeof document.fonts.values === 'function' &&
55+
typeof document.fonts.values()[Symbol.iterator] === 'function') {
56+
for (const fontFace of document.fonts.values()) {
57+
fontPromises.push(fontFace.loaded);
58+
fontFace.load();
59+
}
5760
}
58-
}
61+
return fontPromises;
62+
};
5963

6064
if (document.readyState === 'complete') {
61-
Promise.all(fontPromises).then(this.loadProject);
65+
Promise.all(getFontPromises()).then(this.loadProject);
6266
} else {
6367
document.onreadystatechange = () => {
6468
if (document.readyState !== 'complete') return;
6569
document.onreadystatechange = null;
66-
Promise.all(fontPromises).then(this.loadProject);
70+
Promise.all(getFontPromises()).then(this.loadProject);
6771
};
6872
}
6973
}

0 commit comments

Comments
 (0)