Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@
@apply border-border;
}
html {
scroll-behavior: smooth; /* Added smooth scrolling */
scroll-behavior: smooth;
scrollbar-gutter: stable;
}
body {
@apply bg-background text-foreground;
Expand Down
20 changes: 18 additions & 2 deletions components/providers/navigation-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ function getNavIndex(pathname: string): number {
return navOrder.indexOf(baseRoute)
}

function getPathDepth(pathname: string): number {
return pathname.split("/").filter(Boolean).length
}

export function NavigationProvider({ children }: { children: ReactNode }) {
const pathname = usePathname()
const prevPathRef = useRef(pathname)
Expand All @@ -39,8 +43,20 @@ export function NavigationProvider({ children }: { children: ReactNode }) {
const prevIndex = getNavIndex(prevPathRef.current)
const currentIndex = getNavIndex(pathname)

if (prevIndex !== -1 && currentIndex !== -1 && prevIndex !== currentIndex) {
directionRef.current = currentIndex > prevIndex ? "right" : "left"
if (prevIndex !== -1 && currentIndex !== -1) {
if (prevIndex !== currentIndex) {
// Different main sections
directionRef.current = currentIndex > prevIndex ? "right" : "left"
} else if (prevIndex === currentIndex) {
// Same main section - check path depth for sub-routes
const prevDepth = getPathDepth(prevPathRef.current)
const currentDepth = getPathDepth(pathname)
if (currentDepth > prevDepth) {
directionRef.current = "right"
} else if (currentDepth < prevDepth) {
directionRef.current = "left"
}
}
}
prevPathRef.current = pathname
}
Expand Down