-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscripts.js
23 lines (20 loc) · 877 Bytes
/
scripts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
document.addEventListener("DOMContentLoaded", function() {
const scrollLinks = document.querySelectorAll('.scroll');
const navbarToggler = document.querySelector('.navbar-toggler');
const navbarCollapse = document.querySelector('.navbar-collapse');
scrollLinks.forEach(link => {
link.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href').substring(1);
const targetSection = document.getElementById(targetId);
window.scrollTo({
top: targetSection.offsetTop - 56, // Adjust for fixed navbar height
behavior: 'smooth'
});
// Collapse the navbar
if (navbarToggler && navbarCollapse.classList.contains('show')) {
navbarToggler.click();
}
});
});
});