| Page 1 of 1 | [ 2 posts ] |
Marco AsbreukYUI Contributor
|
Has anybody a clue how I can determine the node's height when there are absolute positioned divs within?
Code: <div id='div1' style='height:200px'> I would like to get the value of 350px when refering to div1.<div id='div2' style='position:absolute; height:200px; top:50px;'> </div> <div id='div3' style='position:absolute; height:200px; top:150px;'> </div> </div> I don't see a standard functioncall. So I tried something like: Code: absNodeHeight : function(node) { But this doesn't work of course, due to the function each, which loses its reference to the function it is called from (finalHeight is unknown at this point).var finalHeight = node.get('offsetHeight'); var divlist = node.all('DIV'); divlist.each(function() { var subNodeHeight = absNodeHeight(this)+this.getStyle('top'); if (subNodeHeight>finalHeight) {finalHeight=subNodeHeight;} }); return finalHeight; } Kind Regards, Marco. |
Marco AsbreukYUI Contributor
|
I'm using this function now:
But I think it would be nice if there was one alike in the node-module. So I will put a request. Code: function getRealHeight(node) { // returns the real nodeheight, also taken into account absolute or relative divs that float above the node var startY = parseInt(node.getY(), 10); var finalY = parseInt(node.get('offsetHeight'), 10) + startY; var childList = node.all('DIV'); var listSize = childList.size(); var i, childNode, position, childY; for (i=0; i<listSize; i++) { childNode = childList.item(i); position = childNode.getStyle('position'); if ((position==='absolute') || (position==='relative')) { childY = parseInt(childNode.get('offsetHeight'), 10) + parseInt(childNode.getY(), 10); if (childY>finalY) {finalY=childY;} } } return finalY-startY; } |
| Page 1 of 1 | [ 2 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group