Repository: flex-asjs Updated Branches: refs/heads/develop 4644861a9 -> b5bcfc2ac
try to not return 0. offsetHeight/Width can be zero if parents don't have size constraints enough to constrain a % calculation on an element Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/8b357cff Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/8b357cff Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/8b357cff Branch: refs/heads/develop Commit: 8b357cff0749969b34d48f8f7d8fd71df9bc75d7 Parents: 942ef40 Author: Alex Harui <[email protected]> Authored: Tue Jan 6 21:36:28 2015 -0800 Committer: Alex Harui <[email protected]> Committed: Fri Jan 9 08:09:46 2015 -0800 ---------------------------------------------------------------------- .../js/FlexJS/src/org/apache/flex/core/UIBase.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/8b357cff/frameworks/js/FlexJS/src/org/apache/flex/core/UIBase.js ---------------------------------------------------------------------- diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/UIBase.js b/frameworks/js/FlexJS/src/org/apache/flex/core/UIBase.js index 3a35c6e..37265bc 100644 --- a/frameworks/js/FlexJS/src/org/apache/flex/core/UIBase.js +++ b/frameworks/js/FlexJS/src/org/apache/flex/core/UIBase.js @@ -446,8 +446,13 @@ org.apache.flex.core.UIBase.prototype.get_width = function() { var pixels; var strpixels = this.positioner.style.width; pixels = parseFloat(strpixels); - if (isNaN(pixels)) + if (isNaN(pixels)) { pixels = this.positioner.offsetWidth; + if (pixels == 0 && this.positioner.scrollWidth != 0) { + // invisible child elements cause offsetWidth to be 0. + pixels = this.positioner.scrollWidth; + } + } return pixels; }; @@ -511,8 +516,13 @@ org.apache.flex.core.UIBase.prototype.get_height = function() { var pixels; var strpixels = this.positioner.style.height; pixels = parseFloat(strpixels); - if (isNaN(pixels)) + if (isNaN(pixels)) { pixels = this.positioner.offsetHeight; + if (pixels == 0 && this.positioner.scrollHeight != 0) { + // invisible child elements cause offsetHeight to be 0. + pixels = this.positioner.scrollHeight; + } + } return pixels; };
