File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,29 @@ <h1 contenteditable>🔥WOAH!</h1>
3535 </ style >
3636
3737< script >
38+ const hero = document . querySelector ( '.hero' ) ;
39+ const text = document . querySelector ( 'h1' ) ;
40+ const walk = 30 ;
41+
42+ function shadow ( e ) {
43+ const { offsetWidth : width , offsetHeight : height } = hero ;
44+ let { offsetX : x , offsetY : y } = e ;
45+
46+ if ( this !== e . target ) {
47+ x = x + e . target . offsetLeft ;
48+ y = y + e . target . offsetTop ;
49+ }
50+
51+ const xWalk = Math . round ( ( x / width * walk ) - ( walk / 2 ) ) ;
52+ const yWalk = Math . round ( ( y / height * walk ) - ( walk / 2 ) ) ;
53+ const bWalk = Math . round ( Math . abs ( xWalk ) + Math . abs ( yWalk ) / 2 ) ;
54+
55+ text . style . textShadow = `${ xWalk } px ${ yWalk } px ${ bWalk } px grey` ;
56+
57+ console . log ( text . style . textShadow ) ;
58+ }
59+
60+ hero . addEventListener ( 'mousemove' , shadow ) ;
3861</ script >
3962</ body >
4063</ html >
You can’t perform that action at this time.
0 commit comments