flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yish...@apache.org
Subject git commit: [flex-asjs] [refs/heads/refactor-sprite] - Positioning parameters of SVG element change depending on whether it's contained in a <g> element or in a <div>. Setting both params should make it work in both cases.
Date Tue, 25 Oct 2016 09:42:08 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/refactor-sprite 3f1df179c -> 0d3ba9491


Positioning parameters of SVG element change depending on whether it's contained in a <g>
element or in a <div>. Setting both params should make it work in both cases.


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

Branch: refs/heads/refactor-sprite
Commit: 0d3ba9491a60ab39235807268437986114678f8b
Parents: 3f1df17
Author: yishayw <yishayjobs@hotmail.com>
Authored: Tue Oct 25 12:41:55 2016 +0300
Committer: yishayw <yishayjobs@hotmail.com>
Committed: Tue Oct 25 12:41:55 2016 +0300

----------------------------------------------------------------------
 .../flex/org/apache/flex/core/ImageViewBase.as  |  2 +-
 .../src/main/flex/org/apache/flex/svg/Image.as  | 55 ++++++++++++++++++--
 .../flex/org/apache/flex/svg/beads/ImageView.as | 41 +++++++++++++++
 3 files changed, 93 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0d3ba949/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ImageViewBase.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ImageViewBase.as
b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ImageViewBase.as
index 264fb07..afc7def 100644
--- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ImageViewBase.as
+++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ImageViewBase.as
@@ -211,7 +211,7 @@ package org.apache.flex.core
          * @flexjsignorecoercion HTMLElement
          */
         COMPILE::JS
-        private function sizeChangedHandler(event:Object):void
+        protected function sizeChangedHandler(event:Object):void
         {
             var host:UIBase = _strand as UIBase;
             var s:Object = host.positioner.style;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0d3ba949/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/Image.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/Image.as b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/Image.as
index 0524e41..cd0729f 100644
--- a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/Image.as
+++ b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/Image.as
@@ -33,7 +33,7 @@ package org.apache.flex.svg
         public function Image()
         {
 			super();
-        }
+       }
 		
 		/**
 		 * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement
@@ -43,8 +43,8 @@ package org.apache.flex.svg
 		{
 			element = document.createElementNS('http://www.w3.org/2000/svg', 'svg') as WrappedHTMLElement;
 			element.flexjs_wrapper = this;
-			element.style.left = 0;
-			element.style.top = 0;
+			element.setAttribute('x', 0);
+			element.setAttribute('y', 0);
 			//element.offsetParent = null;
 			positioner = element;
 			positioner.style.position = 'relative';
@@ -75,12 +75,59 @@ package org.apache.flex.svg
 		{
 			return _image;
 		}
-
+		
+		COMPILE::JS
+		override public function get transformElement():WrappedHTMLElement
+		{
+			return _image;
+		}
+		
 		COMPILE::JS
 		override public function applyImageData(binaryDataAsString:String):void
 		{
 			(_image as SVGImageElement).setAttributeNS('http://www.w3.org/1999/xlink','href', binaryDataAsString);
 		}
+		COMPILE::JS
+		override public function setWidth(value:Number, noEvent:Boolean=false):void
+		{
+			super.setWidth(value, noEvent);
+			positioner.setAttribute("width", value);
+		}
 
+		COMPILE::JS
+		override public function setHeight(value:Number, noEvent:Boolean=false):void
+		{
+			super.setHeight(value, noEvent);
+			positioner.setAttribute("height", value);
+		}
+		
+		COMPILE::JS
+		override public function setX(value:Number):void
+		{
+			super.setX(value);
+			positioner.setAttribute("x", value);
+
+		}
+		COMPILE::JS
+		override public function setY(value:Number):void
+		{
+			super.setY(value);
+			positioner.setAttribute("y", value);
+			
+		}
+		
+		COMPILE::JS
+		override public function set x(value:Number):void
+		{
+			super.x = value;
+			positioner.setAttribute("x", value);
+		}
+		
+		COMPILE::JS
+		override public function set y(value:Number):void
+		{
+			super.y = value;
+			positioner.setAttribute("y", value);
+		}
     }
 }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/0d3ba949/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/beads/ImageView.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/beads/ImageView.as
b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/beads/ImageView.as
index 0f40093..8cbd789 100644
--- a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/beads/ImageView.as
+++ b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/beads/ImageView.as
@@ -20,6 +20,11 @@
 package org.apache.flex.svg.beads
 {
 	import org.apache.flex.core.ImageViewBase;
+	COMPILE::JS
+		{
+			import org.apache.flex.core.UIBase;
+			import org.apache.flex.core.ValuesManager;
+		}
 	
 	/**
 	 *  The ImageView class creates the visual elements of the org.apache.flex.svg.Image component.
@@ -42,5 +47,41 @@ package org.apache.flex.svg.beads
 		public function ImageView()
 		{
 		}
+		
+		COMPILE::JS
+		override protected function sizeChangedHandler(event:Object):void
+		{
+			super.sizeChangedHandler(event);
+			var host:UIBase = _strand as UIBase;
+			
+			var left:* = ValuesManager.valuesImpl.getValue(host, "left");
+			var right:* = ValuesManager.valuesImpl.getValue(host, "right");
+			var l:Number = isNaN(left) ? NaN : left;
+			var r:Number = isNaN(right) ? NaN : right;
+
+			var top:* = ValuesManager.valuesImpl.getValue(host, "top");
+			var bottom:* = ValuesManager.valuesImpl.getValue(host, "bottom");
+			var t:Number = isNaN(top) ? NaN : top;
+			var b:Number = isNaN(bottom) ? NaN : bottom;
+			
+			var p:Object = host.positioner;
+
+			if (!isNaN(l) &&
+				!isNaN(r)) {
+				// if just using size constraints and image will not shrink or grow
+				var computedWidth:Number = (host.positioner.offsetParent as HTMLElement).offsetWidth
-
+					l - r;
+				p.setAttribute("width", computedWidth);
+
+			}
+			if (!isNaN(t) &&
+				!isNaN(b)) {
+				// if just using size constraints and image will not shrink or grow
+				var computedHeight:Number = (host.positioner.offsetParent as HTMLElement).offsetHeight
-
+					t - b;
+				p.setAttribute("height", computedHeight);
+			}
+		}
+
 	}
 }


Mime
View raw message