I'm having trouble consistently getting the width of an element that is updated.
Here's a code snippet. I need to get the width of $newimg. You can see an attempt in line 5,
var $imgwidth = $newimg.width() I've tried referring to it in a number of ways but the problem exists. If the image has already been loaded once it usually missess. I've tried a few when...then commands but got nowhere.
Code:
$('<img class="fp_preview" />').load(function(){
var $newimg = $(this);
var $currImage = $('#fp_gallery').children('img:first');
$newimg.insertBefore($currImage);
var $imgwidth = $newimg.width();
$loader.hide();
//expand clone
$theClone.animate({
'opacity' : 0,
'top' : windowH/2 + 'px',
'left' : windowW/2 + 'px',
'margin-top' : '-200px',
'margin-left' : -final_w/2 + 'px',
'width' : final_w + 'px',
'height' : '400px'
},1000,function(){$(this).remove();});
//now we have two large images on the page
//fadeOut the old one so that the new one gets shown
$currImage.fadeOut(2000,function(){
$(this).remove();
});
//show the navigation arrows
showNav();
}).attr('src',$elem.attr('alt'))