Skip to content

Commit 4f20cbc

Browse files
committed
update scrollY
1 parent 34621dd commit 4f20cbc

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

examples/components/navbar.astro

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@ import {
66
Dropdown,
77
DropdownItems,
88
DropdownSubmenu,
9+
StickyHeader
910
} from "astro-navbar";
1011
---
1112

13+
<StickyHeader
14+
class="sticky top-0 border-b z-20 transition-all"
15+
scrollY={40}
16+
defaultClass="py-5 border-transparent"
17+
activeClass="py-2 bg-white/80 border-gray-200 backdrop-blur-lg">
1218
<header class="lg:flex justify-between p-5 gap-5 mx-auto container">
1319
<Astronav closeOnClick>
1420
<div class="flex w-full lg:w-auto justify-between">
@@ -217,3 +223,4 @@ import {
217223
</MenuItems>
218224
</Astronav>
219225
</header>
226+
</StickyHeader>

examples/pages/index.astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ import Layout from "./layout.astro";
66
<Layout>
77
<Navbar />
88
<h1 class="text-center font-medium text-2xl mt-16">Astro Nav Demo</h1>
9+
<div class="m-40 mt-72 bg-pink-50" style="height: 1500px;"></div>
910
</Layout>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "astro-navbar",
3-
"version": "2.3.2",
3+
"version": "2.3.3",
44
"description": "Responsive Mobile Navigation with Dropdown in Astro",
55
"type": "module",
66
"exports": "./index.ts",

src/components/StickyHeader.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function OnScroll(scrollPos) {
3434
header.setAttribute("active", "");
3535
}
3636
//reduce the scrollY to avoid flickering when scrolling up
37-
if (scrollPos < Math.max(scrollY - 20, 0)) {
37+
if (scrollPos < Math.max(scrollY - 40, 10)) {
3838
header.classList.remove("is-active", ...classArray);
3939
header.classList.add(...replaceArray);
4040
header.removeAttribute("active");

0 commit comments

Comments
 (0)