diff --git a/src/canvas/view/CanvasView.ts b/src/canvas/view/CanvasView.ts index 0499cdfc6..f0e8042b0 100644 --- a/src/canvas/view/CanvasView.ts +++ b/src/canvas/view/CanvasView.ts @@ -284,8 +284,24 @@ export default class CanvasView extends ModuleView { }; } - getElBoxRect(el: HTMLElement): BoxRect { + getElBoxRect(el: HTMLElement, opts: ToWorldOption = {}): BoxRect { const { width, height, left, top } = getElRect(el); + + if (opts.toWorld) { + const { module } = this; + const zoom = module.getZoomDecimal(); + const vwDelta = this.getViewportDelta(); + const x = left * zoom + vwDelta.x || 0; + const y = top * zoom + vwDelta.y || 0; + + return { + x, + y, + width: width * zoom, + height: height * zoom, + }; + } + return { x: left, y: top,