Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-29-2011, 04:15 PM   PM User | #1
cmor
New to the CF scene

 
Join Date: Sep 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
cmor is an unknown quantity at this point
Race condition problem with jquery

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'))
cmor is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:20 AM.


Advertisement
Log in to turn off these ads.