From 63502b5ee9c0a1a6a8a1e1e400b2850250078029 Mon Sep 17 00:00:00 2001 From: newbyvector Date: Mon, 2 Oct 2023 15:02:08 +0800 Subject: [PATCH] fix: optimize dispoese minimap --- packages/x6-common/src/common/disposable.ts | 4 ++-- packages/x6-plugin-minimap/src/index.ts | 13 ++----------- packages/x6/src/graph/graph.ts | 7 +++++-- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/packages/x6-common/src/common/disposable.ts b/packages/x6-common/src/common/disposable.ts index d0a80a7221c..6cd99d456de 100644 --- a/packages/x6-common/src/common/disposable.ts +++ b/packages/x6-common/src/common/disposable.ts @@ -56,11 +56,11 @@ export namespace Disposable { ) => { const raw = descriptor.value const proto = target.__proto__ as IDisposable // eslint-disable-line - descriptor.value = function (this: IDisposable) { + descriptor.value = function (this: IDisposable, ...args: any[]) { if (this.disposed) { return } - raw.call(this) + raw.call(this, ...args) proto.dispose.call(this) } } diff --git a/packages/x6-plugin-minimap/src/index.ts b/packages/x6-plugin-minimap/src/index.ts index ec648c38168..bc56eb4cb81 100644 --- a/packages/x6-plugin-minimap/src/index.ts +++ b/packages/x6-plugin-minimap/src/index.ts @@ -1,12 +1,4 @@ -import { - FunctionExt, - CssLoader, - Dom, - View, - Graph, - EventArgs, - Model, -} from '@antv/x6' +import { FunctionExt, CssLoader, Dom, View, Graph, EventArgs } from '@antv/x6' import { content } from './style/raw' export class MiniMap extends View implements Graph.Plugin { @@ -138,8 +130,7 @@ export class MiniMap extends View implements Graph.Plugin { protected onRemove() { this.stopListening() - this.targetGraph.model = new Model() - this.targetGraph.dispose() + this.targetGraph.dispose(false) } protected onTransform(options: { ui: boolean }) { diff --git a/packages/x6/src/graph/graph.ts b/packages/x6/src/graph/graph.ts index 496d44e781e..5b7dd972837 100644 --- a/packages/x6/src/graph/graph.ts +++ b/packages/x6/src/graph/graph.ts @@ -1271,8 +1271,11 @@ export class Graph extends Basecoat { // #region dispose @Basecoat.dispose() - dispose() { - this.clearCells() + dispose(clean = true) { + if (clean) { + this.clearCells() + } + this.off() this.css.dispose()