7

Is there a way to detect finger drags using Javascript on touch phones? I'm currently using jQuery and the mousemove() method doesn't appear to work on my Andorid phone.

EDIT: I suppose I should clarify that this is for a web application.

EDIT 2: I found a duplicate of my question a few moments ago: Detect a finger swipe through JavaScript on the iPhone and Android. Although, it does not have an accepted answer.

Community
  • 1
  • 1
Ivan
  • 10,052
  • 12
  • 47
  • 78
  • possible duplicate of [Detect a finger swipe through JavaScript on the iPhone and Android](http://stackoverflow.com/questions/2264072/detect-a-finger-swipe-through-javascript-on-the-iphone-and-android) – Ivan Sep 02 '11 at 18:16

2 Answers2

7

Use the analogous touch events: touchstart, touchmove, touchcancel, and touchend. To bind an event listener for one of these events, you'll have to use, for example .bind('touchmove', ...) instead of .touchmove(...), because jQuery does not provide convenience methods.

Community
  • 1
  • 1
Matt Ball
  • 354,903
  • 100
  • 647
  • 710
0

You could use a touch library like https://github.com/dotmaster/Touchable-jQuery-Plugin

This is lightweight if paired with a lightweight dom abstraction library like the very-similar-to-jquery Zepto: http://zeptojs.com/

SimplGy
  • 20,079
  • 15
  • 107
  • 144