I have been pulling my hair out trying to do some dynamic div resizing based on window/body resize events. I first started with javascript, then tried jQuery, and have even tried other “working” demos but almost every one crashes FF (or at least causes the active window to go all white). Is anyone else experiencing this?
For example, if I go to:
http://jsbin.com/ucolu
and try to resize my FF window, it crashes FF, as do most others.
The only stable resize I have found is via Ben Alman’s plugin at:
http://benalman.com/code/projects/jquery-resize/examples/resize/
Any ideas?
I believe it’s because the event fires over and over as you drag the window (as opposed to waiting for you to finish resizing, then firing just once).
You can throttle the handler to make it work, so that it only updates periodically as you drag the window size (say, every 500 milliseconds).
Basically, you’d use
set_timeoutto call the function that resizes the div. The resize event handler only clears the timeout and resets it. Once the user stops resizing the window, the timeout will finally be able to run and the screen will update. If the user drags really slowly, or pauses, then the screen can update “mid-resize”.