img-async
Wraps img for Promises.
var img =
This becomes more useful when you take advantage of other promise features. For example, a complete preloader with Bluebird could look like this:
var Promise = var imgAsync = var {} module { progress = progress||noop var count = 0 return Promise}
And it could be used like so:
//update progress bar.. { console} //optionally specify a concurrency limit
Promise implementation
Uses Bluebird by default, but you can provide a different implementation like so:
var Promise = //returns the promisified functionvar qImgAsync = Promise
Usage
imgAsync(path[, options])
Returns a promise of the image load which resolves with that element when the image is loaded, or rejects when the image was not able to load.
Optional parameters for options
:
crossOrigin
the crossOrigin string
e.g.
'foo.gif' crossOrigin: 'Anonymous'
License
MIT, see LICENSE.md for details.