-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Please enter the commit message for your changes. Lines starting
with '#' will be ignored, and an empty message aborts the commit. On branch main Your branch is up to date with 'origin/main'. Changes to be committed: modified: css/about-section.css modified: css/footer.css modified: css/hero-section.css modified: css/leaderboard.css modified: css/mentors.css modified: css/navbar.css modified: css/project.css modified: index.html new file: js/navbar.js
- Loading branch information
1 parent
de211f1
commit 88202fe
Showing
9 changed files
with
70 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
document.addEventListener("DOMContentLoaded", function () { | ||
var navLinks = document.querySelectorAll('.menu a'); | ||
|
||
function onScroll() { | ||
var scrollPosition = window.scrollY || document.documentElement.scrollTop; | ||
var offset = window.innerHeight * 0.6; | ||
|
||
navLinks.forEach(function (navLink) { | ||
var targetDivId = navLink.getAttribute('href').substring(1); | ||
var targetDiv = document.getElementById(targetDivId); | ||
|
||
if (targetDiv) { | ||
var divTop = targetDiv.offsetTop; | ||
var divHeight = targetDiv.offsetHeight; | ||
|
||
if (scrollPosition >= divTop - offset && scrollPosition < divTop + divHeight - offset) { | ||
navLinks.forEach(function (link) { | ||
link.classList.remove('active'); | ||
}); | ||
|
||
navLink.classList.add('active'); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
window.addEventListener('scroll', onScroll); | ||
|
||
onScroll(); | ||
}); |