Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jamiehs
Last active November 10, 2015 00:43
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 jamiehs/696098887a26f2a7ca6c to your computer and use it in GitHub Desktop.
Save jamiehs/696098887a26f2a7ca6c to your computer and use it in GitHub Desktop.
A novel method of finding the height of an absolutely positioned element. From: http://stackoverflow.com/a/20791125
function absElemHeight(element){
var max_y = 0;
$.each( $(element).find('*'), function(idx, desc){
max_y = Math.max(max_y, $(desc).offset().top + $(desc).height());
});
return max_y - $(element).offset().top;
}
function absElemHeight(element){
$element = $(element);
if($element.find('.inner').length === 0) {
$element.wrapInner('<div class="inner"></div>');
}
return $element.find('.inner')[0].scrollHeight;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment