zoukankan      html  css  js  c++  java
  • wap手机端按下 松开 滑动事件

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"        name="viewport" /> 
        <script type="text/javascript">
            function a() {
                var mdiv = document.getElementById("mdiv");
                var mdiv2 = document.getElementById("mdiv2");
                var mdiv3 = document.getElementById("mdiv3");
                var m = Math, 
                isTouchPad = (/hp-tablet/gi).test(navigator.appVersion), 
                hasTouch = 'ontouchstart' in window && !isTouchPad,
                START_EV = hasTouch ? 'touchstart' : 'mousedown',
             MOVE_EV = hasTouch ? 'touchmove' : 'mousemove',
             END_EV = hasTouch ? 'touchend' : 'mouseup',
             CANCEL_EV = hasTouch ? 'touchcancel' : 'mouseup';
                mdiv.addEventListener(MOVE_EV, function (e) {
                    var point = hasTouch ? e.touches[0] : e;
                    mdiv3.innerHTML = "X:" + point.pageX + ";Y:" + point.pageY + "";
                }, false);
                mdiv.addEventListener(START_EV, function (e) {
                    var point = hasTouch ? e.touches[0] : e;
                    mdiv2.innerHTML = "BeginX:" + point.pageX + ";BeginY:" + point.pageY + "<br/>";
                }, false);
                mdiv.addEventListener(END_EV, function (e) {
                    var point = hasTouch ? e.changedTouches[0] : e;
                    mdiv2.innerHTML +=( "EndX:" + point.pageX + ";EndY:" + point.pageY + "");
                }, false);
            }
        </script>
    </head>
    <body onload="a()">
    <div style="border: solid 1px #000000; background: #ffffff;  100%; height: 299px; margin:auto" id="mdiv"> 
        <div id="mdiv3"> </div>
        <div id="mdiv2"></div>
    </div>
    </body>
    </html>
  • 相关阅读:
    C# 杨辉三角 下
    C# 自动走迷宫 下
    算法练习之1数字填充 下
    动态添加控件并获取其值
    两个ListBox的互动
    VS2005常用快捷键
    GridView内嵌DropDownList操作
    GridView格式化短日期
    获得客户端ID
    Access数据库 Update 语句的怪现象
  • 原文地址:https://www.cnblogs.com/fanxiaowu/p/4510549.html
Copyright © 2011-2022 走看看