0
JavaScript
i need help in JavaScript. Why does the image appear only after the second click on the button? https://code.sololearn.com/WfsIx9O5jqpu/?ref=app
3 Answers
+ 2
you could do same much simpler (and shorter) by drawing your images in the button event listener handler functions, rather than using requestAnimationFrame and flags ;P
you also could assign the result of getElementsByTagName to a variable to not query twice for them...
anyway, to avoid the loading time delay you could preload both images and show the page to user only once they are ready to be used:
https://code.sololearn.com/WWl7YvbuhvvC/?ref=app
+ 1
It works!
Click once and wait for some seconds the image will load.
+ 1
Thanks dude, I already solved this problem myself. About 9 minutes ago.