Skip to content

Commit dc967b2

Browse files
committed
feat: wrap Gallery component with GestureHandlerRootView for gesture handling
1 parent a0f5f0e commit dc967b2

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

src/Gallery.tsx

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import ImageViewer from './ImageViewer';
99
import Animated from 'react-native-reanimated';
1010
import { SCREEN_WIDTH } from './constants';
1111
import type { GalleryProps } from './Type';
12+
import { GestureHandlerRootView } from 'react-native-gesture-handler';
1213

1314
function Gallery({
1415
data = [],
@@ -28,24 +29,26 @@ function Gallery({
2829
);
2930

3031
return (
31-
<View style={[styles.container, containerStyle]}>
32-
<Animated.FlatList
33-
ref={flatListRef}
34-
data={data}
35-
renderItem={renderItem}
36-
horizontal
37-
pagingEnabled
38-
showsHorizontalScrollIndicator={false}
39-
bounces={false}
40-
getItemLayout={(_, index) => ({
41-
length: SCREEN_WIDTH,
42-
offset: SCREEN_WIDTH * index,
43-
index,
44-
})}
45-
style={[styles.container, { backgroundColor: backdropColor }, style]}
46-
contentContainerStyle={contentContainerStyle}
47-
/>
48-
</View>
32+
<GestureHandlerRootView>
33+
<View style={[styles.container, containerStyle]}>
34+
<Animated.FlatList
35+
ref={flatListRef}
36+
data={data}
37+
renderItem={renderItem}
38+
horizontal
39+
pagingEnabled
40+
showsHorizontalScrollIndicator={false}
41+
bounces={false}
42+
getItemLayout={(_, index) => ({
43+
length: SCREEN_WIDTH,
44+
offset: SCREEN_WIDTH * index,
45+
index,
46+
})}
47+
style={[styles.container, { backgroundColor: backdropColor }, style]}
48+
contentContainerStyle={contentContainerStyle}
49+
/>
50+
</View>
51+
</GestureHandlerRootView>
4952
);
5053
}
5154

0 commit comments

Comments
 (0)