1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| function handleTouchEvent(event) { if (event.touches.length == 1) { var output = document.getElementById("output"); switch (event.type) { case "touchstart": output.innerHTML = "Touch started (" + event.touches[0].clientX + "," + event.touches[0].clientY + ")"; break; case "touchend": output.innerHTML += "Touch ended (" + event.changedTouches[0].clientX + "," + event.changeTouches[0].clientY + ")"; break; case "touchmove": event.preventDefault(); output.innerHTML += "Touch moved (" + event.changedTouches[0].clientX + "," + event.changedTouches[0].clientY + ")"; break; } } } document.addEventListener("touchstart", handleTouchEvent, false); document.addEventListener("touchend", handleTouchEvent, false); document.addEventListener("touchmove", handleTouchEvent, false);
|