Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bahamas10/preloadimages.js
Preload images and callback when they are all ready
https://github.com/bahamas10/preloadimages.js
Last synced: 2 months ago
JSON representation
Preload images and callback when they are all ready
- Host: GitHub
- URL: https://github.com/bahamas10/preloadimages.js
- Owner: bahamas10
- Created: 2012-12-27T07:46:46.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2016-04-01T19:59:04.000Z (almost 9 years ago)
- Last Synced: 2024-05-08T19:53:58.113Z (8 months ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 37
- Watchers: 5
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
preloadimages.js
================Preload images and callback when they are all ready
Usage
-----``` html
```
You can call it with an array or object of images
``` js
preloadimages(['1.png', '2.png'], function(images) {
console.log(images);
// => [img, img]
});
```or
``` js
preloadimages({moon: 'moon.png', sun: 'sun.png'}, function(images) {
console.log(images);
// => {moon: img, sun: img}
});
```The function will callback when all of the images are loaded (or have failed
to load). The argument passed to the callback is either an array or object
to match the input, and if it is an array, it will be in the same order
as the input array.The items in the returned argument are `new Image()` elements.
License
-------MIT License