js webapp 滑动事件

var startX, startY, endX, endY;

$(".detailImg").on("touchstart", touchStart);
$(".detailImg").on("touchmove", touchMove);
$(".detailImg").on("touchend", touchEnd);

function touchStart(event) {
    var touch = event.originalEvent.targetTouches[0];
    startX = touch.pageX;
    event.preventDefault();//在andorid下不触发touchend解决方案
};
function touchMove(event) {
    var touch = event.originalEvent.targetTouches[0];
    endX = (startX - touch.pageX);
};
function touchEnd(event) {
    if (endX > 10)
        nextImgCallBack();
    else if (endX < -10)
        proImgCallBack();

endX = 0; startX = 0;
};

上一篇:开始QT+OpenCV学问


下一篇:AutoHotKey实现将站点添加到IE的Intranet本地站点