Fixed bug with grid element position calculation in firefox - firefox uses fractional height values internally but returns them rounded when using offsetHeight - using getComputedStyle when using firefox fixed the issue.

This commit is contained in:
Andreas Stöckel 2011-03-30 20:52:02 +00:00
parent 3111c74eda
commit a726d95d0b
2 changed files with 41 additions and 10 deletions

View File

@ -615,21 +615,51 @@ egwGridViewContainer.prototype.setPosition = function(_top)
/**
* Returns the height of the container in pixels and zero if the element is not
* visible. The height is clamped to positive values.
* The browser switch is placed at this position as the getHeight function is one
* of the mostly called functions in the whole grid code and should stay
* quite fast.
*/
egwGridViewContainer.prototype.getHeight = function()
if ($.browser.mozilla)
{
if (this.visible && this.parentNode)
egwGridViewContainer.prototype.getHeight = function()
{
if (this.height === false && this.assumedHeight === false)
if (this.visible && this.parentNode)
{
this.height = this.parentNode.outerHeight();
}
if (this.height === false && this.assumedHeight === false)
{
// Firefox sometimes provides fractional pixel values - we are
// forced to use those - we can obtain the fractional pixel height
// by using the window.getComputedStyle function
var styleHeightStr =
getComputedStyle(this.parentNode.context, null).getPropertyValue("height");
this.height = parseFloat(styleHeightStr.substr(0, styleHeightStr.length - 2));
}
return this.height !== false ? this.height : this.assumedHeight;
return this.height !== false ? this.height : this.assumedHeight;
}
else
{
return 0;
}
}
else
}
else
{
egwGridViewContainer.prototype.getHeight = function()
{
return 0;
if (this.visible && this.parentNode)
{
if (this.height === false && this.assumedHeight === false)
{
this.height = this.parentNode.context.offsetHeight;
}
return this.height !== false ? this.height : this.assumedHeight;
}
else
{
return 0;
}
}
}

View File

@ -4,6 +4,8 @@
<title>Grid Test</title>
<!-- Basic action stuff -->
<script src="js/jquery.js"></script>
<script src="../egw_action.js"></script>
<script src="../egw_action_common.js"></script>
@ -22,7 +24,6 @@
<script src="../egw_grid.js"></script>
<script src="../egw_stylesheet.js"></script>
<script src="js/jquery.js"></script>
<link rel="stylesheet" href="grid.css"/>
<link rel="stylesheet" href="skins/dhtmlxmenu_egw.css"/>
</head>
@ -237,7 +238,7 @@
"entryType": EGW_DATA_TYPE_RANGE,
"prefix": "root_elem_",
"canHaveChildren": true,
"count": 10
"count": 1000
}
]
);