pmndrs / use-gesture

👇Bread n butter utility for component-tied mouse/touch gestures in React and Vanilla Javascript.
https://use-gesture.netlify.app
MIT License
8.95k stars 307 forks source link

Clicking on the screen with another finger while dragging an element interrupts the dragging behavior #485

Closed jacob-lcs closed 2 years ago

jacob-lcs commented 2 years ago

Describe the bug

Clicking on the screen with another finger while dragging an element interrupts the dragging behavior, unless you remove the dragging finger and start dragging again

Sandbox or Video

codesandbox link: https://codesandbox.io/s/confident-beaver-556uec

https://user-images.githubusercontent.com/40483898/164155641-e7c6963d-fd89-4eaf-9659-4892b5ef0c91.MP4

I looked at the source code and found that these two lines of code were the problem.

https://github.com/pmndrs/use-gesture/blob/main/packages/core/src/engines/DragEngine.ts#L296-L297

The other finger clicked and set _pointerActive to false, which broke the drag behavior. If these two lines of code were removed, they would behave normally, as follows:

https://user-images.githubusercontent.com/40483898/164156275-9191767f-bf21-4f67-9ed4-60cd87289336.MP4

I didn't submit the PR because I wasn't sure what problem these two lines of code were solving

Information:

Checklist:

dbismut commented 2 years ago

Fair enough, that could / should be fixed, thanks for reporting this. This bug should only occur with preventScroll option set.

I'd need to run some tests to make sure we could safely remove those lines (the gesture cleaning might be done elsewhere).

dbismut commented 2 years ago

Sorry for the long wait, should now be fixed!