diff --git a/src/app/page.tsx b/src/app/page.tsx index 263c2a2..c060adb 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -20,6 +20,7 @@ export default function LandingPage() { const [lastScrollY, setLastScrollY] = useState(0); const viewMoreButtonRef = useRef(null); const sixthItemRef = useRef(null); + const galleryRef = useRef(null); useEffect(() => { let ticking = false; @@ -38,17 +39,18 @@ export default function LandingPage() { } setLastScrollY(currentScrollY); - // Check if 6th item is in view - if (sixthItemRef.current) { - const rect = sixthItemRef.current.getBoundingClientRect(); + // Check if gallery is in view + if (galleryRef.current) { + const rect = galleryRef.current.getBoundingClientRect(); const isInView = rect.top < window.innerHeight && rect.bottom > 0; - const isScrollingDown = scrollDirection === 'down'; - // Show button when 6th item is reached AND scrolling down - // Hide button when scrolling back up past the 6th item - if (isInView && isScrollingDown) { + // Show button when gallery is scrolled past (user scrolls down past gallery) + // Hide button when user scrolls back to gallery area + if (!isInView && currentScrollY > lastScrollY) { + // We've scrolled past the gallery, show the up arrow setShowViewMoreButton(true); - } else if (!isInView && scrollDirection === 'up') { + } else if (isInView && currentScrollY < lastScrollY) { + // We're back at or above the gallery, hide the button setShowViewMoreButton(false); } } @@ -61,7 +63,7 @@ export default function LandingPage() { window.addEventListener('scroll', handleScroll); return () => window.removeEventListener('scroll', handleScroll); - }, [lastScrollY, scrollDirection]); + }, [lastScrollY]); const scrollToGallery = () => { const gallerySectionElement = document.getElementById('gallery'); @@ -252,7 +254,7 @@ export default function LandingPage() { /> - {/* Fixed "Go to Dresses" Button */} + {/* Fixed "Go to Dresses" Button - Only visible on home page */} + {/* Fixed "Back to Dresses" Button - Appears when scrolled past gallery */} + {showViewMoreButton && ( + + )} + {/* Fixed "Go to Shoes" Button */}