Browse Source

Cleanup timerZoom

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

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

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

Loading…
Cancel
Save