I am programming a little page using jquery.hammer.js and I have having problems getting the x and y coordinates of a touch event.
my code is as follows:
var x1, y1;
var element = document.getElementById("myDIV")
$(element).hammer().on("touch", function(e){
x1 = e.clientX
y1 = e.clientY
document.getElementById("resultDIV").innerHTML = x1 + " " + y1
}
but all I get is "undefined undefined" as my result.
i have everything i can think of, any help is much appreciated.
e.gesture
is deprecated now.
With the latest version of Hammer.js, you should use
var tapX, tapY;
tapX = e.center.x;
tapY = e.center.y;