mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-19 12:49:25 +08:00
feat: 获取元素的绝对位置
This commit is contained in:
parent
a1fe6e9d00
commit
4bc4588cde
@ -296,6 +296,18 @@ export abstract class RenderItem<E extends ERenderItemEvent = ERenderItemEvent>
|
||||
this.update(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前元素的绝对位置(不建议使用,因为应当很少会有获取绝对位置的需求)
|
||||
*/
|
||||
getAbsolutePosition(): LocArr {
|
||||
const { x, y } = this.transform;
|
||||
if (!this.parent) return [x, y];
|
||||
else {
|
||||
const [px, py] = this.parent.getAbsolutePosition();
|
||||
return [x + px, y + py];
|
||||
}
|
||||
}
|
||||
|
||||
setAnchor(x: number, y: number): void {
|
||||
this.anchorX = x;
|
||||
this.anchorY = y;
|
||||
|
Loading…
Reference in New Issue
Block a user