zoukankan      html  css  js  c++  java
  • 移动端touch滑屏事件

    <script>
    var windowHeight = $(window).height(),
    $body = $("body");
    // console.log($(window).height());
    // console.log($('body').height());
    $body.css("height", windowHeight);
    // console.log($('body').height());

    $("body").on("touchstart", function(e) {
    e.preventDefault();
    startX = e.originalEvent.changedTouches[0].pageX,
    startY = e.originalEvent.changedTouches[0].pageY;
    });
    $("body").on("touchmove", function(e) {
    e.preventDefault();
    moveEndX = e.originalEvent.changedTouches[0].pageX,
    moveEndY = e.originalEvent.changedTouches[0].pageY,
    X = moveEndX - startX,
    Y = moveEndY - startY;

    if ( Math.abs(X) > Math.abs(Y) && X > 10 ) {
    alert("left 2 right");
    }
    else if ( Math.abs(X) > Math.abs(Y) && X < 10 ) {
    alert("right 2 left");
    }
    else if ( Math.abs(Y) > Math.abs(X) && Y > 10) {
    alert("top 2 bottom");
    }
    else if ( Math.abs(Y) > Math.abs(X) && Y < 10 ) {
    alert("bottom 2 top");
    }
    else{
    alert("just touch");
    }
    });
    </script>
  • 相关阅读:
    Round robin
    Linux命令之nslookup
    VLAN
    基础网络概念
    python开发_filecmp
    python开发_stat
    python开发_fileinput
    python开发_os.path
    python开发_bisect
    python开发_copy(浅拷贝|深拷贝)_博主推荐
  • 原文地址:https://www.cnblogs.com/xzzzys/p/8046758.html
Copyright © 2011-2022 走看看