react-draggable icon indicating copy to clipboard operation
react-draggable copied to clipboard

Delay for touch events

Open vladar opened this issue 8 years ago • 5 comments
trafficstars

Is there a way to set delay for touch events, so that dragging started after N ms of touching (to differentiate from tapping and scrolling)?

vladar avatar May 27 '17 11:05 vladar

you can get lastX and lastY from as the second argument in the onDrag and calculate the difference and set a value in state to disable drag after that movement enable the drag

chauhan216 avatar Jun 20 '17 11:06 chauhan216

Is there any plan for this issue? I think it would be great to have this feature embeded in component instead of manually having to compare onDrag arguments on touchDevices

dbuchet avatar Mar 05 '19 08:03 dbuchet

this worked for me

https://codesandbox.io/s/eager-darkness-j97pd

carloquilala avatar Sep 19 '19 16:09 carloquilala

You can use something like useLongPress to enable dragging. You can't use the disabled prop but you can return false in the onDrag handler.

gunnartorfis avatar Oct 18 '22 08:10 gunnartorfis

这个问题有解决方案吗?使用 @carloquilala 的答案可以在 onStop 函数内部拦截到点击事件,但是并不会出发节点本身的onClick事件

liaoyingfu avatar Dec 08 '23 10:12 liaoyingfu