zoukankan      html  css  js  c++  java
  • 学习记录:touch事件的坐标获取

    touch 事件获取坐标

    jq:

    $('#id').on('touchstart',function(e) {
      var _touch = e.originalEvent.targetTouches[0];
      var _x= _touch.pageX;
    });
    
    $('#id').on('touchmove',function(e) {
      var _touch = e.originalEvent.targetTouches[0];
      var _x= _touch.pageX;
    });
    
    $('#id').on('touchend',function(e) {
      var _touch = e.originalEvent.changedTouches[0];
      var _x= _touch.pageX;
    }
    

      


    js:

    document.getElementById("id").addEventListener("touchstart",function(e){
        var _x=e.touches[0].pageX;
        var _y=e.touches[0].pageY;
        console.log("start",_x);
    });
    document.getElementById("id").addEventListener("touchmove",function(e){
        var _x=e.touches[0].pageX;
        var _y=e.touches[0].pageY;
        console.log("move",_x);
    });
    document.getElementById("id").addEventListener("touchend",function(e){
        var _x=e.changedTouches[0].pageX;
        var _y=e.changedTouches[0].pageY;
        console.log("end",_x);
    });
    

      


    相关解释:

    targetTouches 表示的是手指列表
    changedTouches 表示的是手指事件 ,在 touchend 里就是手指离开

  • 相关阅读:
    arrayPointer
    shellAPP
    docker
    程序运行时内存管理
    C++ deepin
    coreOS+Docker新一代企业轻量级Linux
    玩转docker
    古典小说丛书系列软件
    读《追随智慧》(一)
    高速基于echarts的大数据可视化
  • 原文地址:https://www.cnblogs.com/grey-zhou/p/5895159.html
Copyright © 2011-2022 走看看