Skip to content

Commit fbcd62d

Browse files
petrkonecny2Petr Konecny
andauthored
chore: remove offset updated readme (#15)
* chore: remove offset example * chore: better image quality * chore: example image * chore: updated readme --------- Co-authored-by: Petr Konecny <[email protected]>
1 parent 70cc03a commit fbcd62d

File tree

13 files changed

+77
-225
lines changed

13 files changed

+77
-225
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# React Native Hero Carousel
22

3+
<div style="display: flex; flex-direction: row; gap: 10px;">
4+
<img src="docs/assets/carousel-demo.webp" alt="Carousel Demo" width="200">
5+
<img src="docs/assets/carousel-demo2.webp" alt="Video Carousel Demo" width="200">
6+
<img src="docs/assets/carousel-demo3.webp" alt="Other Carousel Demo" width="200">
7+
</div>
38
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.
49

510
**✨ Context-Based Configuration** - All carousel settings are configured through the context provider for a clean, centralized API.

docs/assets/carousel-demo.webp

9.87 MB
Loading

docs/assets/carousel-demo2.webp

7.86 MB
Loading

docs/assets/carousel-demo3.webp

10.3 MB
Loading

example/app/(examples)/index.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ const examples = [
1414
description: 'Advanced animations with custom transitions',
1515
route: '/animated' as const,
1616
},
17-
{
18-
title: 'Offset Carousel',
19-
description: 'A carousel with offset animations',
20-
route: '/offset' as const,
21-
},
2217
{
2318
title: 'Entering Animation Carousel',
2419
description: 'Carousel with entering/exiting animations triggered by shared values',

example/app/(examples)/offset.tsx

Lines changed: 0 additions & 3 deletions
This file was deleted.

example/examples/AnimatedExample.tsx

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ import { LinearGradient } from 'expo-linear-gradient'
1111
import Animated, { useAnimatedStyle, interpolate, Extrapolation } from 'react-native-reanimated'
1212
import { Pagination } from './components/Pagination'
1313
import { useEffect } from 'react'
14+
import { BlurView } from 'expo-blur'
1415

1516
const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get('window')
1617

1718
const getRandomImageUrl = () => {
18-
return `https://picsum.photos/${SCREEN_WIDTH}/${SCREEN_HEIGHT}?random=${Math.floor(Math.random() * 1000)}`
19+
return `https://picsum.photos/${SCREEN_WIDTH * 3}/${SCREEN_HEIGHT * 3}?random=${Math.floor(
20+
Math.random() * 1000,
21+
)}`
1922
}
2023

2124
const images = Array.from({ length: 5 }, getRandomImageUrl)
@@ -54,10 +57,12 @@ const Slide = ({ image, title, index }: { image: string; title: string; index: n
5457
return (
5558
<View key={index} style={styles.slide}>
5659
<Animated.View style={rStyle}>
57-
<Image source={{ uri: image }} style={styles.image} contentFit="cover" />
60+
<Image source={{ uri: image }} style={styles.image} contentFit="cover" transition={200} />
5861
</Animated.View>
5962
<LinearGradient colors={['transparent', 'rgba(0,0,0,0.8)']} style={styles.gradient}>
60-
<Text style={styles.title}>{title}</Text>
63+
<BlurView style={styles.blurView} experimentalBlurMethod="dimezisBlurView">
64+
<Text style={styles.title}>{title}</Text>
65+
</BlurView>
6166
</LinearGradient>
6267
</View>
6368
)
@@ -72,12 +77,14 @@ export default function AnimatedExample() {
7277
return (
7378
<CarouselContextProvider>
7479
<SafeAreaView style={styles.container}>
75-
<View style={styles.container}>
80+
<View style={styles.carouselContainer}>
7681
<HeroCarousel>
7782
{images.map((image, index) => (
7883
<Slide key={index} image={image} title={`Slide ${index + 1}`} index={index} />
7984
))}
8085
</HeroCarousel>
86+
</View>
87+
<View style={styles.paginationContainer}>
8188
<Pagination total={images.length} />
8289
</View>
8390
</SafeAreaView>
@@ -88,7 +95,26 @@ export default function AnimatedExample() {
8895
const styles = StyleSheet.create({
8996
container: {
9097
flex: 1,
91-
backgroundColor: '#fff',
98+
backgroundColor: 'black',
99+
},
100+
carouselContainer: {
101+
flex: 0.8,
102+
borderRadius: 16,
103+
overflow: 'hidden',
104+
marginTop: 64,
105+
},
106+
paginationContainer: {
107+
justifyContent: 'center',
108+
alignItems: 'center',
109+
flex: 0.2,
110+
},
111+
blurView: {
112+
bottom: 40,
113+
left: 20,
114+
position: 'absolute',
115+
borderRadius: 16,
116+
padding: 20,
117+
overflow: 'hidden',
92118
},
93119
slide: {
94120
flex: 1,
@@ -100,7 +126,8 @@ const styles = StyleSheet.create({
100126
width: '100%',
101127
height: '100%',
102128
transformOrigin: 'center',
103-
transform: [{ scale: 1.6 }],
129+
transform: [{ scale: 1.3 }],
130+
backgroundColor: 'gray',
104131
},
105132
gradient: {
106133
position: 'absolute',
@@ -113,9 +140,6 @@ const styles = StyleSheet.create({
113140
},
114141
title: {
115142
fontSize: 32,
116-
bottom: 100,
117-
left: 20,
118-
position: 'absolute',
119143
lineHeight: 32,
120144
fontWeight: 'bold',
121145
color: 'white',

example/examples/BasicExample.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,23 @@ import { useEffect } from 'react'
77
const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get('window')
88

99
const getRandomImageUrl = () => {
10-
return `https://picsum.photos/${SCREEN_WIDTH}/${SCREEN_HEIGHT}?random=${Math.floor(Math.random() * 1000)}`
10+
return `https://picsum.photos/${SCREEN_WIDTH * 3}/${SCREEN_HEIGHT * 3}?random=${Math.floor(
11+
Math.random() * 1000,
12+
)}`
1113
}
1214

1315
const images = Array.from({ length: 5 }, getRandomImageUrl)
1416

1517
const Slide = ({ image, title, index }: { image: string; title: string; index: number }) => {
1618
return (
1719
<View key={index} style={styles.slide}>
18-
<Image key={image} source={{ uri: image }} style={styles.image} contentFit="cover" />
20+
<Image
21+
key={image}
22+
source={{ uri: image }}
23+
style={styles.image}
24+
contentFit="cover"
25+
transition={200}
26+
/>
1927
<LinearGradient colors={['transparent', 'rgba(0,0,0,0.8)']} style={styles.gradient}>
2028
<Text style={styles.title}>{title}</Text>
2129
</LinearGradient>
@@ -77,5 +85,6 @@ const styles = StyleSheet.create({
7785
lineHeight: 32,
7886
fontWeight: 'bold',
7987
color: 'white',
88+
opacity: 0.5,
8089
},
8190
})

example/examples/EnteringAnimationExample.tsx

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,21 @@ const Slide = ({ image, title, index }: { image: string; title: string; index: n
3333

3434
return (
3535
<View key={index} style={styles.slide}>
36-
<Image source={{ uri: image }} style={styles.image} contentFit="cover" />
36+
<Image source={{ uri: image }} style={styles.image} contentFit="cover" transition={200} />
3737
<LinearGradient colors={['transparent', 'rgba(0,0,0,0.8)']} style={styles.gradient}>
38-
<SlideAnimatedView style={styles.textContainer} {...animationConfig}>
39-
<Text style={styles.title}>{title}</Text>
40-
<Text style={styles.subtitle}>
41-
Animation: {animationNames[index % animationNames.length]}
42-
</Text>
43-
</SlideAnimatedView>
38+
<View style={styles.text}>
39+
<SlideAnimatedView style={styles.textContainer} {...animationConfig}>
40+
<Text style={styles.title}>{title}</Text>
41+
</SlideAnimatedView>
42+
<SlideAnimatedView
43+
style={styles.textContainer}
44+
entering={FadeIn.duration(400).delay(200)}
45+
>
46+
<Text style={styles.subtitle}>
47+
Animation: {animationNames[index % animationNames.length]}
48+
</Text>
49+
</SlideAnimatedView>
50+
</View>
4451
</LinearGradient>
4552
</View>
4653
)
@@ -96,23 +103,23 @@ const styles = StyleSheet.create({
96103
justifyContent: 'flex-end',
97104
padding: 20,
98105
},
99-
title: {
100-
fontSize: 32,
106+
text: {
107+
flex: 1,
101108
bottom: 100,
102109
left: 20,
103110
position: 'absolute',
111+
gap: 16,
112+
},
113+
title: {
114+
fontSize: 32,
104115
lineHeight: 32,
105116
fontWeight: 'bold',
106117
color: 'white',
107118
},
108119
subtitle: {
109120
fontSize: 16,
110-
bottom: 70,
111-
left: 20,
112-
position: 'absolute',
113121
lineHeight: 16,
114122
fontWeight: '500',
115123
color: 'white',
116-
opacity: 0.8,
117124
},
118125
})

0 commit comments

Comments
 (0)