0

I have a Jquery carousal which I have coded to move on the touchmove event. On testing on iPad 2, Safari browser it is working. Now I want to do 2 things:

  • Get the direction in which the finger moved so the carousal moves accordingly(Right to left or Left to Right).
  • Get the intensity(or distance) of touchmove so that the carousal moves in such a speed.

For this I was trying to get the X coordinate of the start point and the end point of the touchmove event, but event.pageX returns only 1 value. I have tried getting the values from 'touchstart' and 'touchend' event also, but that also does not work. I have even tried getting the event.originalEvent.touches.length and event.originalEvent.changedTouches.length but its always returned as 1.

Am I approaching this in the right way? How can I get the 2 values of pageX? And if there is a more optimum way of achieving the 2 points above, please tell me.

Thanks in advance.

user229044
  • 232,980
  • 40
  • 330
  • 338
sarveshs
  • 68
  • 1
  • 2
  • 9
  • well. event.originalEvent.touches and event.originalEvent.changedTouches is arrays of touches. 1 means you are just touching with one finger... – hfossli Feb 22 '12 at 22:09
  • see this page http://www.sitepen.com/blog/2008/07/10/touching-and-gesturing-on-the-iphone/ – hfossli Feb 22 '12 at 22:12

1 Answers1

0

I figured it out. Instead of using touchmove, I added the Jquery mobile library(http://jquerymobile.com/). It has a swipe event, as well as Swipe Left and Swipe Right event. This gives me the direction of the swipe. Still have not figured out the intensity part though.

sarveshs
  • 68
  • 1
  • 2
  • 9