Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top