File tree Expand file tree Collapse file tree 1 file changed +8
-26
lines changed Expand file tree Collapse file tree 1 file changed +8
-26
lines changed Original file line number Diff line number Diff line change @@ -51,37 +51,19 @@ import links from "@data/links.json";
5151document.addEventListener("DOMContentLoaded", function() {
5252 var navbar = document.getElementById("navbar") as HTMLElement;
5353 if (!navbar) return;
54-
54+
5555 var prevScrollPos = window.pageYOffset || document.documentElement.scrollTop;
56- var isFocused = false;
57-
56+
5857 window.addEventListener("scroll", function() {
5958 var currentScrollPos = window.pageYOffset || document.documentElement.scrollTop;
60-
61- if (!isFocused) {
62- if (prevScrollPos > currentScrollPos) {
63- navbar.style.transform = "translateY(0)";
64- } else {
65- navbar.style.transform = "translateY(-100%)";
66- }
59+
60+ if (prevScrollPos > currentScrollPos) {
61+ navbar.style.transform = "translateY(0)";
62+ } else {
63+ navbar.style.transform = "translateY(-100%)";
6764 }
68-
65+
6966 prevScrollPos = currentScrollPos;
7067 });
71-
72- if ('onfocusin' in navbar) {
73- navbar.addEventListener("focusin", function() {
74- isFocused = true;
75- navbar.style.transform = "translateY(0)";
76- });
77-
78- navbar.addEventListener("focusout", function() {
79- isFocused = false;
80- var currentScrollPos = window.pageYOffset || document.documentElement.scrollTop;
81- if (currentScrollPos > prevScrollPos) {
82- navbar.style.transform = "translateY(-100%)";
83- }
84- });
85- }
8668});
8769</script >
You can’t perform that action at this time.
0 commit comments