diff --git a/src/canvas/view/FrameView.ts b/src/canvas/view/FrameView.ts index 28585e753..8497ac65c 100644 --- a/src/canvas/view/FrameView.ts +++ b/src/canvas/view/FrameView.ts @@ -7,6 +7,7 @@ import Droppable from '../../utils/Droppable'; import Frame from '../model/Frame'; import Canvas from '../model/Canvas'; import FrameWrapView from './FrameWrapView'; +import { BoxRect } from '../../common'; export default class FrameView extends ModuleView { /** @ts-ignore */ @@ -50,6 +51,27 @@ export default class FrameView extends ModuleView { setViewEl(el, this); } + getBoxRect(): BoxRect { + const { el, module } = this; + const canvasView = module.getCanvasView(); + const coords = module.getCoords(); + const frameRect = el.getBoundingClientRect(); + const canvasRect = canvasView.getCanvasOffset(); + const vwDelta = canvasView.getViewportDelta(); + const zoomM = module.getZoomMultiplier(); + const x = (frameRect.x - canvasRect.left - vwDelta.x - coords.x) * zoomM; + const y = (frameRect.y - canvasRect.top - vwDelta.y - coords.y) * zoomM; + const width = frameRect.width * zoomM; + const height = frameRect.height * zoomM; + + return { + x, + y, + width, + height, + }; + } + /** * Update `` content of the frame */