Im using the jQuery load() function to bind to the onload event of images to gently transition them in.
Problem is if the image is already loaded before the image.load() function is called then the callback function never fires.
Is there a way to detect if an image has already been loaded before i call load()?
Reason being its a marionette application and moving between views images get cached and might already be loaded before the render function is called.
Basically my code where its at:
preloadImages: function () {
var images = $('.grid .item > img');
var initialHeight = images.eq(0).width();
images.each(function(){
$(this).height(initialHeight).css("opacity", 0);
$(this).load(function(){
$(this).css("height", "").animate({"opacity": 1}, 200);
})
});
}