furf / jquery-ui-touch-punch

A duck punch for adding touch events to jQuery UI
http://touchpunch.furf.com/
3.51k stars 1.34k forks source link

No more Click events on Draggable "widgets" #291

Open marmz opened 7 years ago

marmz commented 7 years ago

After including latest touch-punch release, draggable objects does not trigger any CLICK handler/callback. Fortunately, the fork by ivanmoralesv https://github.com/ivanmoralesv/jquery-ui-touch-punch seems to fix this particular issue, but i'm not sure that his branch is "aligned" with the newer modifications that could have been applied by the master developer (furf) ...

Maybe it could be useful to merge this "patch" into the original master branch, just to keep everything updated.

This is only an advice, of course ;)

biafra commented 6 years ago

If I use ivan version, draggable stop working :-(

elgs commented 6 years ago

This kind of problems are caused by event.preventDefault();. This line is not mobile friendly and need to be removed. The consequence is you need to analyse event.target in your code to conditionally call event.preventDefault();. Without event.preventDefault();, when you drag something, the default behavior of mobile screens is to move the whole viewport around. This is undesirable when you want to drag something on your mobile screen. There is no drop in solution for this problem. The only solution is to comment out the line event.preventDefault();, and conditionally call it in your code based on the result of event.target.

schroedi23 commented 6 years ago

in my usage i simply added somthing like this in the .min.js:

if(!$(a.target).hasClass('button') && !$(a.target).is("input") && !$(a.target).is("textarea") && !$(a.target).is("button")){a.preventDefault();}else{a.stopPropagation();}

so input,textarea and buttons work ... and when i give an element on the dragg a button class then it can be also clicked

Committing commented 1 year ago

Mine was still really iffy until I doubled dragIgnoreTime to 300. Now it's working much better in my case. Good fork