Created
July 19, 2012 02:44
-
-
Save adesignl/3140422 to your computer and use it in GitHub Desktop.
Set And Resize Div on window resize
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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