You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What specific section or headline is this issue about?
"Example: Framing and Image" and "Art Gallery Example"
What information was incorrect, unhelpful, or incomplete?
The images aren't checked to see if they're loaded before drawing to the canvas(es). This means that sometimes only a few images draw, sometimes none of the images in the examples draw. The first time I loaded the page, the art gallery example didn't draw the pictures or frames. This issue also happens if you click 'play' to open the examples in the Playground.
What did you expect to see?
The pictures drawing properly to the canvas.
Do you have any supporting links, references, or citations?
No response
Do you have anything more you want to share?
I'm not sure if there is a better way to do this but, you could add an event listener to the window checking that it's been loaded before calling the draw() function?
bsmth
added
accepting PR
Feel free to open a PR to resolve this issue
and removed
needs triage
Triage needed by staff and/or partners. Automatically applied when an issue is opened.
labels
Jan 31, 2024
Thanks a lot for raising this one, I can also reproduce this. It might be good to use image.complete for this to check if an image is loaded and draw it, otherwise image.onload / addEventListener. I didn't have much luck with window.addEventListener("load"...
MDN URL
https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Using_images
What specific section or headline is this issue about?
"Example: Framing and Image" and "Art Gallery Example"
What information was incorrect, unhelpful, or incomplete?
The images aren't checked to see if they're loaded before drawing to the canvas(es). This means that sometimes only a few images draw, sometimes none of the images in the examples draw. The first time I loaded the page, the art gallery example didn't draw the pictures or frames. This issue also happens if you click 'play' to open the examples in the Playground.
What did you expect to see?
The pictures drawing properly to the canvas.
Do you have any supporting links, references, or citations?
No response
Do you have anything more you want to share?
I'm not sure if there is a better way to do this but, you could add an event listener to the window checking that it's been loaded before calling the draw() function?
window.addEventListener("load", (event) => {
draw();
});
MDN metadata
Page report details
en-us/web/api/canvas_api/tutorial/using_images
The text was updated successfully, but these errors were encountered: