Skip to content

Commit

Permalink
Enable scrolling in opened mobile navigation (#768)
Browse files Browse the repository at this point in the history
  • Loading branch information
albig authored Nov 13, 2024
1 parent 1f45be3 commit 1bfda23
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
12 changes: 12 additions & 0 deletions assets/js/frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,16 @@ jQuery( '.dropdown .dropdown-toggle' ).on( 'click', function () {

return false;
} );

jQuery( function () {
jQuery( '.navbar-toggler' ).click( function () {
if ( jQuery( '.navbar-toggler' ).hasClass( 'collapsed' ) ) {
window.setTimeout( () => {
jQuery( 'body' ).removeClass( 'navbar-open' );
}, 100 );
} else {
jQuery( 'body' ).addClass( 'navbar-open' );
}
} );
} );
/* eslint-enable no-undef */
8 changes: 7 additions & 1 deletion sass/_navigation.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
body.navbar-open {
overflow: hidden;
}

@include media-breakpoint-up(lg) {

.navbar {
Expand Down Expand Up @@ -334,7 +338,6 @@
border-radius: 4px;
margin-right: 0;
margin-top: -4px;
overflow: hidden;
list-style-type: none;
background-color: $white;
padding: 0;
Expand Down Expand Up @@ -419,6 +422,9 @@
&.collapsing,
&.collapse.show {

max-height: 90vh;
overflow: auto;

.navbar-nav {
align-items: normal;

Expand Down
14 changes: 0 additions & 14 deletions template-parts/header-personal.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,3 @@
?>
</div>
</nav>

<script>
jQuery(document).ready( function (){
jQuery('.navbar-toggler').click(function(){
if(jQuery('.navbar-toggler').hasClass('collapsed')) {
window.setTimeout(() => {
jQuery('body').removeClass('navbar-open');
}, 100);
} else{
jQuery('body').addClass('navbar-open');
}
})
})
</script>

0 comments on commit 1bfda23

Please sign in to comment.