-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtouch.html
34 lines (32 loc) · 970 Bytes
/
touch.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>touch</title>
<style>
body,html{width: 100%;height:100%;}
#container{width:100%;height: 100%;background: #ccc;}
</style>
</head>
<body>
<div id="container"></div>
<script>
var startx,starty,endx,endy,movex,movey;
document.getElementById("container").addEventListener('touchstart',function(event){
starty = event.targetTouches[0].clientY;
//console.log(event.targetTouches);
})
document.getElementById("container").addEventListener('touchend',function(event){
console.log(event.changedTouches);
endx = event.changedTouches[0].clientX;
endy = event.changedTouches[0].clientY;
movey = endy > starty ? endy - starty : starty - endy;
if(movey > 80){
console.log('滚动一页'+movey)
}else{
console.log('高度不够'+movey);
}
})
</script>
</body>
</html>