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/08/21 12:58:14 UTC
git commit: [flex-asjs] [refs/heads/refactor-sprite] - Don't use
deprecated offsetLeft when possible.
Repository: flex-asjs
Updated Branches:
refs/heads/refactor-sprite 86d794753 -> a107df0bf
Don't use deprecated offsetLeft when possible.
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/a107df0b
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/a107df0b
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/a107df0b
Branch: refs/heads/refactor-sprite
Commit: a107df0bf334d5069316cc5cbf67e0a5be5b4cd0
Parents: 86d7947
Author: yishayw <yi...@hotmail.com>
Authored: Sun Aug 21 15:58:05 2016 +0300
Committer: yishayw <yi...@hotmail.com>
Committed: Sun Aug 21 15:58:05 2016 +0300
----------------------------------------------------------------------
.../main/flex/org/apache/flex/utils/PointUtils.as | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/a107df0b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/PointUtils.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/PointUtils.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/PointUtils.as
index 43a90f6..c00bfa7 100644
--- a/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/PointUtils.as
+++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/utils/PointUtils.as
@@ -112,12 +112,18 @@ package org.apache.flex.utils
var y:Number = pt.y;
var element:HTMLElement = local.element as HTMLElement;
- do {
- x += element.offsetLeft;
- y += element.offsetTop;
- element = element.offsetParent as HTMLElement;
- }
- while (element);
+ if ( element.getBoundingClientRect ) {// TODO take scrollbar widths into account
+ var rect:Object = element.getBoundingClientRect();
+ x = rect.left;
+ y = rect.top;
+ } else { // for older browsers, but offsetParent is soon to be deprecated from from chrome
+ do {
+ x += element.offsetLeft;
+ y += element.offsetTop;
+ element = element.offsetParent as HTMLElement;
+ }
+ while (element);
+ }
return new org.apache.flex.geom.Point(x, y);
}
}