Reputation:
I want to load the image, determine the height, and THEN show it
Here is my code:
$("#block").animate({
height: HERE GOES HEIGHT + 50px for additional space
},
function() {
$("img").fadeIn("slow");
});
Upvotes: 1
Views: 79
Reputation:
Will this work?
$("img").load(function(){
var imgHeight = $(this).height();
});
$("#block").animate({
height: '+='imgHeight
},
function() {
$("img").fadeIn("slow");
});
Upvotes: 2
Reputation: 576
Grabbing the image dimensions before the page is loaded is not something I think is particularly possible like this.
However there is a similar post to grab the image dimensions before its fully loaded, then you could tie that into your animation.
Get image dimensions with Javascript before image has fully loaded
Upvotes: 1