监听移动端手势滑动方向

           var startY = 0;
            document.addEventListener("touchstart",function(e){
                startY = e.changedTouches[0].pageY;
            },false);
            document.addEventListener("touchend",function(e){
                var endY = e.changedTouches[0].pageY;
                var changeVal = endY - startY;
                if(endY < startY){//向上滑
                    alert('向上滑');
                }else if(endY > startY){//向下滑
                   alert('向下滑');
                }else{
                    alert("没有偏移");
                }
            },false);

你可能感兴趣的:(监听移动端手势滑动方向)