Overview
The Sunflower Capital website usesreact-page-scroller to create a full-page vertical scrolling experience with six distinct sections. The implementation includes custom scroll controls, dot navigation, and coordinated state management.
ReactPageScroller Setup
The main page component wraps all sections in ReactPageScroller:src/app/page.tsx
Key Configuration Props
Current page index (0-5). Allows programmatic navigation via state.
Prevents scrolling to previous page. Calculated as
!scrollEnabled && !scrollUpEnabled.Prevents scrolling to next page. Calculated as
!scrollEnabled && !scrollDownEnabled.Callback fired before transitioning to a new page. Used to update
currentPage state.When true, all pages render immediately for instant navigation. Improves perceived performance.
Scroll Control Architecture
Three-Tier Control System
The application implements a sophisticated scroll control system with three layers:Scroll Control Flow Diagram
Page-Specific Scroll Logic
Certain pages require special scroll behavior:Portfolio Page (Index 3)
src/app/page.tsx
When navigating to the portfolio page, both direction controls are disabled. This prevents accidental page changes while users browse the portfolio table.
PortfolioTable Scroll Management
The PortfolioTable component implements sophisticated scroll detection:src/components/PortfolioTable.tsx
Scroll Detection Logic Explained
Scroll Detection Logic Explained
The table tracks three scroll positions:
- At Top: When the first row aligns with table top, enable down-scrolling to navigate away
- At Bottom: When the last row is visible (with 3px tolerance), enable up-scrolling to navigate away
- Middle: When scrolling within the table, disable both directions to prevent page navigation
Mouse and Touch Event Handling
src/components/PortfolioTable.tsx
Dot Navigation System
The DotNavigator component provides visual feedback and click navigation:src/components/DotNavigator.tsx
Dot Navigation Features
Dynamic Styling
Background changes on hero (0) and footer (5) pages
Scale Animation
Active dot scales to 150%, others to 100%
Opacity States
Active: 100%, Inactive: 50%, Hero/Footer: 20%
Click Navigation
Direct navigation to any page via dot click
Conditional Rendering
src/app/page.tsx
The dot navigator only renders on desktop devices. Mobile users navigate solely through swipe gestures.
CSS Positioning
The dot navigator uses fixed positioning:globals.css
Page Sections Structure
Each section is a direct child of ReactPageScroller:- Section 0: Hero
- Section 1: Statement
- Section 2: Ethos
- Section 3: Portfolio
- Section 4: Testimonials
All sections use
h-[calc(100dvh)] or min-h-[calc(100dvh)] to ensure full viewport height, with dvh (dynamic viewport height) accounting for mobile browser UI.Global Overflow Control
Prevents default page scrolling:globals.css
Programmatic Navigation
To navigate programmatically, update thecurrentPage state:
customPageNumber changes and animates to the new page.
Best Practices
Scroll Control Coordination
Scroll Control Coordination
Always provide callback props (
setScrollEnabled, etc.) to components with scrollable content to prevent navigation conflicts.Mobile Optimization
Mobile Optimization
Use touch events (
onTouchStart/onTouchEnd) in addition to mouse events for proper mobile scroll control.Performance
Performance
Set
renderAllPagesOnFirstRender={true} to preload all sections and enable instant navigation.Height Management
Height Management
Use
calc(100dvh) instead of 100vh to account for mobile browser chrome and ensure true full-height sections.Related Resources
Architecture Overview
High-level application structure
Responsive Design
Mobile and desktop patterns