Skip to content

Commit

Permalink
thresold decreased for centered position, close navBar when clicked o…
Browse files Browse the repository at this point in the history
…n navItem
  • Loading branch information
aakashdinkarh committed Nov 20, 2024
1 parent 124c1a2 commit da9595d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion scripts/dynamicallyLoadChunks.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function isDivCenteredVertically(div) {
const divCenter = rect.top + rect.height / 2;

// Check if the div center is approximately equal to the viewport center
const threshold = 200; // Allow some small tolerance for "centered"
const threshold = 125; // Allow some small tolerance for "centered"
return Math.abs(viewportCenter - divCenter) <= threshold;
}
const scrollListener = throttleDebounce(function (project) {
Expand Down
35 changes: 23 additions & 12 deletions scripts/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,30 @@ window.onscroll = function () {
}
};

const hamburgerMenuIcon = document.querySelector('.hamburger-menu-icon');
const mNavBar = document.querySelector('#mNavBar');
const mNavBarOverlay = document.querySelector('.m-nav-bar-overlay');
hamburgerMenuIcon.onclick = () => {
mNavBar.classList.add('show');
mNavBarOverlay.classList.add('show');
};

const navbarCloseIcon = document.querySelector('#navbarCloseIcon');
navbarCloseIcon.onclick = mNavBarOverlay.onclick = () => {
mNavBar.classList.remove('show');
mNavBarOverlay.classList.remove('show');
};
(() => {
const hamburgerMenuIcon = document.querySelector('.hamburger-menu-icon');
const mNavBar = document.querySelector('#mNavBar');
const mNavBarOverlay = document.querySelector('.m-nav-bar-overlay');
const navbarCloseIcon = document.querySelector('#navbarCloseIcon');
const mNavBarLinks = mNavBar.querySelectorAll('.nav-links > a');

function show_mNavBar() {
mNavBar.classList.add('show');
mNavBarOverlay.classList.add('show');
};

function close_mNavBar() {
mNavBar.classList.remove('show');
mNavBarOverlay.classList.remove('show');
};

hamburgerMenuIcon.onclick = show_mNavBar;

mNavBarLinks.forEach((navLink) => { navLink.onclick = close_mNavBar });
navbarCloseIcon.onclick = mNavBarOverlay.onclick = close_mNavBar;
})();


window.onload = () => {
const hash = window.location.hash;
Expand Down

0 comments on commit da9595d

Please sign in to comment.