feat: 获取元素的绝对位置

This commit is contained in:
unanmed 2024-10-05 23:23:35 +08:00
parent a1fe6e9d00
commit 4bc4588cde

View File

@ -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;