0

I have the code:

  wrapper.addEventListener("click", function (event) {
      //do thing
  });

However it doesn't fire in mobile.

I tried replacing click with touch but then nothing happens. I tried replacing click with touchstart and the activates, but it also triggers when I'm trying to drag on top of the element.

How do I grab a click event while ignoring a drag event?

DasBeasto
  • 2,082
  • 5
  • 25
  • 65
  • Possible duplicate: http://stackoverflow.com/questions/3705937/document-click-not-working-correctly-on-iphone-jquery – Gerrit0 Dec 23 '16 at 02:58
  • @Gerrit0 either I'm not understaning that answer at all or it is only handling touchstart or touchend which doesn't quite help for regular click. Also it is using jquery making things more difficult since I am not. – DasBeasto Dec 23 '16 at 03:04
  • What do you want to perform with touch event ? Because the same click event will work on any button or div or element like working on browser. – Kirankumar Dafda Dec 23 '16 at 05:01
  • @KirankumarDafda I just want a simple click. But to intrerfere with drags. From my testing both browser and emulated phone "click" does not register the touch on my "wrapper" – DasBeasto Dec 23 '16 at 05:03
  • try [this](https://jsfiddle.net/xq93yug1/1/) code for simple click of your element which you called wraper, I have used it as div element here. – Kirankumar Dafda Dec 23 '16 at 05:10
  • For drag event follow [this](http://stackoverflow.com/a/6362527/3840093) answer, where I think you need to use [jQuery UI Touch Punch](https://github.com/furf/jquery-ui-touch-punch) to complete your requirements. – Kirankumar Dafda Dec 23 '16 at 05:11

0 Answers0