-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrackingeyes.html
More file actions
110 lines (95 loc) · 2.87 KB
/
trackingeyes.html
File metadata and controls
110 lines (95 loc) · 2.87 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body {
padding: 0;
margin: 0;
box-sizing: border-box;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
/* background: ; */
}
.emoji-face {
position: relative;
width: 200px;
height: 200px;
background: transparent;
/* background: rgba(255,255,0,0.683); */
border: 5px solid black;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
transition: 0.5s;
}
/*
.emoji-face::before {
content: '';
top: 180px;
position: absolute;
width: 150px;
background: crimson;
height: 70px;
border-bottom-left-radius: 70px;
border-bottom-right-radius: 70px;
transition: 0.5s;
} */
.eyes {
position: relative;
width: 100px;
height: 100px;
display: flex;
justify-content: center;
align-items: center;
border: 5px solid black;
border-radius: 100%;
}
.eyes .eye {
position: relative;
width:100%;
height: 100%;
display: block;
background: white;
border-radius: 50%;
}
.eyes .eye::before {
content: '';
position: absolute;
top: 50%;
left: 25px;
transform: translate(-50%, -50%);
width: 20px;
height: 20px;
border-radius: 50%;
background: #000;
}
</style>
</head>
<body>
<!-- <div class="emoji-face"> -->
<div class="eyes">
<div class="eye"></div>
<!-- <div class="eye"></div> -->
</div>
<!-- </div> -->
<script>
document.querySelector('body').addEventListener("mousemove", eyeball);
function eyeball() {
let eyes = document.querySelectorAll(".eye")
eyes.forEach(eye => {
let x = eye.getBoundingClientRect().left + eye.clientWidth / 2;
let y = eye.getBoundingClientRect().top + eye.clientHeight / 2;
let radian = Math.atan2(event.pageX - x, event.pageY - y)
let rotate = radian * (180 / Math.PI) * -1 + 270;
eye.style.transform = `rotate(${rotate}deg)`;
})
}
</script>
</body>
</html>