2023-07-13 17:09:23 +10:00
|
|
|
(function() {
|
|
|
|
"use strict"; // Start of use strict
|
|
|
|
|
|
|
|
var mainNav = document.querySelector('#mainNav');
|
|
|
|
|
|
|
|
if (mainNav) {
|
|
|
|
|
|
|
|
var navbarCollapse = mainNav.querySelector('.navbar-collapse');
|
|
|
|
|
|
|
|
if (navbarCollapse) {
|
|
|
|
|
|
|
|
var collapse = new bootstrap.Collapse(navbarCollapse, {
|
|
|
|
toggle: false
|
|
|
|
});
|
|
|
|
|
|
|
|
var navbarItems = navbarCollapse.querySelectorAll('a');
|
|
|
|
|
|
|
|
// Closes responsive menu when a scroll trigger link is clicked
|
|
|
|
for (var item of navbarItems) {
|
|
|
|
item.addEventListener('click', function (event) {
|
|
|
|
collapse.hide();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Collapse Navbar
|
|
|
|
var collapseNavbar = function() {
|
|
|
|
|
|
|
|
var scrollTop = (window.pageYOffset !== undefined) ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop;
|
|
|
|
|
|
|
|
if (scrollTop > 100) {
|
|
|
|
mainNav.classList.add("navbar-shrink");
|
|
|
|
} else {
|
|
|
|
mainNav.classList.remove("navbar-shrink");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
// Collapse now if page is not at top
|
2023-07-27 21:44:36 +10:00
|
|
|
// collapseNavbar();
|
2023-07-13 17:09:23 +10:00
|
|
|
// Collapse the navbar when page is scrolled
|
2023-07-27 21:44:36 +10:00
|
|
|
// document.addEventListener("scroll", collapseNavbar);
|
2023-07-13 17:09:23 +10:00
|
|
|
|
|
|
|
// Hide navbar when modals trigger
|
|
|
|
var modals = document.querySelectorAll('.portfolio-modal');
|
|
|
|
|
|
|
|
for (var modal of modals) {
|
|
|
|
|
|
|
|
modal.addEventListener('shown.bs.modal', function (event) {
|
|
|
|
mainNav.classList.add('d-none');
|
|
|
|
});
|
|
|
|
|
|
|
|
modal.addEventListener('hidden.bs.modal', function (event) {
|
|
|
|
mainNav.classList.remove('d-none');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
})(); // End of use strict
|