File tree Expand file tree Collapse file tree 5 files changed +56
-1
lines changed
Expand file tree Collapse file tree 5 files changed +56
-1
lines changed Original file line number Diff line number Diff line change 33< head >
44 < meta charset ="UTF-8 " />
55 < meta name ="viewport " content ="width=device-width, initial-scale=1.0 "/>
6+ < link rel ="icon " type ="image/svg+xml " href ="/favicon.svg ">
7+ < link rel ="alternate icon " href ="/favicon.ico ">
68 < title > Lochlan McElroy | Portfolio</ title >
79 < link rel ="preconnect " href ="https://fonts.googleapis.com "/>
810 < link rel ="preconnect " href ="https://fonts.gstatic.com " crossorigin />
@@ -155,6 +157,7 @@ <h2>WRAVEN: Student-run cybersecurity group @ WMU</h2>
155157 < p style ="margin: 0; font-family: var(--font-mono); text-align: center; "> © < span id ="currentYear "> </ span > Lochlan McElroy. All rights reserved.</ p >
156158 </ footer >
157159
160+ < script src ="/scroll-fix.js "> </ script >
158161 < script src ="/script1.js "> </ script >
159162 < script src ="/script2.js "> </ script >
160163</ body >
Original file line number Diff line number Diff line change 1+ // Prevent auto-scroll to terminal on page load while allowing scripts to run
2+ ( function ( ) {
3+ let preventScrolling = true ;
4+ let initialLoad = true ;
5+
6+ // Override focus to prevent auto-scroll during initial load
7+ const originalFocus = HTMLElement . prototype . focus ;
8+ HTMLElement . prototype . focus = function ( options ) {
9+ if ( preventScrolling && initialLoad ) {
10+ // Call focus but prevent scrolling during initial load
11+ return originalFocus . call ( this , { preventScroll : true } ) ;
12+ }
13+ return originalFocus . call ( this , options ) ;
14+ } ;
15+
16+ // Ensure we start at the top
17+ const ensureTopPosition = ( ) => {
18+ if ( initialLoad ) {
19+ window . scrollTo ( 0 , 0 ) ;
20+ document . documentElement . scrollTop = 0 ;
21+ document . body . scrollTop = 0 ;
22+ }
23+ } ;
24+
25+ // Handle immediate scroll prevention
26+ document . addEventListener ( 'DOMContentLoaded' , function ( ) {
27+ ensureTopPosition ( ) ;
28+
29+ // Continue preventing scroll for a short time to let scripts initialize
30+ setTimeout ( ( ) => {
31+ preventScrolling = false ;
32+ ensureTopPosition ( ) ; // One more time after scripts have loaded
33+ } , 500 ) ;
34+ } ) ;
35+
36+ // Final cleanup after full page load
37+ window . addEventListener ( 'load' , function ( ) {
38+ setTimeout ( ( ) => {
39+ initialLoad = false ;
40+ HTMLElement . prototype . focus = originalFocus ; // Restore original focus
41+ ensureTopPosition ( ) ; // Final position correction
42+ } , 100 ) ;
43+ } ) ;
44+ } ) ( ) ;
Original file line number Diff line number Diff line change 1- * , * ::before , * ::after {
1+ * , * ::before , * ::after {
22 box-sizing : border-box;
33 margin : 0 ;
44 padding : 0 ;
2424 line-height : 1.5 ;
2525 font-size : 16px ;
2626 overflow-x : hidden;
27+ /* Ensure page starts at top */
28+ scroll-behavior : smooth;
2729 }
2830 h1 , h2 , h3 , h4 , h5 , h6 {
2931 font-family : var (--font-mono );
276278 font-family : var (--font-mono );
277279 font-size : 0.9rem ;
278280 outline : none;
281+ /* Prevent automatic focusing on load */
282+ -webkit-user-modify : read-write-plaintext-only;
279283 }
280284
281285 @keyframes blink {
You can’t perform that action at this time.
0 commit comments