dist/es5/Loader.js
function onReady(aImage, aCallback, aErrorCallback) {

        // if this didn't resolve in a full second, we presume the Image is corrupt

        var MAX_ITERATIONS = 60;
        var iterations = 0;

        function readyCheck() {

            if (Loader.isReady(aImage)) {
                aCallback();
            } else if (++iterations === MAX_ITERATIONS) {

                if (typeof aErrorCallback === "function") aErrorCallback();

                console.warn("Image could not be resolved. This shouldn't occur.");
            } else {
                // requestAnimationFrame preferred over a timeout as
                // browsers will fire this when the DOM is actually ready (e.g. Image is rendered)
                window.requestAnimationFrame(readyCheck);
            }
        }
        readyCheck();
    }
function onReady(aImage, aCallback, aErrorCallback) {

        // if this didn't resolve in a full second, we presume the Image is corrupt

        var MAX_ITERATIONS = 60;
        var iterations = 0;

        function readyCheck() {

            if (Loader.isReady(aImage)) {
                aCallback();
            } else if (++iterations === MAX_ITERATIONS) {

                if (typeof aErrorCallback === "function") aErrorCallback();

                console.warn("Image could not be resolved. This shouldn't occur.");
            } else {
                // requestAnimationFrame preferred over a timeout as
                // browsers will fire this when the DOM is actually ready (e.g. Image is rendered)
                window.requestAnimationFrame(readyCheck);
            }
        }
        readyCheck();
    }
function onReady ( aImage , aCallback , aErrorCallback ) { // if this didn't resolve in a full second, we presume the Image is corrupt var MAX_ITERATIONS = 60 ; var iterations = 0 ; function readyCheck ( ) { if ( Loader . isReady ( aImage ) ) { aCallback ( ) ; } else if ( ++ iterations === MAX_ITERATIONS ) { if ( typeof aErrorCallback === "function" ) aErrorCallback ( ) ; console . warn ( "Image could not be resolved. This shouldn't occur." ) ; } else { // requestAnimationFrame preferred over a timeout as // browsers will fire this when the DOM is actually ready (e.g. Image is rendered) window . requestAnimationFrame ( readyCheck ) ; } } readyCheck ( ) ; }
Executes given callback when given Image is actually ready for rendering
If the image was ready when this function was called, execution is synchronous
if not it will be made asynchronous via RAF delegation

@public
@param {Image} aImage
@param {!Function} aCallback
@param {!Function=} aErrorCallback optional callback to fire if Image is never ready
Executes given callback when given Image is actually ready for rendering If the image was ready when this function was called execution is synchronous if not it will be made asynchronous via RAF delegation