Skip to content

Commit 0451546

Browse files
committed
feat: improve mobile navigation slide-out animation
- Change from fade to slide-out animation from bottom of screen - Trigger hiding earlier when leaving last section (30% from top of viewport) - Reduce footer threshold from 200px to 100px for earlier detection - Add smooth slide animation with bottom-[-100px] positioning - Increase animation duration to 500ms with ease-in-out timing - Improve UX by hiding navigation when it's no longer relevant - Better visual feedback with slide-out motion instead of just fade
1 parent cc68714 commit 0451546

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/components/ui/SectionNavigation.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,24 @@ export default function SectionNavigation({ sections, className = '' }: SectionN
2020
let currentSection = sections[0]?.id || '';
2121
let foundSection = false;
2222

23-
// Check if we're in the footer area (near bottom of page)
23+
// Check if we're in the footer area or leaving the last section
2424
const scrollPosition = window.scrollY;
2525
const documentHeight = document.documentElement.scrollHeight;
2626
const windowHeight = window.innerHeight;
27-
const footerThreshold = documentHeight - windowHeight - 200; // 200px before footer
27+
const footerThreshold = documentHeight - windowHeight - 100; // 100px before footer
2828

29-
const inFooter = scrollPosition > footerThreshold;
29+
// Also check if we're past the last section
30+
const lastSection = sections[sections.length - 1];
31+
let pastLastSection = false;
32+
if (lastSection) {
33+
const lastSectionElement = document.getElementById(lastSection.id);
34+
if (lastSectionElement) {
35+
const lastSectionRect = lastSectionElement.getBoundingClientRect();
36+
pastLastSection = lastSectionRect.bottom < windowHeight * 0.3; // 30% from top
37+
}
38+
}
39+
40+
const inFooter = scrollPosition > footerThreshold || pastLastSection;
3041
setIsInFooter(inFooter);
3142

3243
// If we're in footer, keep the last section active or hide navigation
@@ -141,7 +152,7 @@ export default function SectionNavigation({ sections, className = '' }: SectionN
141152
</nav>
142153

143154
{/* Mobile Navigation - Horizontal Scroll */}
144-
<nav className={`md:hidden fixed bottom-4 left-4 right-4 z-40 transition-all duration-300 ${isInFooter ? 'opacity-0 pointer-events-none' : 'opacity-100'} ${className}`}>
155+
<nav className={`md:hidden fixed left-4 right-4 z-40 transition-all duration-500 ease-in-out ${isInFooter ? 'bottom-[-100px] opacity-0 pointer-events-none' : 'bottom-4 opacity-100'} ${className}`}>
145156
<div className="bg-white/5 backdrop-blur-md border border-white/5 rounded-lg shadow-lg p-2">
146157
<div ref={mobileNavRef} className="flex space-x-1 overflow-x-auto scrollbar-hide">
147158
{sections.map((section, index) => (

0 commit comments

Comments
 (0)