Created
January 9, 2022 00:56
-
-
Save Magoninho/5ecf93a3bf39014d47f0c8b3b11206cb to your computer and use it in GitHub Desktop.
a nice hand function to load images
This file contains hidden or 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
async function loadImageFromUrl(url: string): Promise<HTMLImageElement> { | |
return new Promise(resolve => { | |
const img = new Image(); | |
img.onload = () => { | |
resolve(img); | |
} | |
img.src = url; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment