You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A highly customizable, performant carousel component for React Native with advanced animations, auto-scrolling capabilities, and infinite scrolling support. Built with React Native Reanimated for smooth, native-level performance.
9
9
10
-
**✨ Context-Based Configuration** - All carousel settings are configured through the context provider for a clean, centralized API.
10
+
**✨ Compound Pattern** - Clean, intuitive API with `HeroCarousel.Provider`, `HeroCarousel.Item`, and `HeroCarousel.AnimatedView`
11
+
**✨ Context-Based Configuration** - All carousel settings are configured through the provider for a clean, centralized API.
11
12
12
13
## Features
13
14
@@ -45,7 +46,7 @@ Make sure to follow the [React Native Reanimated installation guide](https://doc
|`children`|`React.ReactNode[]`| Array of slide components |
144
155
156
+
#### `HeroCarousel.Item`
157
+
158
+
A wrapper component for individual slides. Provides slide context to child components. **Note:** This is automatically used internally when you pass children to `HeroCarousel`, but you can use it directly for more control.
159
+
160
+
```tsx
161
+
<HeroCarousel.Item>{/* Your slide content */}</HeroCarousel.Item>
162
+
```
163
+
164
+
#### `HeroCarousel.AnimatedView`
165
+
166
+
A specialized animated view component that automatically handles entering/exiting animations based on carousel scroll position. Perfect for creating slide-specific animations.
The `HeroCarousel.AnimatedView` component automatically handles entering/exiting animations based on carousel scroll position. Perfect for creating slide-specific animations:
This library uses a **compound component pattern** that provides a clean, intuitive API:
443
+
444
+
```tsx
445
+
<HeroCarousel.Provider>
446
+
<HeroCarousel>
447
+
<HeroCarousel.Item>
448
+
<HeroCarousel.AnimatedView>{/* Your content */}</HeroCarousel.AnimatedView>
449
+
</HeroCarousel.Item>
450
+
</HeroCarousel>
451
+
</HeroCarousel.Provider>
452
+
```
453
+
341
454
### Context-Based Configuration
342
455
343
-
This library uses a **context-based architecture** where all carousel configuration is passed to the `CarouselContextProvider` rather than individual components. This design provides several benefits:
456
+
All carousel configuration is passed to the `HeroCarousel.Provider` rather than individual components. This design provides several benefits:
344
457
345
458
✅ **Centralized Configuration** - All settings in one place
346
459
✅ **Cleaner Component API** - Components focus on rendering, not configuration
347
-
✅ **Easier Testing** - Mock context for isolated component testing
460
+
✅ **Easier Testing** - Mock context for isolated component testing
461
+
✅ **Flexible Composition** - Components like pagination can be placed anywhere within the provider
462
+
463
+
The compound pattern allows for:
348
464
349
-
That allows for components like pagination to not be attached to the carousel component.
465
+
-**Intuitive API** - Related components are grouped under `HeroCarousel.*`
466
+
-**Better Discoverability** - All carousel-related components are accessible via autocomplete
467
+
-**Flexible Usage** - Use `HeroCarousel.Item` and `HeroCarousel.AnimatedView` when needed, or pass children directly to `HeroCarousel`
350
468
351
469
## Troubleshooting
352
470
353
471
### Common Issues
354
472
355
473
**Carousel not auto-scrolling:**
356
474
357
-
- Ensure `CarouselContextProvider` wraps your carousel
475
+
- Ensure `HeroCarousel.Provider` wraps your carousel
358
476
- Check if `disableAutoScroll` is set to `false`
359
477
- Verify React Native Reanimated is properly installed
0 commit comments