markusenglund / react-switch

A draggable toggle-switch component for React. Check out the demo at:
https://react-switch.netlify.com/
MIT License
1.33k stars 101 forks source link

Zero length drags should count as clicks #32

Closed nat-n closed 5 years ago

nat-n commented 5 years ago

Sometimes clicking on the switch in the demos seems to have no effect.

I've not fully verified this because the minified code is hard to debug, but my theory (based on debugging other drag&drop UIs) is that I'm inadvertently moving the mouse during the click by a distance less than 1 pixel which still triggers a drag event, and so the intended click has no effect.

The solution would be to ignore initial drag events below a certain drag threshold drag distance.

It may be that this effect only occurs with apple mice with the sensitivity turned up high.

markusenglund commented 5 years ago

Yes, your analysis is correct. This problem has been fixed in 4.0.0 that was just released by always triggering the onChange-event if the user holds the mouse down for less 250 ms.