I'm trying to bind an event to the touchstart, touchmove, and touchend properties that will track the location of the touch. Here's my code:
$('#container').bind('touchstart touchmove touchend', function (event) { updateFinger(event); });
And the update finger function:
var updateFinger = function(e)
{
e.preventDefault();
fingerX = e.data.x1;
fingerY = e.data.y1;
alert(fingerX + ' ' + fingerY);
}
I know the function is called, but from what I can tell, e.data.x1 and e.data.y1 don't exist (As well as .x). I'm using the code in the documentation, can anyone help me out with this?
EDIT: I fixed the problem, it turns out I was using the wrong code.
Instead of
e.data.x1
You need to use
e.touches[0].pageX
Instead of
e.data.x1
You need to use
e.touches[0].pageX