From 7cf5e3ab5de395fc72481226d3868446efd3f2ed Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Wed, 9 Aug 2023 12:23:57 +0400 Subject: [PATCH] Up getElBoxRect --- src/canvas/view/CanvasView.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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,