Created
December 6, 2008 16:05
-
-
Save staaky/32900 to your computer and use it in GitHub Desktop.
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
getHiddenDimensions: function(element) { | |
element = $(element); | |
var check = element.ancestors(), | |
restore = [], | |
styles = []; | |
check.push(element); | |
// All *Width and *Height properties give 0 on elements with display none, | |
// or when ancestors have display none, so enable those temporarily | |
check.each(function(c) { | |
if (c != element && c.visible()) return; | |
restore.push(c); | |
styles.push({ | |
display: c.getStyle('display'), | |
position: c.getStyle('position'), | |
visibility: c.getStyle('visibility') | |
}); | |
c.setStyle({display: 'block', position: 'absolute', visibility: 'visible'}); | |
}); | |
var dimensions = {width: element.clientWidth, height: element.clientHeight}; | |
restore.each(function(r, index) { | |
r.setStyle(styles[index]); | |
}); | |
return dimensions; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment