views:

313

answers:

4

Hi i am using :

$(window).resize(foo())

to detect when the window is resizeing...

the foo() works fine but it only fires foo() after the resize has finished so it's not while resizeing.

is there a way to make the resize smoothly. maybe a cancelBubble could be something to do with it but im not familiar with it.

any help is appriciiated

A: 

It makes me wonder why you would want to do such a thing. If you could be specific, perhaps I could suggest a CSS solution to you?

Here Be Wolves
well i am using it so i can change the height of the a class. more like a fluid concept and css cant do that because there are different factors that mess it up.
Val
A: 

The resize event fired after the window has finished resizing is pretty much the way things are. I don't think you can do anything about it.

RichN
+1  A: 

You can't do precisely what you want by listening to window resize events.

Check out Google maps or reader, try resizing the window vertically. Note that these apps exhibit the same behavior.

Look a bit more carefully at your CSS. I find that sometimes CSS can do some very surprising things. If you post some sample HTML and CSS that is representative of you problem, we may be able to devise a solution.

If you absolutely cannot tolerate waiting until the user has finished resizing the window, you could poll document.scrollWidth and document.scrollHeight at a short interval. Whenever they change, call your resizing code. Note that polling these properties may be pretty expensive. I recommend against this, but it will solve the problem.

If you are using Internet Explorer, depending on version, you made need to use document.documentElement.scrollWidth or document.body.scrollWidth (and similar for scrollWidth).

Firefox 3.6 will support events for determining when document.scrollWidth and document.scrollHeight change, although it looks like it will be non-standard:

https://developer.mozilla.org/en/DOM/Detecting_document_width_and_height_changes

Mike
+1  A: 

From the jQuery documentation, you seem to be experiencing Firefox behavior when you're really after IE behavior.

Depending on implementation, resize events can be sent continuously as the resizing is in progress (the typical behavior in Internet Explorer and WebKit-based browsers such as Safari and Chrome), or only once at the end of the resize operation (the typical behavior in Firefox). http://api.jquery.com/resize/

Interestingly, on that same page is a comment to a plugin which may make the behavior cross-browser (I have not looked into this)

Darrell