Skip to content

Instantly share code, notes, and snippets.

@subchild
Created April 18, 2010 18:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save subchild/370446 to your computer and use it in GitHub Desktop.
Save subchild/370446 to your computer and use it in GitHub Desktop.
$.resizeEnd()
jQuery.fn.extend({
/**
* Binds new resize handler to window object. For IE and Safari handler is executed on resize completion.
* @param newHandler function object
*/
resizeEnd: function(newHandler){
$(this).resize(function(){
var handlerCode = newHandler.toString(); // for hash reference
if ($.browser.msie || $.browser.safari){ // handle after resize operation is complete (once)
if (!GLR.resizeTimeout){
GLR.resizeTimeout = {}; // initiate GLR.resizeTimeout
}
if (GLR.resizeTimeout[handlerCode] !== null){ // if handler exists...
clearTimeout(GLR.resizeTimeout[handlerCode]); // clear timeout since it will be re-assigned later, if need be
}
GLR.resizeTimeout[handlerCode] = setTimeout(newHandler, 300); // wait before calling handleResize, unless its been reset by a further resize actiong IE or Safari;
}
else {
newHandler();
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment