flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [07/15] git commit: [flex-asjs] [refs/heads/develop] - add clientWidth and CSSWidth so we can better compute and force sizes of containers. Absolute positioned children don't affect the bounding width so you have to set it yourself
Date Fri, 22 May 2015 23:04:26 GMT
add clientWidth and CSSWidth so we can better compute and force sizes of containers.  Absolute
positioned children don't affect the bounding width so you have to set it yourself


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

Branch: refs/heads/develop
Commit: d2fe78afe46739bac6963a434a004bf2f03cadc1
Parents: aac09e7
Author: Alex Harui <aharui@apache.org>
Authored: Fri May 22 15:27:36 2015 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Fri May 22 16:04:11 2015 -0700

----------------------------------------------------------------------
 .../Core/js/src/org/apache/flex/core/UIBase.js  | 56 +++++++++++++++++---
 1 file changed, 48 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/d2fe78af/frameworks/projects/Core/js/src/org/apache/flex/core/UIBase.js
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/js/src/org/apache/flex/core/UIBase.js b/frameworks/projects/Core/js/src/org/apache/flex/core/UIBase.js
index 61a0015..14c79da 100644
--- a/frameworks/projects/Core/js/src/org/apache/flex/core/UIBase.js
+++ b/frameworks/projects/Core/js/src/org/apache/flex/core/UIBase.js
@@ -424,6 +424,26 @@ Object.defineProperties(org_apache_flex_core_UIBase.prototype, {
         }
     },
     /** @expose */
+    clientWidth: {
+        /** @this {org_apache_flex_core_UIBase} */
+        get: function() {
+            return this.positioner.clientWidth;
+        }
+    },
+    /** @expose */
+    CSSWidth: {
+        /** @this {org_apache_flex_core_UIBase} */
+        get: function() {
+            var pixels;
+            var strpixels = this.positioner.style.width;
+            if (strpixels !== null && strpixels.indexOf('%') != -1)
+              pixels = NaN;
+            else
+              pixels = parseFloat(strpixels);
+            return pixels;
+        }
+    },
+    /** @expose */
     width: {
         /** @this {org_apache_flex_core_UIBase} */
         set: function(pixels) {
@@ -476,6 +496,26 @@ Object.defineProperties(org_apache_flex_core_UIBase.prototype, {
         }
     },
     /** @expose */
+    clientHeight: {
+        /** @this {org_apache_flex_core_UIBase} */
+        get: function() {
+            return this.positioner.clientHeight;
+        }
+    },
+    /** @expose */
+    CSSHeight: {
+        /** @this {org_apache_flex_core_UIBase} */
+        get: function() {
+            var pixels;
+            var strpixels = this.positioner.style.height;
+            if (strpixels !== null && strpixels.indexOf('%') != -1)
+              pixels = NaN;
+            else
+              pixels = parseFloat(strpixels);
+            return pixels;
+        }
+    },
+    /** @expose */
     height: {
         /** @this {org_apache_flex_core_UIBase} */
         set: function(pixels) {
@@ -649,8 +689,8 @@ org_apache_flex_core_UIBase.prototype.setHeight =
   if (opt_noEvent === undefined)
     opt_noEvent = false;
 
-  var _height = this.height;
-  if (_height != value) {
+  var _height = this.CSSHeight;
+  if (isNaN(_height) || _height != value) {
     this.positioner.style.height = value.toString() + 'px';
     if (!opt_noEvent)
       this.dispatchEvent('heightChanged');
@@ -669,8 +709,8 @@ org_apache_flex_core_UIBase.prototype.setWidth =
   if (opt_noEvent === undefined)
     opt_noEvent = false;
 
-  var _width = this.width;
-  if (_width != value) {
+  var _width = this.CSSWidth;
+  if (isNaN(_width) || _width != value) {
     this.positioner.style.width = value.toString() + 'px';
     if (!opt_noEvent)
       this.dispatchEvent('widthChanged');
@@ -690,14 +730,14 @@ org_apache_flex_core_UIBase.prototype.setWidthAndHeight =
   if (opt_noEvent === undefined)
     opt_noEvent = false;
 
-  var _width = this.width;
-  if (_width != newWidth) {
+  var _width = this.CSSWidth;
+  if (isNaN(_width) || _width != newWidth) {
     this.positioner.style.width = newWidth.toString() + 'px';
     if (!opt_noEvent)
       this.dispatchEvent('widthChanged');
   }
-  var _height = this.height;
-  if (_height != newHeight) {
+  var _height = this.CSSHeight;
+  if (isNaN(_height) || _height != newHeight) {
     this.positioner.style.height = newHeight.toString() + 'px';
     if (!opt_noEvent)
       this.dispatchEvent('heightChanged');


Mime
View raw message