flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [4/4] git commit: [flex-asjs] [refs/heads/develop] - compute width is sized to content. The prior width might get used and cause linebreaks which we don't want
Date Fri, 28 Aug 2015 20:53:52 GMT
compute width is sized to content.  The prior width might get used and cause linebreaks which
we don't want


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/a29787a0
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/a29787a0
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/a29787a0

Branch: refs/heads/develop
Commit: a29787a0aedb1b1e582ca6557af11cb6c5dc02c4
Parents: 00f2d2c
Author: Alex Harui <aharui@apache.org>
Authored: Fri Aug 28 13:53:52 2015 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Fri Aug 28 13:53:52 2015 -0700

----------------------------------------------------------------------
 .../flex/html/beads/layouts/HorizontalLayout.js      | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a29787a0/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/HorizontalLayout.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/HorizontalLayout.js
b/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/HorizontalLayout.js
index 8db30eb..efc75d0 100644
--- a/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/HorizontalLayout.js
+++ b/frameworks/projects/HTML/js/src/org/apache/flex/html/beads/layouts/HorizontalLayout.js
@@ -65,7 +65,9 @@ org.apache.flex.html.beads.layouts.HorizontalLayout.
   var contentView = viewBead.contentView;
   children = contentView.internalChildren();
   var hasHeight = !this.strand_.isHeightSizedToContent();
+  var hasWidth = !this.strand_.isWidthSizedToContent();
   var maxHeight = 0;
+  var computedWidth = 0;
   n = children.length;
   for (i = 0; i < n; i++)
   {
@@ -75,7 +77,15 @@ org.apache.flex.html.beads.layouts.HorizontalLayout.
       child.lastDisplay_ = 'inline-block';
     else
       child.style.display = 'inline-block';
-    maxHeight = Math.max(maxHeight, child.offsetTop + child.offsetHeight);
+    maxHeight = Math.max(maxHeight, child.offsetHeight);
+    if (!hasWidth) {
+      var cv = window.getComputedStyle(child);
+      var mls = cv['margin-left'];
+      var ml = Number(mls.substring(0, mls.length - 2));
+      var mrs = cv['margin-right'];
+      var mr = Number(mrs.substring(0, mrs.length - 2));
+      computedWidth += ml + child.offsetWidth + mr;
+    }
     child.flexjs_wrapper.dispatchEvent('sizeChanged');
   }
   // if there are children and maxHeight is ok, use it.
@@ -83,4 +93,7 @@ org.apache.flex.html.beads.layouts.HorizontalLayout.
   if (!hasHeight && n > 0 && !isNaN(maxHeight)) {
     contentView.height = maxHeight;
   }
+  if (!hasWidth && n > 0 && !isNaN(computedWidth)) {
+    contentView.width = computedWidth + 1; // some browser need one more pixel
+  }
 };


Mime
View raw message