Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 78a3749

Browse files
author
Jin Xu
committed
course wesbos#16 finished
1 parent eb98f0e commit 78a3749

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

16 - Mouse Move Shadow/index-start.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,23 @@ <h1 contenteditable>🔥WOAH!</h1>
2525
}
2626

2727
h1 {
28-
text-shadow: 10px 10px 0 rgba(0,0,0,1);
28+
text-shadow: 10px 10px 0 rgba(0,0,0,.3);
2929
font-size: 100px;
3030
}
3131
</style>
3232

3333
<script>
34+
const target = document.querySelector('h1[contenteditable]');
35+
const center = [(target.offsetLeft + target.offsetWidth / 2), (target.offsetTop + target.offsetHeight / 2)]
36+
console.log(center);
37+
38+
39+
window.addEventListener('mousemove', e => {
40+
shadow = [ - e.pageX + center[0], center[1] - e.pageY];
41+
console.log(shadow);
42+
target.style.textShadow = `${shadow[0] * .2}px ${shadow[1] * .2}px 0 rgba(5,100,100,.5),
43+
${shadow[0] * .3}px ${shadow[1] * .3}px 0 rgba(5,5,100,.3)`;
44+
})
3445
</script>
3546
</body>
3647
</html>

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
13. [x] ~~Slide in on Scroll~~
2020
14. [x] ~~JavaScript References vs. Copying~~
2121
15. [x] ~~LocalStorage~~
22-
16. [ ] Mouse Move Shadow
22+
16. [x] ~~Mouse Move Shadow~~
2323
17. [ ] Sort Without Articles
2424
18. [ ] Adding Up Times with Reduce
2525
19. [ ] Webcam Fun

0 commit comments

Comments
 (0)