API Docs for:
Show:

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:

  • options Object

    Configuration object

    • url String

      URL of image to load

    • [loaded] Function optional

      Function to call on success

    • [failed] Function optional

      Function to call on failure

    • [always] Function optional

      Function to call regardless if success or failure

    • [cycles= 100] Number optional

      Maximum 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)
    }
});