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

[FEATURE] Support for multiple concurrent drag elements #2965

Open
Simon-Tang opened this issue Dec 30, 2024 · 0 comments
Open

[FEATURE] Support for multiple concurrent drag elements #2965

Simon-Tang opened this issue Dec 30, 2024 · 0 comments
Labels
feature New feature or request

Comments

@Simon-Tang
Copy link

Simon-Tang commented Dec 30, 2024

Is your feature request related to a problem? Please describe.

On multi-touch devices, the user isn't able to drag multiple elements with Motion with multiple fingers.

Describe the solution you'd like

I'd like the ability to specify that an element can be dragged by a non-primary pointer (i.e. multi-touch input). With a callout that this API would need to work with regular drag prop and the useDragControls method.

Describe alternatives you've considered

If I really want multiple concurrent drags, I would need to write the pointer event handlers manually and maybe recreate the dragConstraints behaviour. I could still use a pair of MotionValue to try to maintain Motion integration.

Additional context

At a glance it looks like the code could be mostly ready to handle this, but there are explicit checks in place that prevent testing this without cloning the library and editing the code myself.

The first is checking PointerEvent.isPrimary for touch inputs, though I think this can be circumvented with Object.defineProperty on the PointerEvent.

The second is a check for !isDragActive() that prevents the above workaround from working. Looks like the packages/motion-dom/src/gestures/drag/state/is-active.ts module would need some refactoring for multiple drags.

@Simon-Tang Simon-Tang added the feature New feature or request label Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant