Skip to content

Commit b7d8c41

Browse files
use scroll position instead of scroll progress for consistency
1 parent 5b69339 commit b7d8c41

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/components/ui/NavigationBar.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const HoverNavigation = ({
4949
className?: string;
5050
}) => {
5151
const [hoveredIndex, setHoveredIndex] = useState<number | null>(null);
52-
const { scrollYProgress } = useScroll();
52+
const { scrollY } = useScroll();
5353
const [navVisible, setNavVisible] = useState(true);
5454
const [availableVisible, setAvailableVisible] = useState(false);
5555

@@ -68,13 +68,13 @@ export const HoverNavigation = ({
6868

6969
const updateNavBarState = (
7070
width: number,
71-
scrollProgress: number = 0,
71+
scrollPosition: number = 0,
7272
scrollUp: boolean = false,
7373
) => {
7474
if (width && width < 1024) {
7575
setNavVisible(false);
7676
setAvailableVisible(true);
77-
} else if (scrollProgress < 0.05) {
77+
} else if (scrollPosition < 50) {
7878
setNavVisible(true);
7979
setAvailableVisible(false);
8080
} else if (!onContactPage) {
@@ -86,12 +86,12 @@ export const HoverNavigation = ({
8686
}
8787
};
8888

89-
useMotionValueEvent(scrollYProgress, "change", (current) => {
89+
useMotionValueEvent(scrollY, "change", (current) => {
9090
// Check if current is not undefined and is a number
9191
if (typeof current === "number") {
92-
let direction = current! - scrollYProgress.getPrevious()!;
92+
let direction = current! - scrollY.getPrevious()!;
9393
let scrollUp = direction <= 0;
94-
let scrollProgress = scrollYProgress.get();
94+
let scrollProgress = scrollY.get();
9595

9696
updateNavBarState(width, scrollProgress, scrollUp);
9797
}

tsconfig.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"extends": "astro/tsconfigs/strict",
3-
"compilerOptions": {
4-
"jsx": "react-jsx",
5-
"jsxImportSource": "react",
6-
"baseUrl": "./",
7-
"paths": {
8-
"@/*": ["src/*"]
9-
}
10-
}
2+
"extends": "astro/tsconfigs/strict",
3+
"compilerOptions": {
4+
"jsx": "react-jsx",
5+
"jsxImportSource": "react",
6+
"baseUrl": "./",
7+
"paths": {
8+
"@/*": ["src/*"]
9+
}
10+
}
1111
}

0 commit comments

Comments
 (0)