移动端拖动并点击,仿苹果手机小圆点

var isClick=true;
$('.memeber-listfix').each(function(index){
$(this).on('touchstart', function(evt) {
var e = event || evt;
disX = e.touches[0].clientX - this.offsetLeft;
disY = e.touches[0].clientY - this.offsetTop;
starX = e.touches[0].clientX;
starY = e.touches[0].clientY;
isClick=true;
}).on('touchmove', function(evt) {
var e = event || evt;
e.preventDefault();//阻止其余事件
// 若是这个元素的位置内只有一个手指的话
//console.log(e.targetTouches)
L = e.touches[0].clientX - disX;
T = e.touches[0].clientY - disY;
starXEnd = e.touches[0].clientX - starX;
starYEnd = e.touches[0].clientY - starY;
//console.log(L);
if (L < 0) {
L = 0;
} else if (L > document.documentElement.clientWidth - this.offsetWidth) {
L = document.documentElement.clientWidth - this.offsetWidth;
}
if (T < 0) {
T = 0;
} else if (T > document.documentElement.clientHeight - this.offsetHeight) {
T = document.documentElement.clientHeight - this.offsetHeight;
}
moveX = L + 'px';
moveY = T + 'px';
//console.log(moveX);
this.style.left = moveX;
this.style.top = moveY;
isClick=false;
}).on('touchend', function(evt) {
var e = event || evt;
e.preventDefault();//阻止其余事件
if(isClick==true){
window.location.href='javascript:history.go(-1)'
};
})
});
相关文章
相关标签/搜索