Skip to content

Instantly share code, notes, and snippets.

@Kcko
Created March 26, 2015 17:45
Show Gist options
  • Save Kcko/964fc353e34bdc99d2d5 to your computer and use it in GitHub Desktop.
Save Kcko/964fc353e34bdc99d2d5 to your computer and use it in GitHub Desktop.
Resize window with timeout (for responsive testing)
var a;
$(window).resize(function(){
clearTimeout(a);
a = setTimeout(function(){
// call your function
},750);
});
$(window).bind('resize', function(e){
window.resizeEvt;
$(window).resize(function(){
clearTimeout(window.resizeEvt);
window.resizeEvt = setTimeout(function(){
//code to do after window is resized
}, 250);
});
});
$(window).resize( function() {
if( timer ) {
clearTimeout(timer);
}
var timer = setTimeout( function() {
// On Resize Code Goes Here
}, 100 );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment