mirror of
https://github.com/status-im/rn-emoji-keyboard.git
synced 2025-02-05 04:43:26 +00:00
refactor: close animation
This commit is contained in:
parent
af342a86f9
commit
095a1fda25
@ -23,24 +23,31 @@ export const ModalWithBackdrop = ({
|
|||||||
children,
|
children,
|
||||||
}: ModalWithBackdropProps) => {
|
}: ModalWithBackdropProps) => {
|
||||||
const { height: screenHeight } = useWindowDimensions();
|
const { height: screenHeight } = useWindowDimensions();
|
||||||
const translateY = React.useRef(new Animated.Value(0)).current;
|
const translateY = React.useRef(new Animated.Value(screenHeight)).current;
|
||||||
const ctx = React.useContext(KeyboardContext);
|
const ctx = React.useContext(KeyboardContext);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
Animated.timing(translateY, {
|
Animated.spring(translateY, {
|
||||||
toValue: isOpen ? 0 : screenHeight,
|
toValue: isOpen ? 0 : screenHeight,
|
||||||
useNativeDriver: true,
|
useNativeDriver: true,
|
||||||
duration: 500,
|
|
||||||
}).start();
|
}).start();
|
||||||
}, [isOpen, screenHeight, translateY]);
|
}, [isOpen, screenHeight, translateY]);
|
||||||
|
|
||||||
|
const handleClose = () => {
|
||||||
|
Animated.spring(translateY, {
|
||||||
|
toValue: screenHeight,
|
||||||
|
useNativeDriver: true,
|
||||||
|
}).start();
|
||||||
|
setTimeout(() => backdropPress(), 200);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal visible={isOpen} animationType="fade" transparent={true}>
|
<Modal visible={isOpen} animationType="fade" transparent={true}>
|
||||||
<GestureHandlerRootView style={styles.modalContainer}>
|
<GestureHandlerRootView style={styles.modalContainer}>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={styles.modalContainer}
|
style={styles.modalContainer}
|
||||||
activeOpacity={1}
|
activeOpacity={1}
|
||||||
onPress={backdropPress}
|
onPress={handleClose}
|
||||||
>
|
>
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
|
Loading…
x
Reference in New Issue
Block a user