-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
118 lines (111 loc) · 3.25 KB
/
index.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
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
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Te Observo</title>
</head>
<body>
<div class="emoji">
<div class="head">
<div class="eye left-eye">
<div class="eye-ball"></div>
</div>
<div class="eye right-eye">
<div class="eye-ball"></div>
</div>
<div class="mouth">
<div class="tongue"></div>
</div>
</div>
</div>
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.emoji {
width: 100vw;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
.head {
box-shadow: -20px 20px 25px 10px #000;
background: linear-gradient(#d0d343, #b68c01);
width: 500px;
height: 500px;
border-radius: 50%;
position: relative;
}
.eye {
position: absolute;
background-color: #fff;
width: 100px;
height: 75px;
border-radius: 50%;
}
.left-eye {
top: 130px;
left: 70px;
}
.right-eye {
top: 130px;
right: 70px;
}
.eye-ball {
display: flex;
background-color: #000;
width: 60px;
height: 60px;
border-radius: 50%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.mouth {
background-color: #000;
width: 250px;
height: 125px;
border-radius: 50%;
position: absolute;
top: 300px;
left: 125px;
display: flex;
justify-content: center;
align-items: end;
}
.tongue {
display: flex;
margin-bottom: -10px;
background-color: red;
width: 125px;
height: 50px;
border-radius: 50%;
}
</style>
<script>
const emoji = document.querySelector('.emoji');
const eyeBalls = document.querySelectorAll('.eye-ball');
// evento do mouse passando por cima do emoji
emoji.addEventListener("mousemove", (event) => {
const mouseX = event.clientX - emoji.getBoundingClientRect().left;
const mouseY = event.clientY - emoji.getBoundingClientRect().top;
const eyeX = mouseX / emoji.offsetWidth - 0.5;
const eyeY = mouseY / emoji.offsetHeight - 0.5;
eyeBalls.forEach((eyeBall) => {
eyeBall.style.transform = `translate(-50%, -50%) translate(${eyeX * 50}px, ${eyeY * 40}px)`;
});
});
// evento do clique na tela que faz com que o código retorne para o modo inicial....
emoji.addEventListener("click",() => {
eyeBalls.forEach((eyeBall) => {
eyeBall.style.transform = `translate(-50%, -50%)`;
});
});
</script>
</body>
</html>