-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created a functionality so that when scrolling down the navbar is hidden
- Loading branch information
1 parent
404f701
commit 955d89d
Showing
2 changed files
with
17 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -367,6 +367,7 @@ <h5>Aligarh</h5> | |
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" | ||
integrity="sha384-ENjdO4Dr2bkBIFxQpeoTz1HIcje39Wm4jDKdf19U8gI4ddQ3GYNS7NTKfAdVQSZe" | ||
crossorigin="anonymous"></script> | ||
<script src="./index.js"></script> | ||
</body> | ||
|
||
</html> |
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,16 @@ | ||
let lastScrollTop = 0; | ||
const navbar = document.querySelector('.navbar'); | ||
|
||
window.addEventListener('scroll', function() { | ||
let scrollTop = window.pageYOffset || document.documentElement.scrollTop; | ||
|
||
if (scrollTop > lastScrollTop) { | ||
// Scrolling down | ||
navbar.style.top = '-80px'; // Adjust height accordingly | ||
} else { | ||
// Scrolling up | ||
navbar.style.top = '0'; | ||
} | ||
|
||
lastScrollTop = scrollTop; | ||
}); |