You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by yi...@apache.org on 2016/12/26 09:18:10 UTC
git commit: [flex-asjs] [refs/heads/develop] - Fix
getScreenBoundingRect() for svg elements.
Repository: flex-asjs
Updated Branches:
refs/heads/develop d277641ed -> 85c080468
Fix getScreenBoundingRect() for svg elements.
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/85c08046
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/85c08046
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/85c08046
Branch: refs/heads/develop
Commit: 85c080468af4d1b1bd8602b9e284f5b6c211a845
Parents: d277641
Author: yishayw <yi...@hotmail.com>
Authored: Mon Dec 26 11:18:03 2016 +0200
Committer: yishayw <yi...@hotmail.com>
Committed: Mon Dec 26 11:18:03 2016 +0200
----------------------------------------------------------------------
.../flex/org/apache/flex/utils/DisplayUtils.as | 24 ++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/85c08046/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/DisplayUtils.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/DisplayUtils.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/DisplayUtils.as
index 483ab41..ac66a19 100644
--- a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/DisplayUtils.as
+++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/DisplayUtils.as
@@ -19,7 +19,14 @@
package org.apache.flex.utils
{
import org.apache.flex.core.IUIBase;
- import org.apache.flex.geom.Rectangle
+ import org.apache.flex.geom.Rectangle;
+
+ COMPILE::JS
+ {
+ import org.apache.flex.geom.Matrix;
+ import org.apache.flex.geom.Point;
+ import org.apache.flex.core.ITransformHost;
+ }
/**
* The SpriteUtils class is a collection of static functions that are useful
* for geometric operations on visible objects.
@@ -42,6 +49,7 @@ package org.apache.flex.utils
* @playerversion AIR 2.6
* @productversion FlexJS 0.0
* @flexjsignorecoercion HTMLElement
+ * @flexjsignorecoercion ITransformHost
*/
public static function getScreenBoundingRect(obj:IUIBase):Rectangle
{
@@ -53,9 +61,21 @@ package org.apache.flex.utils
COMPILE::JS
{
var r:Object = (obj.element as HTMLElement).getBoundingClientRect();
- var bounds:Rectangle = new Rectangle(r.x, r.y, r.width, r.height);
+ var bounds:Rectangle = new Rectangle(r.left, r.top, r.right - r.left, r.bottom - r.top);
bounds.x -= window.pageXOffset;
bounds.y -= window.pageYOffset;
+ if (obj.element instanceof SVGElement)
+ {
+ var svgElement:Object = (obj as ITransformHost).transformElement as Object;
+ var sm:SVGMatrix = svgElement.getScreenCTM();
+ var m:Matrix = new Matrix(sm.a,sm.b,sm.c,sm.d,sm.e,sm.f);
+ var tl:Point = m.transformPoint(bounds.topLeft);
+ var br:Point = m.transformPoint(bounds.bottomRight);
+ bounds.top = tl.y;
+ bounds.left = tl.x;
+ bounds.bottom = br.y;
+ bounds.right = br.x;
+ }
return bounds;
}
}