Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: optimize dispoese minimap #3950

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading