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.92k stars 305 forks source link

Swiping too hard causes the whole viewport unclickable #676

Open vincentsartoko opened 1 month ago

vincentsartoko commented 1 month ago

Describe the bug When using useDrag where velocity is greater than 1, there is a moment where you cannot click anywhere else. The behaviour is similar to clicking a shadow overlay that doesn't register anything, and everything seems fine after you click this shadow overlay. This also happens on the official site of use-gesture, take a look at the video below.

Sandbox or Video Here is the bug on the use-gesture website:

https://github.com/user-attachments/assets/dd7e2b74-fb9b-44bf-940a-bd44a4ac6610

Here is the detailed console.log on my app:

import { useSpring, animated } from '@react-spring/web';
import { useDrag } from '@use-gesture/react';

export default function Component() {
  const [{ x, y }, api] = useSpring(() => ({ x: 0, y: 0 }));

  const bind = useDrag(({ down, movement: [mx, my], velocity }) => {
    if (!down) console.log(`Click inside useDrag with velocity: ${velocity}`); // Log inside useDrag
    api.start({ x: down ? mx : 0, y: down ? my : 0, immediate: down });
  });

  return (
    <div>
      <animated.div
        {...bind()}
        onClick={() => console.log('Click inside onClick')} // Log when click
        style={{ x, y, width: 100, height: 100, background: 'red', touchAction: 'none' }}
      />
    </div>
  );
}

https://github.com/user-attachments/assets/872604f0-0e3a-4b5a-bee4-674e49fddc42

Information:

Checklist:

dbismut commented 1 month ago

Are you able to reproduce this outside of the inspector (ie real device)?

vincentsartoko commented 1 month ago

Are you able to reproduce this outside of the inspector (ie real device)?

Yes, I deployed on production as a webapp, and an Android webview through CapacitorJS.

dbismut commented 1 month ago

The example from the docs you're referring to and showing in the issue: are you able to reproduce this on a real device with a normal browser?

vincentsartoko commented 1 month ago

@dbismut Yes I could reproduce it on my phone, and some of our users. How about from your side?

dbismut commented 1 month ago

No, I can't, hence why I'm asking. I'm using an iPhone 15 Pro and Safari. Reason why I'm asking about context and devices is because I think it might be related to pointer capture but there's no reason why it wouldn't work normally on regular devices.

vincentsartoko commented 1 month ago

@dbismut all occurances happened on Android phones, FYI I use Samsung S22 ultra.