views:

21

answers:

0

Trying to get a spinner gif to appear at the beginning of an image loading, then disappear when the image is loaded. Works almost everytime, but some times it will keep on displaying and won't go. Any help? (Relevant function showed)

$.loadImage = function(imgSrc,imageList){
    $("#loading-graphic").fadeIn('slow');
    $.clearImage();
    if(overlayActive == false){
        $.showOverlay();
        }
    var myImage = new Image();
    myImage.id = "portfolio-image";
    $.updateNavigation(imgSrc,imageList);
    myImage.onload = function(){
        $("#loading-graphic").hide('slow',function(){
                        // Center the image
            $.centerImage(myImage);
            $("#misty-portfolio-image-container").append(myImage);
            $("#misty-portfolio-image-container").fadeIn("fast");
            });
        };
    myImage.src = imgSrc; // Src goes after onload to prevent caching
    };