Browse Source

Remove getZoom from CanvasView

canvas-spot
Artur Arseniev 3 years ago
parent
commit
523e1cdcfc
  1. 11
      src/canvas/view/CanvasView.ts

11
src/canvas/view/CanvasView.ts

@ -240,10 +240,6 @@ export default class CanvasView extends ModuleView<Canvas> {
module.setCoords(coords.x, coords.y); module.setCoords(coords.x, coords.y);
} }
getZoom() {
return this.em.getZoomDecimal();
}
/** /**
* Checks if the element is visible in the canvas's viewport * Checks if the element is visible in the canvas's viewport
* @param {HTMLElement} el * @param {HTMLElement} el
@ -318,7 +314,7 @@ export default class CanvasView extends ModuleView<Canvas> {
* @public * @public
*/ */
getElementPos(el: HTMLElement, opts: ElementPosOpts = {}) { getElementPos(el: HTMLElement, opts: ElementPosOpts = {}) {
const zoom = this.getZoom(); const zoom = this.module.getZoomDecimal();
const frameOffset = this.getFrameOffset(el); const frameOffset = this.getFrameOffset(el);
const canvasEl = this.el; const canvasEl = this.el;
const canvasOffset = this.getCanvasOffset(); const canvasOffset = this.getCanvasOffset();
@ -347,6 +343,7 @@ export default class CanvasView extends ModuleView<Canvas> {
if (!el || isTextNode(el)) return {}; if (!el || isTextNode(el)) return {};
const result: MarginPaddingOffsets = {}; const result: MarginPaddingOffsets = {};
const styles = window.getComputedStyle(el); const styles = window.getComputedStyle(el);
const zoom = this.module.getZoomDecimal();
const marginPaddingOffsets: (keyof MarginPaddingOffsets)[] = [ const marginPaddingOffsets: (keyof MarginPaddingOffsets)[] = [
'marginTop', 'marginTop',
'marginRight', 'marginRight',
@ -358,7 +355,7 @@ export default class CanvasView extends ModuleView<Canvas> {
'paddingLeft', 'paddingLeft',
]; ];
marginPaddingOffsets.forEach(offset => { marginPaddingOffsets.forEach(offset => {
result[offset] = parseFloat(styles[offset]) * this.getZoom(); result[offset] = parseFloat(styles[offset]) * zoom;
}); });
return result; return result;
@ -380,7 +377,7 @@ export default class CanvasView extends ModuleView<Canvas> {
}; };
} }
const bEl = doc.body; const bEl = doc.body;
const zoom = this.getZoom(); const zoom = this.module.getZoomDecimal();
const fo = this.getFrameOffset(); const fo = this.getFrameOffset();
const co = this.getCanvasOffset(); const co = this.getCanvasOffset();
const { noScroll } = opts; const { noScroll } = opts;

Loading…
Cancel
Save