| 42 | |
| 43 | // make a promise that resolves when the document is ready |
| 44 | export const waitForDocumentReady = () =>{ |
| 45 | if(typeof document !== 'undefined'){ |
| 46 | return new Promise((resolve, reject) => { |
| 47 | // if the page is ready, initialize p5 immediately |
| 48 | if (document.readyState === 'complete') { |
| 49 | resolve(); |
| 50 | // if the page is still loading, add an event listener |
| 51 | // and initialize p5 as soon as it finishes loading |
| 52 | } else { |
| 53 | window.addEventListener('load', resolve, false); |
| 54 | } |
| 55 | }); |
| 56 | } |
| 57 | }; |
| 58 | |
| 59 | // only load translations if we're using the full, un-minified library |
| 60 | export const waitingForTranslator = |