mirror of
https://gitee.com/antv/g6.git
synced 2024-12-02 03:38:20 +08:00
refactor(behaviors): adjust unbind logic
This commit is contained in:
parent
352dffb588
commit
38d690b218
@ -170,14 +170,13 @@ export class DragElement extends BaseBehavior<DragElementOptions> {
|
|||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
public update(options: Partial<DragElementOptions>): void {
|
public update(options: Partial<DragElementOptions>): void {
|
||||||
|
this.unbindEvents();
|
||||||
super.update(options);
|
super.update(options);
|
||||||
this.bindEvents();
|
this.bindEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bindEvents() {
|
private bindEvents() {
|
||||||
const { graph } = this.context;
|
const { graph } = this.context;
|
||||||
this.unbindEvents();
|
|
||||||
|
|
||||||
this.enableElements.forEach((type) => {
|
this.enableElements.forEach((type) => {
|
||||||
graph.on(`${type}:${CommonEvent.DRAG_START}`, this.onDragStart);
|
graph.on(`${type}:${CommonEvent.DRAG_START}`, this.onDragStart);
|
||||||
graph.on(`${type}:${CommonEvent.DRAG}`, this.onDrag);
|
graph.on(`${type}:${CommonEvent.DRAG}`, this.onDrag);
|
||||||
@ -415,6 +414,8 @@ export class DragElement extends BaseBehavior<DragElementOptions> {
|
|||||||
graph.off(`${type}:${CommonEvent.DRAG_START}`, this.onDragStart);
|
graph.off(`${type}:${CommonEvent.DRAG_START}`, this.onDragStart);
|
||||||
graph.off(`${type}:${CommonEvent.DRAG}`, this.onDrag);
|
graph.off(`${type}:${CommonEvent.DRAG}`, this.onDrag);
|
||||||
graph.off(`${type}:${CommonEvent.DRAG_END}`, this.onDragEnd);
|
graph.off(`${type}:${CommonEvent.DRAG_END}`, this.onDragEnd);
|
||||||
|
graph.off(`${type}:${CommonEvent.POINTER_ENTER}`, this.setCursor);
|
||||||
|
graph.off(`${type}:${CommonEvent.POINTER_LEAVE}`, this.setCursor);
|
||||||
});
|
});
|
||||||
|
|
||||||
graph.off(`combo:${CommonEvent.DROP}`, this.onDrop);
|
graph.off(`combo:${CommonEvent.DROP}`, this.onDrop);
|
||||||
|
Loading…
Reference in New Issue
Block a user