Skip to content

Commit 99d2cce

Browse files
committed
💩
1 parent a0451b1 commit 99d2cce

File tree

2 files changed

+63
-27
lines changed

2 files changed

+63
-27
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
28+
h1 {
29+
text-shadow: 10px 10px 0 rgba(0,0,0,1);
30+
font-size: 100px;
31+
}
32+
</style>
33+
34+
<script>
35+
const hero = document.querySelector('.hero');
36+
const text = hero.querySelector('h1');
37+
const walk = 500; // 100px
38+
39+
function shadow(e) {
40+
const { offsetWidth: width, offsetHeight: height } = hero;
41+
let { offsetX: x, offsetY: y } = e;
42+
43+
if (this !== e.target) {
44+
x = x + e.target.offsetLeft;
45+
y = y + e.target.offsetTop;
46+
}
47+
48+
const xWalk = Math.round((x / width * walk) - (walk / 2));
49+
const yWalk = Math.round((y / height * walk) - (walk / 2));
50+
51+
text.style.textShadow = `
52+
${xWalk}px ${yWalk}px 0 rgba(255,0,255,0.7),
53+
${xWalk * -1}px ${yWalk}px 0 rgba(0,255,255,0.7),
54+
${yWalk}px ${xWalk * -1}px 0 rgba(0,255,0,0.7),
55+
${yWalk * -1}px ${xWalk}px 0 rgba(0,0,255,0.7)
56+
`;
57+
58+
}
59+
60+
hero.addEventListener('mousemove', shadow);
61+
</script>
62+
</body>
63+
</html>

16 - Mouse Move Shadow/index-start.html

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,40 +24,13 @@ <h1 contenteditable>🔥WOAH!</h1>
2424
color:black;
2525
}
2626

27-
2827
h1 {
2928
text-shadow: 10px 10px 0 rgba(0,0,0,1);
3029
font-size: 100px;
3130
}
3231
</style>
3332

3433
<script>
35-
const hero = document.querySelector('.hero');
36-
const text = hero.querySelector('h1');
37-
const walk = 500; // 100px
38-
39-
function shadow(e) {
40-
const { offsetWidth: width, offsetHeight: height } = hero;
41-
let { offsetX: x, offsetY: y } = e;
42-
43-
if (this !== e.target) {
44-
x = x + e.target.offsetLeft;
45-
y = y + e.target.offsetTop;
46-
}
47-
48-
const xWalk = Math.round((x / width * walk) - (walk / 2));
49-
const yWalk = Math.round((y / height * walk) - (walk / 2));
50-
51-
text.style.textShadow = `
52-
${xWalk}px ${yWalk}px 0 rgba(255,0,255,0.7),
53-
${xWalk * -1}px ${yWalk}px 0 rgba(0,255,255,0.7),
54-
${yWalk}px ${xWalk * -1}px 0 rgba(0,255,0,0.7),
55-
${yWalk * -1}px ${xWalk}px 0 rgba(0,0,255,0.7)
56-
`;
57-
58-
}
59-
60-
hero.addEventListener('mousemove', shadow);
6134
</script>
6235
</body>
6336
</html>

0 commit comments

Comments
 (0)