Skip to content

Commit 8b0281f

Browse files
committed
better getcOomponentOffset
1 parent e45d4cf commit 8b0281f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

haxe/ui/backend/ComponentImpl.hx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ class ComponentImpl extends ComponentBase {
243243
}
244244
}
245245

246+
private var _componentOffset:Point = new Point(0, 0);
246247
private override function getComponentOffset():Point {
247248
var p:DisplayObjectContainer = this;
248249
var s:DisplayObjectContainer = null;
@@ -254,10 +255,13 @@ class ComponentImpl extends ComponentBase {
254255
p = p.parent;
255256
}
256257
if (s == null) {
257-
return new Point(0, 0);
258+
_componentOffset.x = 0;
259+
_componentOffset.y = 0;
260+
} else {
261+
_componentOffset.x = s.x;
262+
_componentOffset.y = s.y;
258263
}
259-
var globalPoint = s.localToGlobal(new openfl.geom.Point(0, 0));
260-
return new Point(globalPoint.x, globalPoint.y);
264+
return _componentOffset;
261265
}
262266

263267
private override function handleFrameworkProperty(id:String, value:Any) {

0 commit comments

Comments
 (0)