Skip to content

Commit ba7fda4

Browse files
authored
Merge pull request #79 from bottlesdevs/fix/mobile-menu
fix: mobile menu
2 parents 92a5914 + 7c73ada commit ba7fda4

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/components/Header.astro

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ import { Icon } from "astro-icon/components";
180180
const mobileMenu = document.getElementById("mobileMenu");
181181
const line1 = document.getElementById("line1");
182182
const line2 = document.getElementById("line2");
183+
const header = document.querySelector("header");
183184

184185
let menuOpen = false;
185186

@@ -190,11 +191,17 @@ import { Icon } from "astro-icon/components";
190191
mobileMenu!.classList.add("translate-x-0");
191192
line1!.classList.add("rotate-45");
192193
line2!.classList.add("-rotate-45", "-translate-y-1.5");
194+
setTimeout(() => {
195+
header!.classList.add("fixed", "top-0", "left-0", "w-full");
196+
header!.classList.remove("sticky");
197+
}, 300); // delay so you don't see the header jump
193198
} else {
194199
mobileMenu!.classList.remove("translate-x-0");
195200
mobileMenu!.classList.add("translate-x-full");
196201
line1!.classList.remove("rotate-45");
197202
line2!.classList.remove("-rotate-45", "-translate-y-1.5");
203+
header!.classList.remove("fixed", "top-0", "left-0", "w-full");
204+
header!.classList.add("sticky");
198205
}
199206
});
200207
</script>

src/styles/tailwind.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ layer(base);
8484
}
8585
}
8686

87+
html {
88+
overflow-x: hidden;
89+
}
90+
8791
body {
8892
font-family: "Roboto Flex", sans-serif;
8993
overflow-x: hidden;

0 commit comments

Comments
 (0)