-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
30 lines (24 loc) · 969 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const navigationShow = document.getElementById('show-nav');
const navigationHide = document.getElementById('hide-nav');
const mobMenuLinks = document.querySelectorAll('#mobmenu-links li a');
const mobileMenu = document.getElementById('mobile-menu');
const toggleMobileMenu = () => {
mobileMenu.classList.toggle('mobile-menu--show');
};
const smoothScrollToSection = (link) => {
const targetID = link.getAttribute('href').substring(1);
const targetSection = document.getElementById(targetID);
if (targetSection) {
targetSection.scrollIntoView({ behavior: 'smooth' });
}
};
const handleMobileMenuClick = (event) => {
event.preventDefault();
smoothScrollToSection(event.target);
mobileMenu.classList.remove('mobile-menu--show');
};
navigationShow.addEventListener('click', toggleMobileMenu);
navigationHide.addEventListener('click', toggleMobileMenu);
mobMenuLinks.forEach((link) => {
link.addEventListener('click', handleMobileMenuClick);
});