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

Skip to content

Commit a174a1b

Browse files
committed
couple of changes to wesbos#16
1 parent dfdde2c commit a174a1b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

16 - Mouse Move Shadow/index-start.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,20 @@ <h1 contenteditable>🔥WOAH!</h1>
3838
<script>
3939
let text = document.querySelector('.hero h1');
4040
var rect = text.getBoundingClientRect();
41-
let {x: offsetWidth, y: offsetHeight} = rect;
41+
console.log('rect', rect);
42+
// let {x: offsetWidth, y: offsetHeight} = rect;
43+
let offsetWidth = (rect.right + rect.left) / 2;
44+
let offsetHeight = (rect.bottom + rect.top) / 2;
45+
console.log('width', offsetWidth);
46+
console.log('Height', offsetHeight);
4247
let x, y;
4348
window.addEventListener('mousemove', (e) => {
4449
x = e.x;
4550
y = e.y;
4651
console.log(x, y)
4752
// text.style.textShadow = `${x}px ${y}px 0 rgba(255,0,255,0.7);`
4853
// 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);`);
54+
text.setAttribute('style', `text-shadow: ${x > offsetWidth ? -.04 * (x - offsetWidth): .04 * (offsetWidth - x)}px ${y > offsetHeight ? -.04 * (y - offsetHeight): .04 * (offsetHeight - y)}px 0 rgba(255,0,255,0.7);`);
5055
})
5156
</script>
5257
</body>

0 commit comments

Comments
 (0)