fix(behaviors): fix drag canvas unbind event (#6146)

Co-authored-by: antv <antv@antfin.com>
This commit is contained in:
Aaron 2024-08-07 14:20:08 +08:00 committed by GitHub
parent c943ab5d9e
commit f5311dd43b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -108,9 +108,10 @@ export class DragCanvas extends BaseBehavior<DragCanvasOptions> {
this.shortcut.bind(left, (event) => this.onTranslate([1, 0], event));
this.shortcut.bind(right, (event) => this.onTranslate([-1, 0], event));
} else {
this.context.graph.on(CanvasEvent.DRAG_START, this.onDragStart);
this.context.graph.on(CanvasEvent.DRAG, this.onDrag);
this.context.graph.on(CanvasEvent.DRAG_END, this.onDragEnd);
const { graph } = this.context;
graph.on(CanvasEvent.DRAG_START, this.onDragStart);
graph.on(CanvasEvent.DRAG, this.onDrag);
graph.on(CanvasEvent.DRAG_END, this.onDragEnd);
}
}
@ -170,10 +171,10 @@ export class DragCanvas extends BaseBehavior<DragCanvasOptions> {
private unbindEvents() {
this.shortcut.unbindAll();
const canvas = this.canvas;
canvas.removeEventListener(CanvasEvent.DRAG_START, this.onDragStart);
canvas.removeEventListener(CanvasEvent.DRAG, this.onDrag);
canvas.removeEventListener(CanvasEvent.DRAG_END, this.onDragEnd);
const { graph } = this.context;
graph.off(CanvasEvent.DRAG_START, this.onDragStart);
graph.off(CanvasEvent.DRAG, this.onDrag);
graph.off(CanvasEvent.DRAG_END, this.onDragEnd);
}
public destroy(): void {