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: resolve conflict of zoom-canvas and drag-canvas #6780

Merged
merged 6 commits into from
Feb 21, 2025

Conversation

zhongyunWan
Copy link
Contributor

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.

Copy link

Walkthrough

This 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

File Summary
packages/g6/src/behaviors/drag-canvas.ts Added a check to prevent dragging when a pinch gesture is detected.
packages/g6/src/utils/pinch.ts Introduced isPinchStage to track the pinch gesture state.
packages/g6/src/utils/shortcut.ts Made pinchHandler public to allow access to pinch state.

@zhongyunWan
Copy link
Contributor Author

支持一个 PinchHanle 实例绑定多种类型(start/move/end)的多个事件函数,同时支持单个回调函数的解绑,当所有回调函数为空时,会自动销毁实例

@@ -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));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bind 会返回一个新的函数,这样写会注销不会成功

Copy link
Contributor Author

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);

@Aarebecca Aarebecca merged commit a28b903 into v5 Feb 21, 2025
3 checks passed
@Aarebecca Aarebecca deleted the fix-canvas-behavior-conflict branch February 21, 2025 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants