• JQuery 获取touchstart,touchmove,touchend 坐标


    JQuery写法:

    $('#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;
    }
    原生写法:
    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)
    })
  • 相关阅读:
    tab点击切换
    下拉收起
    倒计时
    边框三角形
    jQuery Easing 使用方法及其图解
    网址收藏
    Java遍历Map对象的四种方式
    idea初使用之自动编译
    Mysql 存储引擎中InnoDB与Myisam的主要区别
    spring-boot-devtools在Idea中热部署方法
  • 原文地址:https://www.cnblogs.com/shentao11023/p/7825950.html
Copyright © 2020-2023  润新知