手机端html滑动处理

$('.pushJie').on('touchstart',touchStartFun).on('touchmove',touchmoveFun).on('touchend',touchendFun);

function touchStartFun(e){
        e.preventDefault();
        touchStartX = e.originalEvent.changedTouches[0].pageX;
        touchStartY = e.originalEvent.changedTouches[0].pageY;
    }
    function touchmoveFun(e){
        e.preventDefault();
        endX = e.originalEvent.changedTouches[0].pageX;
        endY = e.originalEvent.changedTouches[0].pageY;
        //获取滑动距离
        distanceX = touchStartX-endX;
        distanceY = touchStartY-endY;
    }
 function touchendFun(e){
        e.preventDefault();
    //处理业务
}

 

你可能感兴趣的:(手机端html滑动处理)