Skip to content

Instantly share code, notes, and snippets.

@AlexJWayne
Created August 3, 2016 19:10
Show Gist options
  • Save AlexJWayne/4146f58b18047fc11edb72950a2e9aa8 to your computer and use it in GitHub Desktop.
Save AlexJWayne/4146f58b18047fc11edb72950a2e9aa8 to your computer and use it in GitHub Desktop.
var resize_blocker = Date.now();
var resize_interval;
// resize AFTER resize finished, and don't do again for a second or so
window.onresize=function(){
// window was resized, so cancel any previous deferred resize handlers.
clearTimeout(resize_interval);
// Call this every 250ms
resize_interval = setTimeout(function () {
// When is it right now?
var date_now = Date.now();
// If it's been 750ms since the last resize event was handled...
if (date_now - resize_blocker > 750) {
// The last resize event was handled right now. Make a note.
resize_blocker = date_now;
// Do the crap you need to do on resize.
$('body').css('min-height',$(window).height()+'px');
if ($.isFunction(jQuery.fn.body_height))
$('div.body_height').body_height();
}
},250);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment