Make imageLoaded adhere to its function signature

This commit is contained in:
Henrik Giesel 2021-04-13 00:42:09 +02:00
parent f4f0298378
commit 74a9d0b0a1

View File

@ -162,13 +162,12 @@ function allImagesLoaded(): Promise<void[]> {
}
function imageLoaded(img: HTMLImageElement): Promise<void> {
if (img.complete) {
return;
}
return new Promise((resolve) => {
img.addEventListener("load", () => resolve());
img.addEventListener("error", () => resolve());
});
return img.complete
? Promise.resolve()
: new Promise((resolve) => {
img.addEventListener("load", () => resolve());
img.addEventListener("error", () => resolve());
});
}
function scrollToAnswer(): void {