-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path11-移动端常用手势实现.html
74 lines (74 loc) · 1.8 KB
/
11-移动端常用手势实现.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body {
margin: 0;
}
#wrap {
margin: 20vh auto 0;
width: 260px;
height: 50vh;
border: 1px solid #000;
overflow: hidden;
}
#list {
margin: 0;
padding: 10px 5px;
list-style: none;
font: 16px/2 "宋体";
}
#list li {
border-bottom: 1px solid #000;
}
</style>
</head>
<body>
<div id="wrap">
<ul id="list"></ul>
</div>
<button id="press">长按</button>
<button id="tap">点击</button>
<button id="btn">正常</button>
<script>
{
let list = document.querySelector("#list");
list.innerHTML = [...(".".repeat(100))].map((item,index)=>`<li>这是第${index}个li</li>`).join("");
}
</script>
<script src="js/gesture.js"></script>
<script>
{
let list = document.querySelector("#list");
enableGesture(list);
list.addEventListener("panstart",(e)=>{
console.log("panstart");
});
list.addEventListener("pan",(e)=>{
console.log("pan");
});
list.addEventListener("panend",(e)=>{
console.log("panend");
});
enableGesture(press);
press.addEventListener("pressstart",()=>{
console.log("pressstart");
});
press.addEventListener("pressend",()=>{
console.log("presend");
});
press.addEventListener("presscancel",()=>{
console.log("presscancel");
});
enableGesture(tap);
tap.addEventListener("tap",()=>{
console.log("tap");
})
}
</script>
</body>
</html>