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

feat: support drag canvas on mobile device #6770

Merged
merged 1 commit into from
Feb 13, 2025
Merged

Conversation

zhongyunWan
Copy link
Contributor

@zhongyunWan zhongyunWan commented Feb 13, 2025

support drag canvas on mobile device, which is resolved by adapting the mobile offset

normal.video.mp4

Copy link

Walkthrough

This pull request introduces support for dragging the canvas on mobile devices by adapting the mobile offset. It modifies the drag event handling to accommodate mobile-specific interactions.

Changes

File Summary
packages/g6/__tests__/unit/behaviors/drag-canvas.spec.ts Added unit tests to verify drag functionality on mobile devices, ensuring correct position changes.
packages/g6/src/behaviors/drag-canvas.ts Modified drag event handling to use IDragEvent instead of IPointerEvent, and adapted movement calculations for mobile compatibility.

if (!this.isDragging) return;
const { x, y } = event.movement;
const x = event.movement?.x ?? event.dx;

Choose a reason for hiding this comment

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

Ensure that event.movement is properly defined for all scenarios, as using event.dx and event.dy as fallbacks might lead to unexpected behavior if movement is not handled correctly for all input types.

@Aarebecca Aarebecca merged commit aef338d into v5 Feb 13, 2025
3 checks passed
@Aarebecca Aarebecca deleted the support-mobile-drag-canvas branch February 13, 2025 06:35
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.

[Bug]: In version 5.0.42, the drag-canvas on the mobile page cannot drag the canvas
2 participants