-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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: resolve conflict of zoom-canvas and drag-canvas #6780
Conversation
WalkthroughThis pull request resolves the conflict between zoom-canvas and drag-canvas interactions by introducing a mechanism to prevent drag-canvas offset behavior when zoom-canvas interaction is active. The changes ensure that the drag operation is halted during a pinch gesture. Changes
|
支持一个 PinchHanle 实例绑定多种类型(start/move/end)的多个事件函数,同时支持单个回调函数的解绑,当所有回调函数为空时,会自动销毁实例 |
packages/g6/src/utils/shortcut.ts
Outdated
@@ -127,7 +127,7 @@ export class Shortcut { | |||
this.emitter.off(CommonEvent.KEY_UP, this.onKeyUp); | |||
this.emitter.off(CommonEvent.WHEEL, this.onWheel); | |||
this.emitter.off(CommonEvent.DRAG, this.onDrag); | |||
this.pinchHandler?.destroy(); | |||
this.pinchHandler?.unregister('move', this.handlePinch.bind(this)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bind 会返回一个新的函数,这样写会注销不会成功
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改成了下面的形式,保证绑定和解绑的是同一个函数
this.boundHandlePinch = this.handlePinch.bind(this);
this.pinchHandler = new PinchHandler(this.emitter, 'pinchmove', this.boundHandlePinch);
Resolved the conflict that occurred when configuring the interaction behaviors of zoom canvas and drag canvas simultaneously. The solution is to prevent the offset behavior of drag - canvas when the zoom - canvas interaction is in progress.