Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hughsk/image-loaded
Call a callback when an image has loaded
https://github.com/hughsk/image-loaded
Last synced: 12 days ago
JSON representation
Call a callback when an image has loaded
- Host: GitHub
- URL: https://github.com/hughsk/image-loaded
- Owner: hughsk
- Created: 2013-04-04T06:42:10.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-04-04T13:09:02.000Z (over 11 years ago)
- Last Synced: 2024-10-17T16:41:12.783Z (22 days ago)
- Language: JavaScript
- Size: 184 KB
- Stars: 7
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# image-loaded #
[![browser support](https://ci.testling.com/hughsk/image-loaded.png)](https://ci.testling.com/hughsk/image-loaded)
Call a callback when an image has loaded - adapted from
[desandro/imagesloaded](https://github.com/desandro/imagesloaded),
minus the jQuery.## Installation ##
Using [npm](http://npmjs.org/) and [browserify](http://browserify.org/):
``` bash
npm install image-loaded
```## Usage ##
**require('image-loaded')(image, callback)**
``` javascript
var loaded = require('image-loaded')
var image = document.getElementById('hidden-image')loaded(image, function(err, alreadyLoaded) {
// image is loaded!
})
```If the image was already loaded beforehand, the callback will be called
instantly with the second argument set to `true`. Otherwise this will be
`false`.