Skip to content

Commit

Permalink
fix: optimize dispoese minimap (#3950)
Browse files Browse the repository at this point in the history
  • Loading branch information
NewByVector authored Oct 2, 2023
1 parent c6800af commit 4dc74f1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
4 changes: 2 additions & 2 deletions packages/x6-common/src/common/disposable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
13 changes: 2 additions & 11 deletions packages/x6-plugin-minimap/src/index.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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 }) {
Expand Down
7 changes: 5 additions & 2 deletions packages/x6/src/graph/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1271,8 +1271,11 @@ export class Graph extends Basecoat<EventArgs> {
// #region dispose

@Basecoat.dispose()
dispose() {
this.clearCells()
dispose(clean = true) {
if (clean) {
this.clearCells()
}

this.off()

this.css.dispose()
Expand Down

0 comments on commit 4dc74f1

Please sign in to comment.