You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ha...@apache.org on 2018/05/29 09:26:18 UTC

[royale-asjs] branch feature/revert-refactor updated: global point should ignore window scrolling

This is an automated email from the ASF dual-hosted git repository.

harbs pushed a commit to branch feature/revert-refactor
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/feature/revert-refactor by this push:
     new acc3d3e  global point should ignore window scrolling
acc3d3e is described below

commit acc3d3e7a194021363505830edaf1746cd8db67b
Author: Harbs <ha...@in-tools.com>
AuthorDate: Tue May 29 12:25:55 2018 +0300

    global point should ignore window scrolling
---
 .../royale/org/apache/royale/utils/PointUtils.as   | 28 +++++++++++++---------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/PointUtils.as b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/PointUtils.as
index 264102c..f96e61c 100644
--- a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/PointUtils.as
+++ b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/PointUtils.as
@@ -71,18 +71,24 @@ package org.apache.royale.utils
                 var x:Number = pt.x;
                 var y:Number = pt.y;
                 var element:HTMLElement = local.element as HTMLElement;
+				if ( element.getBoundingClientRect ) {// TODO take scrollbar widths into account
+					var rect:Object = element.getBoundingClientRect();
+					x = x - rect.left - window.scrollX;
+					y = y - rect.top - window.scrollY;
+				} else { // for older browsers, but offsetParent is soon to be deprecated from chrome
 
-                do {
-                    x -= element.offsetLeft;
-                    y -= element.offsetTop;
-					if (local['parent'] !== undefined) {
-                        local = local.parent;
-                        element = local ? local.element as HTMLElement : null;
-                    } else {
-                        element = null;
+                    do {
+                        x -= element.offsetLeft;
+                        y -= element.offsetTop;
+                        if (local['parent'] !== undefined) {
+                            local = local.parent;
+                            element = local ? local.element as HTMLElement : null;
+                        } else {
+                            element = null;
+                        }
                     }
+                    while (element);
                 }
-                while (element);
                 return new org.apache.royale.geom.Point(x, y);
 
             }
@@ -119,8 +125,8 @@ package org.apache.royale.utils
 
 				if ( element.getBoundingClientRect ) {// TODO take scrollbar widths into account
 					var rect:Object = element.getBoundingClientRect();
-					x = rect.left + x;
-					y = rect.top + y;
+					x = rect.left + x + window.scrollX;
+					y = rect.top + y + window.scrollY;
 				} else { // for older browsers, but offsetParent is soon to be deprecated from from chrome
 	                do {
 	                    x += element.offsetLeft;

-- 
To stop receiving notification emails like this one, please contact
harbs@apache.org.