Expand/Close when item list scroll ends #997
-
Hi guys, Is there an implementation of the example on the left in the README? Best, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
You can use You can do something like this: import React, {useCallback, useRef, useMemo} from 'react';
import {StyleSheet, View, Text, Button} from 'react-native';
import BottomSheet, {BottomSheetScrollView} from '@gorhom/bottom-sheet';
const BottomSheetFlatlistExample = () => {
const sheetRef = useRef<BottomSheet>(null);
const data = useMemo(
() =>
Array(50)
.fill(0)
.map((_, index) => `index-${index}`),
[],
);
const snapPoints = useMemo(() => [1, '90%'], []);
const openBottomModal = useCallback(() => {
sheetRef.current?.expand();
}, []);
const renderItem = useCallback(
item => (
<View key={item} style={styles.itemContainer}>
<Text>{item}</Text>
</View>
),
[],
);
return (
<View style={styles.container}>
<Button title="Open Bottom Sheet" onPress={openBottomModal} />
<BottomSheet ref={sheetRef} index={1} snapPoints={snapPoints}>
<BottomSheetScrollView contentContainerStyle={styles.contentContainer}>
{data.map(renderItem)}
</BottomSheetScrollView>
</BottomSheet>
</View>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
paddingTop: 200,
},
contentContainer: {
backgroundColor: 'white',
},
itemContainer: {
padding: 6,
margin: 6,
backgroundColor: '#eee',
},
});
export default BottomSheetFlatlistExample; |
Beta Was this translation helpful? Give feedback.
-
Coming back with fresh eyes, I've created 2 projects one with react native (left) and one with expo (right). Also to note, on RN there's a smooth ongoing scroll after releasing the press but on Expo as soon as I release the finger it stops scrolling. After some digging it seems it relates to this: #868 Update: after building the expo app with EAS the animation and scrolling seem to be working smooth |
Beta Was this translation helpful? Give feedback.
Coming back with fresh eyes, I've created 2 projects one with react native (left) and one with expo (right).
The projects have the same exact setup and dependencies and it seems that on Expo it doesn't want to release from that snap point.
Also to note, on RN there's a smooth ongoing scroll after releasing the press but on Expo as soon as I release the finger it stops scrolling.
After some digging it seems it relates to this: #868
Update: after building the expo app with EAS the animation and scrolling seem to be working smooth