@@ -70,28 +70,60 @@ document.addEventListener("DOMContentLoaded", function () {
7070 document . addEventListener ( "click" , ( e ) => {
7171 if ( ! nav . contains ( e . target ) ) {
7272 navCheckbox . checked = false ;
73- selectButton . classList . add ( "blinking" ) ;
73+ // Reset button text when menu closes
74+ selectButton . textContent = originalText ;
7475 }
7576 } ) ;
7677
77- // Add blinking state management
78+ // Close menu when clicking overlay
79+ overlay . addEventListener ( "click" , function ( ) {
80+ navCheckbox . checked = false ;
81+ // Reset button text when menu closes
82+ selectButton . textContent = originalText ;
83+ } ) ;
84+
85+ // Close menu when clicking a link
86+ navLinks . forEach ( ( link ) => {
87+ link . addEventListener ( "click" , function ( ) {
88+ navCheckbox . checked = false ;
89+ // Reset button text when menu closes
90+ selectButton . textContent = originalText ;
91+ } ) ;
92+ } ) ;
93+
94+ // Simple animation management
7895 const selectButton = document . querySelector ( ".select-button" ) ;
96+ const originalText = "Select" ;
97+ const activeText = "Menu" ;
98+
99+ // Toggle button text based on menu state
100+ const updateButtonText = ( ) => {
101+ if ( navCheckbox . checked ) {
102+ selectButton . textContent = activeText ;
103+ } else {
104+ selectButton . textContent = originalText ;
105+ }
106+ } ;
107+
108+ // Listen for checkbox changes to update text
109+ navCheckbox . addEventListener ( "change" , updateButtonText ) ;
79110
111+ // Pause animation on hover
80112 selectButton . addEventListener ( "mouseenter" , ( ) => {
81- selectButton . classList . remove ( "blinking" ) ;
113+ selectButton . style . animation = 'none' ;
82114 } ) ;
83115
84116 selectButton . addEventListener ( "mouseleave" , ( ) => {
85117 if ( ! navCheckbox . checked ) {
86- selectButton . classList . add ( "blinking" ) ;
118+ selectButton . style . animation = '' ;
87119 }
88120 } ) ;
89121
122+ // Resume animation after navigation
90123 document . querySelector ( ".dropdown" ) . addEventListener ( "click" , ( e ) => {
91124 if ( e . target . matches ( "a" ) ) {
92- // Resume blinking after navigation
93125 setTimeout ( ( ) => {
94- selectButton . classList . add ( "blinking" ) ;
126+ selectButton . style . animation = '' ;
95127 } , 100 ) ;
96128 }
97129 } ) ;
0 commit comments