-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheart.html
More file actions
117 lines (111 loc) · 3.59 KB
/
heart.html
File metadata and controls
117 lines (111 loc) · 3.59 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" id="viewport" name="viewport">
<meta content="yes" name="apple-mobile-web-app-capable"/>
<meta content="black" name="apple-mobile-web-app-status-bar-style"/>
<meta content="telephone=no" name="format-detection"/>
<meta content="email=no" name="format-detection"/>
<title>手不离开 心跳不止 乌鸦出品</title>
<style>
*{
margin: 0px;
padding: 0px;
}
body{
text-align: center;
}
#v{
width: 100%;
font-size: 28px;
}
#canvas{
width:300px;
height:200px;
margin:0 auto;
margin-top: 10px;
}
@-webkit-keyframes pound {
30% { -webkit-transform: scale(2); }
}
.heart{
display: inline-block;
margin: 20% auto;
font-size: 80px;
color: #e00;
}
.heartOK{
display: inline-block;
margin: 20% auto;
font-size: 80px;
color: #e00;
-webkit-transform-origin: center;
-webkit-animation: pound 1s infinite;
}
</style>
<script>
var v=0;
var isheart=false;
window.onload = function() {
window.addEventListener('touchstart', function (e) {
var touchobj = e.changedTouches[0] // reference first touch point (ie: first finger)
startx = parseInt(touchobj.clientX) // get x position of touch point relative to left edge of browser
starty = parseInt(touchobj.clientY) // get x position of touch point relative to left edge of browser
//statusdiv.innerHTML = 'Status: touchstart<br /> ClientX: ' + startx + 'px'
isheart=true;
document.getElementById("heart").setAttribute("class","heartOK");
e.preventDefault()
}, false);
window.addEventListener('touchmove', function (e) {
var touchobj = e.changedTouches[0] // reference first touch point for this event
//gameCtrl.player.x+=distX;
//gameCtrl.player.y+=distY;
//statusdiv.innerHTML = 'Status: touchmove<br /> Horizontal distance traveled: ' + dist + 'px'
e.preventDefault()
}, false);
window.addEventListener('touchend', function (e) {
var touchobj = e.changedTouches[0] // reference first touch point for this event
//statusdiv.innerHTML = 'Status: touchend<br /> Resting x coordinate: ' + touchobj.clientX + 'px'
var distX = parseInt(touchobj.clientX) - startx;
var distY = parseInt(touchobj.clientY) - starty;
var tmp=0;
if (distX > document.body.scrollWidth/3) {
//right
}
if (distX < -document.body.scrollWidth/3) {
//left
}
if (distY > document.body.scrollWidth/3) {
//down
}
if (distY < -document.body.scrollWidth/3) {
//up
}
isheart=false;
document.getElementById("heart").setAttribute("class","heart");
e.preventDefault()
}, false);
//
}
setInterval(function(){
if(isheart){
document.getElementById("v").innerHTML="我坚持了"+(v++)+"秒";
}else{
v=0;
}
},1000)
</script>
</head>
<body>
<div id="v"></div>
<div id="canvas">
<div id="heart" class="heart">♥</div>
</div>
<div style="margin:10px 0px 0px 0px;line-height:25px;">
<p>乌鸦出品,我喂自己袋盐。。。</p>
<p>请用手指触摸屏幕的任意地方不要离开。</p>
<p>加我微信:daxiongbeijing2011</p>
</div>
</body>
</html>