zoukankan      html  css  js  c++  java
  • /touch滑屏事件

    //touch滑屏事件

        var windowHeight = $(window).height(),
        $body = $("body");
        $body.css("height", windowHeight);

        $("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");
            }
        });

  • 相关阅读:
    pytorch之dataloader深入剖析
    Pytorch多GPU并行处理
    鸡汤:做灯泡的
    数据工程师
    软实力
    七拼八凑的读书感
    深入一点儿
    Session的生命周期
    cloudera项目源代码
    Storm实时计算系统
  • 原文地址:https://www.cnblogs.com/xzzzys/p/8438801.html
Copyright © 2011-2022 走看看