zoukankan      html  css  js  c++  java
  • HTML5触摸事件(touchstart、touchmove和touchend)

    http://blog.csdn.net/kaikai4/article/details/46840317

    http://blog.csdn.net/fuqinyijiu/article/details/41315123

    //例子

    $("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 > 0 ) {
            alert("left 2 right");
        }
        else if ( Math.abs(X) > Math.abs(Y) && X < 0 ) {
            alert("right 2 left");
        }
        else if ( Math.abs(Y) > Math.abs(X) && Y > 0) {
            alert("top 2 bottom");
        }
        else if ( Math.abs(Y) > Math.abs(X) && Y < 0 ) {
            alert("bottom 2 top");
        }
        else{
            alert("just touch");
        }
    });
  • 相关阅读:
    lucene4 Filter
    lucene Query
    MyEclipse 中各种 libraries 的含义
    CRF++使用小结
    链表的输入与输出

    数据结构队列的各种操作
    设置背景颜色
    JavaScript由单价、数量计算总价
    中文和拼音自动转换的输入框
  • 原文地址:https://www.cnblogs.com/annie211/p/6944845.html
Copyright © 2011-2022 走看看