aoldman

 

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;
};

分类:

技术点:

相关文章:

  • 2021-12-23
  • 2021-12-23
  • 2021-06-30
  • 2021-12-23
  • 2022-02-14
猜你喜欢
  • 2021-12-23
  • 2021-12-23
  • 2022-12-23
  • 2021-08-22
  • 2021-07-10
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案