Created
December 16, 2016 10:42
-
-
Save tuckbloor/8e49cd21dab48c728329d479bd8007e8 to your computer and use it in GitHub Desktop.
pre-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
| //preload images for canvas on tag design | |
| function preloadImages(srcs) { | |
| if (!preloadImages.cache) { | |
| preloadImages.cache = []; | |
| } | |
| var img; | |
| for (var i = 0; i < srcs.length; i++) { | |
| img = new Image(); | |
| img.src = srcs[i]; | |
| preloadImages.cache.push(img); | |
| } | |
| } | |
| // then to call it, you would use this | |
| var imageSrcs = ["/images/flag.jpg", "/images/tag-logo.png", "/images/ce.jpg", "/images/flow_arrow_v.jpg", "/images/flow_arrow_u.jpg", "/images/flow_arrow_h.jpg", "/images/eac.jpg"]; | |
| preloadImages(imageSrcs); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment