Browse Source

Add getBoxRect to Frame

canvas-spot
Artur Arseniev 3 years ago
parent
commit
ee446ddc05
  1. 15
      src/canvas/model/Frame.ts

15
src/canvas/model/Frame.ts

@ -6,13 +6,14 @@ import { isComponent, isObject } from '../../utils/mixins';
import FrameView from '../view/FrameView';
import Frames from './Frames';
import Page from '../../pages/model/Page';
import { BoxRect } from '../../common';
const keyAutoW = '__aw';
const keyAutoH = '__ah';
const getDimension = (frame: Frame, type: 'width' | 'height') => {
const dim = frame.get(type);
const viewDim = frame.view?.el['width' ? 'offsetWidth' : 'offsetHeight'];
const viewDim = frame.view?.el[type === 'width' ? 'offsetWidth' : 'offsetHeight'];
if (isNumber(dim)) {
return dim;
@ -114,6 +115,18 @@ export default class Frame extends ModuleModel<CanvasModule> {
return this.get('head');
}
getBoxRect(): BoxRect {
const { x, y } = this.attributes;
const { width, height } = this;
return {
x,
y,
width,
height,
};
}
onRemove() {
this.getComponent().remove({ root: 1 });
}

Loading…
Cancel
Save