移动端touch事件
作者:互联网
var startX = startY = endX = endY = 0;
var dom = document.getElementById('main');
//touchStart事件
dom.addEventListener('touchstart',function(event){
var touch = event.targetTouches[0];
startX = touch.pageX;
startY = touch.pageY;
document.getElementById('start').value = startX + ',' + startY;
},false);
//touchmove事件
dom.addEventListener('touchmove',function(event){
var touch = event.targetTouches[0];
endX = touch.pageX;
endY = touch.pageY;
},false);
//touchend事件
dom.addEventListener('touchend',function(event){
document.getElementById('end').value = endX + ',' + endY;
document.getElementById('count').value = (endX - startX) + ',' + (endY - startY);
},false);
标签:startX,startY,document,var,事件,touch,移动,event 来源: https://www.cnblogs.com/anna001/p/14866921.html