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 FrameView from '../view/FrameView';
import Frames from './Frames'; import Frames from './Frames';
import Page from '../../pages/model/Page'; import Page from '../../pages/model/Page';
import { BoxRect } from '../../common';
const keyAutoW = '__aw'; const keyAutoW = '__aw';
const keyAutoH = '__ah'; const keyAutoH = '__ah';
const getDimension = (frame: Frame, type: 'width' | 'height') => { const getDimension = (frame: Frame, type: 'width' | 'height') => {
const dim = frame.get(type); 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)) { if (isNumber(dim)) {
return dim; return dim;
@ -114,6 +115,18 @@ export default class Frame extends ModuleModel<CanvasModule> {
return this.get('head'); return this.get('head');
} }
getBoxRect(): BoxRect {
const { x, y } = this.attributes;
const { width, height } = this;
return {
x,
y,
width,
height,
};
}
onRemove() { onRemove() {
this.getComponent().remove({ root: 1 }); this.getComponent().remove({ root: 1 });
} }

Loading…
Cancel
Save