Utils.Loader Class
Async image loading utility
Item Index
Methods
Methods
loadImage
(
-
options
Allows to load a single image. One may pass a object of options as argument to specify parameters like a success and failure handler or the max number of attempts to load the image.
Parameters:
-
optionsObjectConfiguration object
-
urlStringURL of image to load
-
[loaded]Function optionalFunction to call on success
-
[failed]Function optionalFunction to call on failure
-
[always]Function optionalFunction to call regardless if success or failure
-
[cycles= 100]Number optionalMaximum number of attempts to load
-
Example:
import loadImage from './utils/loader';
loadImage({
url: 'path/to/image.jpg',
loaded: function (img) {
// success, img is the <img> node
},
failed: function (errorMsg) {
// process error message
},
always: function () {
// executed in any case (success or failure)
}
});
