touchend javasccript event not working

So I came to find out today that I think the touchend event has a pageX and pageY populated in Safari, but not in the Android browser.

Here's the code.


if (canvas.addEventListener) {
canvas.addEventListener("mousedown", function(e) {
   click(e.pageX, e.pageY);
}, false);
canvas.addEventListener("touchstart", function(e) {
   e.preventDefault();
   click(e.touches[0].pageX, e.touches[0].pageY);
}, false);
}

Originally, I was using e.pageX and e.pageY and it worked on chrome (desktop) and mobile safari, but it was failing on a Samsung device.  So, reading about the touchend event on Mozilla, I found that there is a touches array with the list of touches.  That was populated on a mobile.

Comments

Popular Posts