Skip to content

Commit dfdde2c

Browse files
committed
wesbos#16 my way
1 parent 76b50da commit dfdde2c

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

14 - JavaScript References VS Copying/index-START.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
// how do we take a copy instead?
4848

4949
// We will hopefully soon see the object ...spread
50-
50+
let person2 = {...person};
51+
console.log(person2);
5152
// Things to note - this is only 1 level deep - both for Arrays and Objects. lodash has a cloneDeep method, but you should think twice before using it.
5253

5354
</script>

16 - Mouse Move Shadow/index-finished.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ <h1 contenteditable>🔥WOAH!</h1>
5050

5151
const xWalk = Math.round((x / width * walk) - (walk / 2));
5252
const yWalk = Math.round((y / height * walk) - (walk / 2));
53-
53+
54+
// ${xWalk * -1}px ${yWalk}px 0 rgba(0,255,255,0.7),
55+
// ${yWalk * -1}px ${xWalk}px 0 rgba(0,0,255,0.7)
56+
// ${yWalk}px ${xWalk * -1}px 0 rgba(0,255,0,0.7)
5457
text.style.textShadow = `
55-
${xWalk}px ${yWalk}px 0 rgba(255,0,255,0.7),
56-
${xWalk * -1}px ${yWalk}px 0 rgba(0,255,255,0.7),
57-
${yWalk}px ${xWalk * -1}px 0 rgba(0,255,0,0.7),
58-
${yWalk * -1}px ${xWalk}px 0 rgba(0,0,255,0.7)
58+
${xWalk}px ${yWalk}px 0 rgba(255,0,255,0.7)
5959
`;
6060

6161
}

16 - Mouse Move Shadow/index-start.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,24 @@ <h1 contenteditable>🔥WOAH!</h1>
3030

3131
h1 {
3232
text-shadow: 10px 10px 0 rgba(0,0,0,1);
33+
/* text-shadow: 100px 10px 0 rgba(255,0,255,0.7); */
3334
font-size: 100px;
3435
}
3536
</style>
3637

3738
<script>
39+
let text = document.querySelector('.hero h1');
40+
var rect = text.getBoundingClientRect();
41+
let {x: offsetWidth, y: offsetHeight} = rect;
42+
let x, y;
43+
window.addEventListener('mousemove', (e) => {
44+
x = e.x;
45+
y = e.y;
46+
console.log(x, y)
47+
// text.style.textShadow = `${x}px ${y}px 0 rgba(255,0,255,0.7);`
48+
// text.style.cssText = `${x}px ${y}px 0 rgba(255,0,255,0.7);`
49+
text.setAttribute('style', `text-shadow: ${x > offsetWidth ? -.025 * (x - offsetWidth): .025 * (offsetWidth - x)}px ${y > offsetHeight ? -.025 * (y - offsetHeight): .025 * (offsetHeight - y)}px 0 rgba(255,0,255,0.7);`);
50+
})
3851
</script>
3952
</body>
4053
</html>

0 commit comments

Comments
 (0)