移动端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);
上一篇:大型网站技术架构——核心原理与案例分析(二)


下一篇:4-学会刷Wi-Fi模块固件(刷AT指令固件)