Is there an event that tells me when the user has stopped resizing by letting go of the mouse button? I'm looking at $(window).resize, and it's firing for every pixel movement. I just need to know when they've stopped.
Firing resize event only when resizing is finished. jQuery resize event is fired when the size of the browser’s window (viewport) changes as pointed out in jQuery documentation. Sometimes we need to execute functions which might take a while to execute or which might consume quite a few resources from the machine.
Well, as far as the window manager is concerned, each resize event is its own message, with a distinct beginning and end, so technically, every time the window is resized, it is the end. Having said that, maybe you want to set a delay to your continuation?
When we resize the browser window, the “resize” event is fired continuously, multiple times while resizing. We want the “resize” event to only be fired once we are done resizing.
If the resize event is triggered too many times for your application, see Optimizing window.onresize to control the time after which the event fires. The following example reports the window size each time it is resized.
no, but you can defer the event handler if you want:
function onResize(){ ... }
var timer;
$(window).bind('resize', function(){
timer && clearTimeout(timer);
timer = setTimeout(onResize, 100);
});
this will make it fire after the user has stopped resizing for 100ms.
You can try this :
function rsizeItems()
{ }
var tOut = false;
var milSec = 500;
$(window).resize(function(){
if(tOut !== false)
clearTimeout(tOut);
tOut = setTimeout(rsizeItems, milSec);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With