Last active
August 29, 2015 14:21
-
-
Save orioltf/19ff5d0cb119f40adce4 to your computer and use it in GitHub Desktop.
#JQUERY #UTIL getHeightIn
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
/** | |
* Gets the height from the provided elements, even if they are hidden | |
* @param {Object} $context - the jQuery DOM element where to append the object so that it gets proper styling | |
* @returns {Number} - the outerHeight value from the passed $element | |
*/ | |
$.fn.getHeightIn = function($context) { | |
var $element = this, | |
$wrap = $('<div />'), | |
$clone, height; | |
$context = typeof $context === 'undefined' ? $('body') : $context; | |
$wrap.css({ | |
'position': 'absolute !important', | |
'visibility': 'hidden !important', | |
'display': 'block !important' | |
}).appendTo($context); | |
$clone = $element.clone(); | |
$clone.appendTo($wrap); | |
height = $clone.outerHeight(); | |
$wrap.remove(); | |
return height; | |
}; |
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
collapsibleHeight = $collapsible.getHeightIn( $('#main') ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment