feat: scroll by both resources and day #238
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements dual-axis scrolling for resource view mode, enabling users to scroll through dates (horizontally) while simultaneously navigating through resources with per-resource snapping. Previously, calendar users faced a limiting constraint: they could either (1) scroll by days and render all resources at once, or (2) render a subset of resources with pagination but lose the ability to navigate by date. This dichotomy created a poor UX for applications with many resources.
This feature is a critical requirement from our product management and design teams, essential for delivering the intended user experience in our production application.
The implementation fundamentally changes how the resource view handles scrolling and rendering:
goToDate,goToNextPage,goToPrevPage,goToNextResource,goToPrevResource)Changes
Core Architecture Changes
CalendarContainer (
packages/react-native-calendar-kit/src/CalendarContainer.tsx:184-509)numberOfDayscalculation to support multi-day rendering in resource mode whenenableResourceScrollis enabledgoToDateto properly navigate to specific dates in resource scroll mode with automatic offset calculationgoToNextPageandgoToPrevPageto handle date changes in resource mode with proper scroll synchronizationgoToNextResourceandgoToPrevResourceto support both per-resource and per-page navigation with proper bounds checkingResourceListView (
packages/react-native-calendar-kit/src/components/Resource/ResourceListView.tsx:24-179)DateResourceIteminterface combining date and resource datasnapToOffsetsarray for intelligent snap positioningonScrollOffsetChangecallback for scroll state trackinginitialOffsetsupport for proper scroll position restorationResourceBoard (
packages/react-native-calendar-kit/src/components/Resource/ResourceBoard.tsx)ResourceContainers (
packages/react-native-calendar-kit/src/components/Resource/ResourceContainers.tsx)Event Rendering Improvements
EventsProvider (
packages/react-native-calendar-kit/src/context/EventsProvider.tsx)EventItem (
packages/react-native-calendar-kit/src/components/EventItem.tsx)DragEventProvider (
packages/react-native-calendar-kit/src/context/DragEventProvider.tsx:98)Supporting Changes
UnavailableHoursByResource (
packages/react-native-calendar-kit/src/components/Resource/UnavailableHoursByResource.tsx)BodyResourceItem, BodyItem, DraggableEvent, DraggingEvent
CalendarProvider, CalendarHeader, CalendarBody
Example App (
apps/example/app/(drawer)/index.tsx:2)Technical Highlights
Intelligent Snap Algorithm
The implementation includes a sophisticated snapping system that:
Performance Optimizations
API Completeness
All calendar ref methods now fully support resource scroll mode:
goToDate()- Navigate to specific date with resource contextgoToNextPage()/goToPrevPage()- Day-based navigationgoToNextResource()/goToPrevResource()- Resource-based navigation with 'resource' or 'page' granularityDemo Videos
Android
Screen_Recording_20251128_233143_Expo.Go.mp4
Screen_Recording_20251128_233248_Expo.Go.mp4
iOS
ScreenRecording_11-29-2025.00-43-19_1.MP4
ScreenRecording_11-29-2025.00-40-15_1.MP4
Testing
Breaking Changes
None ✅ . This feature is fully backward compatible and opt-in via the existing
enableResourceScrollprop.