Browse Source

Up getElBoxRect

canvas-spot
Artur Arseniev 3 years ago
parent
commit
7cf5e3ab5d
  1. 18
      src/canvas/view/CanvasView.ts

18
src/canvas/view/CanvasView.ts

@ -284,8 +284,24 @@ export default class CanvasView extends ModuleView<Canvas> {
};
}
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,

Loading…
Cancel
Save