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:
442
+
443
+
```tsx
444
+
<HeroCarousel.Provider>
445
+
<HeroCarousel>
446
+
<HeroCarousel.Item>
447
+
<HeroCarousel.AnimatedView>{/* Your content */}</HeroCarousel.AnimatedView>
448
+
</HeroCarousel.Item>
449
+
</HeroCarousel>
450
+
</HeroCarousel.Provider>
451
+
```
452
+
341
453
### Context-Based Configuration
342
454
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:
455
+
All carousel configuration is passed to the `HeroCarousel.Provider` rather than individual components. This design provides several benefits:
344
456
345
457
✅ **Centralized Configuration** - All settings in one place
346
458
✅ **Cleaner Component API** - Components focus on rendering, not configuration
347
-
✅ **Easier Testing** - Mock context for isolated component testing
459
+
✅ **Easier Testing** - Mock context for isolated component testing
460
+
✅ **Flexible Composition** - Components like pagination can be placed anywhere within the provider
461
+
462
+
The compound pattern allows for:
348
463
349
-
That allows for components like pagination to not be attached to the carousel component.
464
+
-**Intuitive API** - Related components are grouped under `HeroCarousel.*`
465
+
-**Better Discoverability** - All carousel-related components are accessible via autocomplete
466
+
-**Flexible Usage** - Use `HeroCarousel.Item` and `HeroCarousel.AnimatedView` when needed, or pass children directly to `HeroCarousel`
350
467
351
468
## Troubleshooting
352
469
353
470
### Common Issues
354
471
355
472
**Carousel not auto-scrolling:**
356
473
357
-
- Ensure `CarouselContextProvider` wraps your carousel
474
+
- Ensure `HeroCarousel.Provider` wraps your carousel
358
475
- Check if `disableAutoScroll` is set to `false`
359
476
- Verify React Native Reanimated is properly installed
0 commit comments