-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
153 lines (132 loc) · 4.16 KB
/
index.html
File metadata and controls
153 lines (132 loc) · 4.16 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<!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, maximum-scale=1.0, user-scalable=no">
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png">
<link rel="manifest" href="site.webmanifest">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Maven+Pro&display=swap" rel="stylesheet">
<title>MYDEAR</title>
<style>
html {
height: 100%;
font-family: 'Maven Pro', sans-serif;
}
body {
margin: 0;
padding: 0;
box-sizing: border-box;
width: 100%;
height: 100%;
position: relative;
}
.content {
position: relative;
z-index: 1;
height: 100%;
display: flex;
align-items: center;
padding: 0 4%;
}
.bg {
position: absolute;
z-index: 0;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgb(251, 114, 106);
background: linear-gradient(117deg, rgba(251, 114, 106, 1) 0%, rgba(255, 159, 75, 1) 100%);
}
.touchme {
position: absolute;
z-index: 1;
top: 1rem;
left: 1rem;
color: #fff;
}
.zone-heart {
position: absolute;
z-index: 2;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.heart {
position: absolute;
animation: pulse 1s ease infinite;
}
@keyframes pulse {
0% {
transform: scale(1);
}
50% {
transform: scale(1.3);
}
100% {
transform: scale(1);
}
}
.noselect {
-webkit-touch-callout: none;
/* iOS Safari */
-webkit-user-select: none;
/* Safari */
-khtml-user-select: none;
/* Konqueror HTML */
-moz-user-select: none;
/* Old versions of Firefox */
-ms-user-select: none;
/* Internet Explorer/Edge */
user-select: none;
/* Non-prefixed version, currently
supported by Chrome, Edge, Opera and Firefox */
}
</style>
</head>
<body>
<div class="content">
<img src="img/mydear.svg" width="100%" alt="">
</div>
<div class="bg">
</div>
<div class="zone-heart"></div>
<div class="touchme">
Touch me on everywhere ❤️
</div>
<script>
const zoneHeart = document.querySelector(".zone-heart")
console.log(zoneHeart);
function generateHeart(posX, posY) {
const colorsList = [1, 2, 3, 4, 5, 6]
const random = (length) => Math.floor(Math.random() * length)
const heartImg = document.createElement("img")
console.log(colorsList[random()]);
heartImg.src = `img/hearts/${colorsList[random(colorsList.length)]}.svg`
heartImg.width = "32"
heartImg.height = "32"
heartImg.classList.add("heart");
heartImg.classList.add("noselect");
heartImg.style.top = `${posY}px`
heartImg.style.left = `${posX}px`
zoneHeart.appendChild(heartImg)
setTimeout(() => {
zoneHeart.removeChild(heartImg)
}, 4000);
}
var pointerX = -1;
var pointerY = -1;
zoneHeart.onclick = function (event) {
pointerX = event.pageX;
pointerY = event.pageY;
generateHeart(pointerX, pointerY)
}
</script>
</body>
</html>