Last active
March 16, 2023 11:17
-
-
Save Catevika/6237236bccee726c3d333147272d2154 to your computer and use it in GitHub Desktop.
Revisions
-
Catevika revised this gist
Mar 16, 2023 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,14 @@ /*===================================================== = Navbar: Hide on Scroll and Show at Scroll position = =====================================================*/ const navbar = document.querySelector('nav'); let lastScrollTop; window.addEventListener('scroll', function () { let scrollTop = window.pageYOffset || document.documentElement.scrollTop; if (scrollTop > lastScrollTop) { navbar.style.top = '-75px'; /* height of the navbar */ } else { navbar.style.top = '0'; -
Catevika created this gist
Mar 16, 2023 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ /*===================================================== = Navbar: Hide on Scroll and Show at Scroll position = =====================================================*/ let lastScrollTop; window.addEventListener('scroll', function () { let scrollTop = window.pageYOffset || document.documentElement.scrollTop; if (scrollTop > lastScrollTop) { navbar.style.top = '-75px'; } else { navbar.style.top = '0'; } lastScrollTop = scrollTop; });