0

I started to use recently an awesome plug-in to convert touch evens to mouse clicks. But just today I came across one problem

jQuery('.draggable').click(function(){
  alert('clicked');
})

To fire alert I need to make two touches(mobile device), while on computer I need only one mouse click. What can be the problem? Thank you.

unloco
  • 6,928
  • 2
  • 47
  • 58
Alex F
  • 183
  • 2
  • 14

1 Answers1

0
// set a var as false as a way to change and flag if something is being dragged

var dragCheck = false;
$('.element').draggable({
      revert: true,
   drag: function(){
            // On drag set that flag to true
         dragCheck = true;
   },
   stop: function(){
            // On stop of dragging reset the flag back to false
         dragCheck = false;
   }
});

// Then instead of using click use mouseup, and on mouseup only fire if the flag is set to false

$('.element') .bind('mouseup', function(){
      if(dragCheck == false){
           // do the click action here...
      }
});
Alex F
  • 183
  • 2
  • 14