Browse Source

Cleanup listeners

update-canvas-frame
Artur Arseniev 2 years ago
parent
commit
7c3a86ed6e
  1. 1
      packages/core/src/canvas/view/CanvasView.ts
  2. 6
      packages/core/src/canvas/view/FrameWrapView.ts
  3. 1
      packages/core/src/commands/view/SelectComponent.ts
  4. 2
      packages/core/src/editor/model/Editor.ts

1
packages/core/src/canvas/view/CanvasView.ts

@ -270,6 +270,7 @@ export default class CanvasView extends ModuleView<Canvas> {
fitViewport(opts: FitViewportOptions = {}) { fitViewport(opts: FitViewportOptions = {}) {
const { em, module, model } = this; const { em, module, model } = this;
this.clearOff();
const canvasRect = this.getCanvasOffset(); const canvasRect = this.getCanvasOffset();
const { el } = opts; const { el } = opts;
const elFrame = el && getComponentView(el)?.frameView; const elFrame = el && getComponentView(el)?.frameView;

6
packages/core/src/canvas/view/FrameWrapView.ts

@ -76,6 +76,7 @@ export default class FrameWrapView extends ModuleView<Frame> {
} }
remove(opts?: any) { remove(opts?: any) {
this.sizeObserver?.disconnect();
this.__clear(opts); this.__clear(opts);
ModuleView.prototype.remove.apply(this, opts); ModuleView.prototype.remove.apply(this, opts);
//@ts-ignore //@ts-ignore
@ -150,7 +151,7 @@ export default class FrameWrapView extends ModuleView<Frame> {
__handleSize() { __handleSize() {
const un = 'px'; const un = 'px';
const { model, el } = this; const { model, el, em } = this;
const { style } = el; const { style } = el;
const { width, height } = model.attributes; const { width, height } = model.attributes;
const currW = style.width || ''; const currW = style.width || '';
@ -161,6 +162,7 @@ export default class FrameWrapView extends ModuleView<Frame> {
const newWidth = isNumber(newW) ? `${newW}${un}` : newW; const newWidth = isNumber(newW) ? `${newW}${un}` : newW;
const newHeight = isNumber(newH) ? `${newH}${un}` : newH; const newHeight = isNumber(newH) ? `${newH}${un}` : newH;
style.width = newWidth; style.width = newWidth;
this.sizeObserver?.disconnect();
if (model.hasAutoHeight()) { if (model.hasAutoHeight()) {
const iframe = this.frame.el; const iframe = this.frame.el;
@ -175,12 +177,10 @@ export default class FrameWrapView extends ModuleView<Frame> {
style.height = `${contentDocument.body.scrollHeight}px`; style.height = `${contentDocument.body.scrollHeight}px`;
}); });
observer.observe(contentDocument.body); observer.observe(contentDocument.body);
this.sizeObserver?.disconnect();
this.sizeObserver = observer; this.sizeObserver = observer;
} }
} else { } else {
style.height = newHeight; style.height = newHeight;
this.sizeObserver?.disconnect();
delete this.sizeObserver; delete this.sizeObserver;
} }

1
packages/core/src/commands/view/SelectComponent.ts

@ -800,6 +800,7 @@ export default {
this.stopSelectComponent(); this.stopSelectComponent();
!opts.preserveSelected && em.setSelected(); !opts.preserveSelected && em.setSelected();
this.toggleToolsEl(); this.toggleToolsEl();
this.updateAttached.cancel();
editor && editor.stopCommand('resize'); editor && editor.stopCommand('resize');
}, },
} as CommandObject<any, { [k: string]: any }>; } as CommandObject<any, { [k: string]: any }>;

2
packages/core/src/editor/model/Editor.ts

@ -110,9 +110,9 @@ export default class EditorModel extends Model {
device: '', device: '',
}; };
} }
Model = Model; Model = Model;
Collection = Collection; Collection = Collection;
events = EditorEvents;
__skip = false; __skip = false;
defaultRunning = false; defaultRunning = false;
destroyed = false; destroyed = false;

Loading…
Cancel
Save