设为首页 加入收藏

TOP

移动端触摸
2019-08-30 00:37:50 】 浏览:42
Tags:移动 触摸
  var div=document.querySelector("div");
        var startX,startY,moveX,moveY,distanceX,distanceY;
        // 开始触摸
        div.addEventListener("touchstart",function(e){
            startX=e.targetTouches[0].clientX;
            startY=e.targetTouches[0].clientY;

        })
        // 触摸滑动 持续触发
        div.addEventListener("touchmove",function(e){
            moveX=e.targetTouches[0].clientX;
            moveY=e.targetTouches[0].clientY;
            distanceX=moveX-startX;
            distanceY=moveY-startY;
            div.style.transform="translate("+distanceX+"px,"+distanceY+"px)";
        });
        // 触摸结束
        div.addEventListener("touchend",function(e){

        })

  

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇react-native环境搭建 下一篇Android项目实战登录&注册

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目