Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/awcross/images-loaded
Wait for images to load using promises. No dependencies.
https://github.com/awcross/images-loaded
browser dom images imagesloaded promise
Last synced: about 9 hours ago
JSON representation
Wait for images to load using promises. No dependencies.
- Host: GitHub
- URL: https://github.com/awcross/images-loaded
- Owner: awcross
- License: mit
- Created: 2017-01-05T23:57:04.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-27T07:17:26.000Z (over 6 years ago)
- Last Synced: 2024-08-11T08:50:28.769Z (3 months ago)
- Topics: browser, dom, images, imagesloaded, promise
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# images-loaded [![Build Status](https://travis-ci.org/awcross/images-loaded.svg?branch=master)](https://travis-ci.org/awcross/images-loaded)
> Wait for images to load using promises
## Install
```
$ npm install --save images-loaded
```## Usage
```js
const imagesLoaded = require('images-loaded');imagesLoaded('.container').then(elements => {
// images are hot and ready
});
```## API
### imagesLoaded(input [, options])
Returns a `Promise` when all images are done loading, with or without errors.
#### input
Type: `string` `Element` `NodeList`
A container or list of `elements` to watch for loading images.
#### options
Type: `Object`
##### props
Type: `string[]`
Default: `[]`Can be passed a list of DOM style camelCase properties to check. For example, `backgroundImage`, `borderImage`, etc.
##### attrs
Type: `string[]`
Default: `[]`Can be passed a list of attributes to check, such as `poster` in a video tag.
## Browser Support
If your browser supports [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) then 🎉. Check it at [caniuse.com](http://caniuse.com/#search=promises).
## License
MIT © [Alex Cross](https://alexcross.io)