diff --git a/packages/core/src/app.ts b/packages/core/src/app.ts index bd72d09a..a6b1bced 100644 --- a/packages/core/src/app.ts +++ b/packages/core/src/app.ts @@ -204,8 +204,9 @@ export class App extends BaseService { public clear(): void { this.mainLayer.removeChildren(); - this.selector.clear(); + this.selector.destroy(); this.render(); + this.selector = new Selector(this); } public async toDataURL(config?: { diff --git a/packages/core/src/services/selector.ts b/packages/core/src/services/selector.ts index ed015555..e4e3d843 100644 --- a/packages/core/src/services/selector.ts +++ b/packages/core/src/services/selector.ts @@ -153,12 +153,6 @@ export class Selector extends Service { return this.transformer.getClientRect(); } - public clear(): void { - this.transformer.removeChildren(); - this.optionLayer.clear(); - this.selected.clear(); - } - private onTransformStart = (): void => { this.app.emit('node:transform:start', { nodes: [...this.selected.values()] }); this.app.emit('node:update:before', { nodes: [...this.selected.values()] });