From 4a6a634a8acfad5c1a7bb93ac17fb3b97239e853 Mon Sep 17 00:00:00 2001 From: vector Date: Thu, 8 Dec 2022 09:35:17 +0800 Subject: [PATCH] fix: trigger preventDefault by origin event (#3017) --- packages/x6/src/graph/graph.ts | 8 ++++++-- packages/x6/src/graph/view.ts | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/x6/src/graph/graph.ts b/packages/x6/src/graph/graph.ts index 82254f5e42d..e557fd84769 100644 --- a/packages/x6/src/graph/graph.ts +++ b/packages/x6/src/graph/graph.ts @@ -58,8 +58,12 @@ export class Graph extends Basecoat { this.grid = new Grid(this) this.background = new Background(this) - this.model = this.options.model ? this.options.model : new Model() - this.model.graph = this + if (this.options.model) { + this.model = this.options.model + } else { + this.model = new Model() + this.model.graph = this + } this.renderer = new ViewRenderer(this) this.panning = new Panning(this) diff --git a/packages/x6/src/graph/view.ts b/packages/x6/src/graph/view.ts index a24da7e5791..165e233fb0b 100644 --- a/packages/x6/src/graph/view.ts +++ b/packages/x6/src/graph/view.ts @@ -201,7 +201,7 @@ export class GraphView extends View { } if (this.options.preventDefaultMouseDown) { - e.preventDefault() + evt.preventDefault() } const localPoint = this.graph.snapToGrid(e.clientX, e.clientY) @@ -213,7 +213,7 @@ export class GraphView extends View { this.options.preventDefaultBlankAction && ['touchstart'].includes(e.type) ) { - e.preventDefault() + evt.preventDefault() } this.graph.trigger('blank:mousedown', {