.load () and .fadeIn in jquery

I have this code and it works, except for the fadeIn transition.

$("div.thumbnailsContainer").fadeOut("500",function(){            
        $("div.fullViewContainer").empty();
        $('<img />')
        .attr('src', imgPathLarge)
        .load(function(){               
            $("div.fullViewContainer").append( $(this) );
            $("div.fullViewContainer").fadeIn("1000");
        });   
    });    

The problem is that after the image is fully loaded, the fadeIn transition will not work properly, it will appear only after loading, but without the transition.

what could be the problem with my code?

Do I need to set setTimeout to the transition delay after loading the image?

+3
source share
2 answers

It doesn't seem like div.fullViewContainer has ever been hiding - it was empty but not hidden. Therefore, when you add a new image to it, it is displayed immediately, even before the fadeIn command is called.

0
source

, fadeIn load().

: jquery:

+1

Source: https://habr.com/ru/post/1754824/


All Articles