Created
June 5, 2024 01:34
-
-
Save cecilemuller/f6841c271907521af88451aa96c44103 to your computer and use it in GitHub Desktop.
Async image complete
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function imageComplete(img) { | |
return new Promise((resolve) => { | |
if (img.complete) { | |
resolve(); | |
} else { | |
img.onerror = img.onload = () => { resolve() }; | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment