Skip to content

Commit 83520de

Browse files
committed
16 done
1 parent 733cf77 commit 83520de

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Mouse Shadow</title>
6+
</head>
7+
<body>
8+
9+
<div class="hero">
10+
<h1 contenteditable>🔥WOAH!</h1>
11+
</div>
12+
13+
<style>
14+
html {
15+
color:black;
16+
font-family: sans-serif;
17+
}
18+
19+
.hero {
20+
min-height: 100vh;
21+
display:flex;
22+
justify-content: center;
23+
align-items: center;
24+
color:black;
25+
}
26+
27+
h1 {
28+
text-shadow: 10px 10px 0 rgba(0,0,0,1);
29+
font-size: 100px;
30+
}
31+
</style>
32+
33+
<script>
34+
const hero = document.querySelector('.hero');
35+
const text = hero.querySelector('h1');
36+
const walk = 100;
37+
38+
function shadow(e) {
39+
const { offsetWidth: width, offsetHeight: height } = hero;
40+
let { offsetX: x, offsetY: y } = e;
41+
if (this !== e.target) {
42+
x = x + e.target.offsetLeft;
43+
y = y + e.target.offsetTop;
44+
}
45+
const xWalk = Math.round((x / width * walk) - (walk / 2));
46+
const yWalk = Math.round((y / height * walk) - (walk / 2));
47+
text.style.textShadow = `${xWalk}px ${yWalk}px 0 red`;
48+
}
49+
50+
hero.addEventListener('mousemove', shadow);
51+
</script>
52+
</body>
53+
</html>

0 commit comments

Comments
 (0)