1.源码:
.divFixed {
width: 100px;
height: 100px;
font-size: 15px;
text-align: center;
border: 2px solid red;
position: fixed;
}
var divOne = document.getElementById('divOne');
var isMove = false;
var oldX = oldY = 0;
divOne.addEventListener('touchstart', function (e) {
if (e.targetTouches.length == 1) {
var touch = e.targetTouches[0];
isMove = true;
oldX = touch.pageX;
oldY = touch.pageY;
divOne.style.background = "gray";
}
}, false);
divOne.addEventListener('touchmove', function (e) {
if (e.targetTouches.length == 1) {
var touch = e.targetTouches[0];
if (isMove) {
var curX = touch.pageX;