Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for black screen/dual draw calls #6

Open
MaudDibb opened this issue May 22, 2021 · 0 comments
Open

fix for black screen/dual draw calls #6

MaudDibb opened this issue May 22, 2021 · 0 comments

Comments

@MaudDibb
Copy link

You immediately call main() in mandelbrot.js before the page is fully loaded.. You could be getting null references to DOM elements that have not been loaded/initialized yet by the browser. Note that canvas elements always return null in getElementById or querySelector calls before the onload/DOMContentLoaded events.

Keep in mind the browser is still parsing the html/scripts (never mind loading external files, like mandelbrot.js). Nothing has been presented to the user, even if you put the script at the bottom of the html.

fix:

wait till the page has fully loaded.

modify the onload event to start rendering (you are already doing it with focusOnSubmit)
or switch out your call to main with this:
document.addEventListener('DOMContentLoaded', main);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant