Skip to content

Commit 85ba03b

Browse files
committed
Remove focus from navbar
1 parent 511129f commit 85ba03b

File tree

1 file changed

+8
-26
lines changed

1 file changed

+8
-26
lines changed

src/components/Header.astro

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -51,37 +51,19 @@ import links from "@data/links.json";
5151
document.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>

0 commit comments

Comments
 (0)