Reputation: 21893
I want the content of jQuery.fn.resize
to only execute after i let go of the mouse button not while i am resizing the window.
I have tried putting onmousedown inside on resize but it didn't work.
$(window).resize(function(){
console.log("resizing")
});
Upvotes: 1
Views: 243
Reputation: 382160
You can't know what happens outside your document, and you're not notified when the resizing ends (a resizing can occur in many ways, not all of them mouse based).
But you could add a timer for the same effect :
(function(){
var timer;
$(window).resize(function(){
if (timer) clearTimeout(timer);
timer = setTimeout(function(){
// do the things
}, 200);
});
})();
This would add a slight delay (200 ms should be ok) but this would avoid most intermediate recomputing.
Note that you don't receive events when your javascript function is running, so you usually don't have to do this unless you really want the user to not see anything during the resizing.
Upvotes: 1