File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ $(document).ready(function () {
2222 }
2323
2424 // Listen for changes in the theme preference
25- window . matchMedia ( '(prefers-color-scheme: dark)' ) . addListener ( function ( e ) {
25+ window . matchMedia ( '(prefers-color-scheme: dark)' ) . addEventListener ( 'change' , function ( e ) {
2626 // Only update the theme based on prefers-color-scheme if 'data-theme' is 'auto' or not set
2727 if (
2828 ! $ ( 'body' ) . attr ( 'data-theme' ) ||
@@ -149,4 +149,18 @@ $(document).ready(function () {
149149 document . body . classList . toggle ( 'nav-open' ) ;
150150 document . getElementById ( 'navigation' ) . classList . toggle ( 'nav-is-active' ) ;
151151 } ) ;
152+
153+ // Remove classes to close the nav if screen size is larger than 992px
154+ function closeNav ( ) {
155+ if ( window . innerWidth > 992 ) {
156+ document . body . classList . remove ( 'nav-open' ) ;
157+ document . getElementById ( 'navigation' ) . classList . remove ( 'nav-is-active' ) ;
158+ hamburger . classList . remove ( 'is-active' ) ;
159+ }
160+ }
161+
162+ closeNav ( ) ;
163+
164+ $ ( window ) . on ( 'resize' , closeNav ) ;
165+
152166} ) ;
You can’t perform that action at this time.
0 commit comments