移動端觸摸事件及對象

來源:互聯網
上載者:User

標籤:document   screen   text   init   max   change   client   add   start   

<!DOCTYPE html>
  <html>
    <head>
      <meta charset="utf-8">
      <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
      <title></title>
    </head>
  <body>
    <div class="one">hehehehehehe</div>
    <div class="two">hahhahhahaha</div>
    <script type="text/javascript">
      /*
        *clientX:觸摸目標在視口中的x座標。
        *clientY:觸摸目標在視口中的y座標。
        *identifier:標識觸摸的唯一ID。
        *pageX:觸摸目標在頁面中的x座標。
        *pageY:觸摸目標在頁面中的y座標。
        *screenX:觸摸目標在螢幕中的x座標。
        *screenY:觸摸目標在螢幕中的y座標。
         *target:觸目的DOM節點目標。
        *touches:touch對象,裡麵包含的是一些座標資訊。
        * targetTouches:touch對象,包含座標資訊,具體情況不清楚,如果length代表了手指的數量。
        * changedTouches:touch對象,包含座標資訊,具體情況不清楚。
      * */
      //監聽手指滑動
      document.addEventListener(‘touchmove‘, function(event){
        // var x = event.touches[0].clientX;
        // var y = event.touches[0].clientY;
        // var identifier = event.touches[0].identifier;
        // var pageX = event.touches[0].pageX;
        // var pageY = event.touches[0].pageY;
        // var screenX = event.touches[0].screenX;
        // var screenY = event.touches[0].screenY;
        // var target = event.touches[0].target;
        // console.log(x,y,identifier,pageX,pageY,screenX,screenY,target)
        console.log(event.targetTouches.length)
        //console.log(‘2:‘,event.changedTouches)
      });
      //監聽觸摸
      //document.addEventListener(‘touchstart‘, function(event) {
        // alert(1)
      //});
      //監聽觸摸結束
      //document.addEventListener(‘touchend‘, function(){
        // alert(3)
      // });
    </script>

  </body>
</html>

移動端觸摸事件及對象

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.