Skip to content

Instantly share code, notes, and snippets.

@adesignl
Created July 19, 2012 02:44
Show Gist options
  • Save adesignl/3140422 to your computer and use it in GitHub Desktop.
Save adesignl/3140422 to your computer and use it in GitHub Desktop.
Set And Resize Div on window resize
function mainWindowHeight(){
var search = $('#search');
var work = $('#work');
var bottomPosition = $(window).height();
var usedHeight = '120';
var availableHeight = bottomPosition - usedHeight;
$('#main').height(availableHeight);
}
function overflowPanelHeight (){
var mainHeight = $('#main').height();
var paddingHeight = '37';
var interiorHeight = mainHeight - paddingHeight;
$('.overflow').height(interiorHeight);
}
function resultsHeight(){
var mainHeight = $('#main').height();
var paddingHeight = '70';
var interiorHeight = mainHeight - paddingHeight;
$('#results.overflow').height(interiorHeight);
}
$(window).load(function(){
mainWindowHeight();
overflowPanelHeight();
resultsHeight();
});
var delay = (function(){
var timer = 0;
return function(callback, ms){
clearTimeout (timer);
timer = setTimeout(callback, ms);
};
})();
$(window).resize(function() {
delay(function(){
mainWindowHeight();
overflowPanelHeight();
resultsHeight();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment