Merge pull request #687 from redbirdly/main

fix loading using window.addEventListener
This commit is contained in:
slweeb 2024-06-16 13:55:04 -04:00 committed by GitHub
commit ba3a1cad1b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 17 deletions

View File

@ -265,20 +265,9 @@ elements.plasma.tick = function(pixel) {
lightmap[y][x] = { color: plasmaColor }; lightmap[y][x] = { color: plasmaColor };
}; };
// Wait for loading window.addEventListener('load', function() {
let i = 0; initializeLightmap(width, height);
let interval = setInterval(() => { });
if (typeof width !== 'undefined') {
clearInterval(interval);
initializeLightmap(width, height);
}
i += 1;
// if width is not defined for 3 seconds or longer, it's probably broken, so it will just try run the function anyways to see the error
if (i >= 30) {
clearInterval(interval);
initializeLightmap(width, height);
}
}, 100);
// Add code to functions instead of replacing them // Add code to functions instead of replacing them
let originalTick = tick; let originalTick = tick;

View File

@ -265,9 +265,9 @@ elements.plasma.tick = function(pixel) {
lightmap[y][x] = { color: plasmaColor }; lightmap[y][x] = { color: plasmaColor };
}; };
// Wait for loading window.addEventListener('load', function() {
// if it loads too soon then width will be undefined initializeLightmap(width, height);
setTimeout(() => { initializeLightmap(width, height); }, 700); });
// Add code to functions instead of replacing them // Add code to functions instead of replacing them
let originalTick = tick; let originalTick = tick;