Skip to content

Commit d729121

Browse files
committed
Complete Day 16 - Mouse Move Shadow
1 parent fc1fc93 commit d729121

2 files changed

Lines changed: 15 additions & 56 deletions

File tree

16 - Mouse Move Shadow/index-START.html

Lines changed: 0 additions & 41 deletions
This file was deleted.

16 - Mouse Move Shadow/index-FINISHED.html renamed to 16 - Mouse Move Shadow/index.html

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,31 @@
33
<head>
44
<meta charset="UTF-8">
55
<title>Mouse Shadow</title>
6-
<link rel="icon" href="https://fav.farm/" />
6+
<link rel="icon" href="https://fav.farm/🔥" />
77
</head>
88
<body>
99

1010
<div class="hero">
11-
<h1 contenteditable>🔥WOAH!</h1>
11+
<h1 contenteditable>🪷 Hey angela! 🪻</h1>
1212
</div>
1313

1414
<style>
1515
html {
1616
color: black;
17-
font-family: sans-serif;
17+
font-family:'Courier New', Courier, monospace;
1818
}
1919

2020
body {
2121
margin: 0;
22+
background-color: rgb(35, 35, 93);
2223
}
2324

2425
.hero {
2526
min-height: 100vh;
2627
display: flex;
2728
justify-content: center;
2829
align-items: center;
29-
color: black;
30+
color: rgb(248, 246, 246);
3031
}
3132

3233
h1 {
@@ -38,27 +39,26 @@ <h1 contenteditable>🔥WOAH!</h1>
3839
<script>
3940
const hero = document.querySelector('.hero');
4041
const text = hero.querySelector('h1');
41-
const walk = 500; // 500px
42+
const walk = 700; //700px
4243

4344
function shadow(e) {
4445
const { offsetWidth: width, offsetHeight: height } = hero;
4546
let { offsetX: x, offsetY: y } = e;
4647

47-
if (this !== e.target) {
48+
if(this !== e.target) {
4849
x = x + e.target.offsetLeft;
49-
y = y + e.target.offsetTop;
50+
y = y + e.target.offsetTop;
5051
}
5152

52-
const xWalk = Math.round((x / width * walk) - (walk / 2));
53-
const yWalk = Math.round((y / height * walk) - (walk / 2));
53+
const xWalk = Math.round((x/width * walk) - (walk/ 2));
54+
const yWalk = Math.round((y/height * walk) - (walk/ 2));
5455

5556
text.style.textShadow = `
56-
${xWalk}px ${yWalk}px 0 rgba(255,0,255,0.7),
57-
${xWalk * -1}px ${yWalk}px 0 rgba(0,255,255,0.7),
58-
${yWalk}px ${xWalk * -1}px 0 rgba(0,255,0,0.7),
59-
${yWalk * -1}px ${xWalk}px 0 rgba(0,0,255,0.7)
60-
`;
61-
57+
${xWalk}px ${yWalk}px 0 rgb(190, 190, 226),
58+
${xWalk * -1}px ${yWalk}px 0 rgb(126, 126, 179),
59+
${yWalk}px ${xWalk * -1}px 0 rgb(72, 72, 236),
60+
${yWalk * -1}px ${xWalk}px 0 rgb(186, 186, 211)
61+
`;
6262
}
6363

6464
hero.addEventListener('mousemove', shadow);

0 commit comments

Comments
 (0)