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){ })