Browse Source

Cleanup timerZoom

update-canvas-frame
Artur Arseniev 12 months ago
parent
commit
ee2799df7e
  1. 7
      packages/core/src/canvas/view/CanvasView.ts
  2. 12
      packages/core/src/editor/model/Editor.ts

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

@ -84,7 +84,7 @@ export default class CanvasView extends ModuleView<Canvas> {
frames!: FramesView;
frame?: FrameView;
private timerZoom?: number;
private timerZoom?: NodeJS.Timeout;
private frmOff?: { top: number; left: number; width: number; height: number };
private cvsOff?: { top: number; left: number; width: number; height: number };
@ -135,6 +135,7 @@ export default class CanvasView extends ModuleView<Canvas> {
}
remove(...args: any) {
clearTimeout(this.timerZoom);
this.frames?.remove();
//@ts-ignore
this.frames = undefined;
@ -242,12 +243,12 @@ export default class CanvasView extends ModuleView<Canvas> {
this.clearOff();
toolsWrpEl.style.display = 'none';
em.trigger('canvas:update', ev);
this.timerZoom && clearTimeout(this.timerZoom);
clearTimeout(this.timerZoom);
this.timerZoom = setTimeout(() => {
em.stopDefault(defOpts);
em.runDefault(defOpts);
toolsWrpEl.style.display = '';
}, 300) as any;
}, 300);
}
updateFramesArea() {

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

@ -907,10 +907,10 @@ export default class EditorModel extends Model {
* @private
*/
runDefault(opts = {}) {
const command = this.get('Commands').get(this.config.defaultCommand);
const command = this.Commands.get(this.config.defaultCommand!);
if (!command || this.defaultRunning) return;
command.stop(this, this, opts);
command.run(this, this, opts);
command.stop!(this as any, this, opts);
command.run!(this as any, this, opts);
this.defaultRunning = true;
}
@ -920,11 +920,11 @@ export default class EditorModel extends Model {
* @private
*/
stopDefault(opts = {}) {
const commands = this.get('Commands');
const commands = this.Commands;
if (!commands) return;
const command = commands.get(this.config.defaultCommand);
const command = commands.get(this.config.defaultCommand!);
if (!command || !this.defaultRunning) return;
command.stop(this, this, opts);
command.stop!(this as any, this, opts);
this.defaultRunning = false;
}

Loading…
Cancel
Save