Skip to content

Commit 6aa83ac

Browse files
committed
feat: Close mobile navbar on outside click
Added a click event listener to the main content area. When the mobile navigation is open, clicking on the main content will now close the navigation drawer.
1 parent e15ad08 commit 6aa83ac

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

assets/js/navbar.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ function innitMobileNavbar() {
66
const navButton = document.querySelector('.menu-icon');
77
const closeMobileNavButton = document.querySelector('.menu-close-ico')
88
const scroller = document.querySelector('.body-content')
9+
const mainContent = document.querySelector('.body-content__main-section');
10+
11+
mainContent.addEventListener('click', () => {
12+
if (scroller.scrollLeft > 0) {
13+
scroller.scroll({ left: 0, behavior: "smooth" });
14+
}
15+
});
916

1017
closeMobileNavButton.addEventListener('click', () => {
1118
scroller.scroll({ left: 0, behavior: "smooth", });

0 commit comments

Comments
 (0)