Last active
June 5, 2020 11:26
-
-
Save Karthik-B-06/c3c55c34318ffda0a7aa37f4dcf416e2 to your computer and use it in GitHub Desktop.
Bottom Container for Overlapping Container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import { Animated, StyleSheet, View } from 'react-native'; | |
| import { deviceHeight, deviceWidth } from '../helpers/constants'; | |
| const BottomContainer = ({ | |
| scrollY, | |
| imageHeight, | |
| ...props | |
| }) => { | |
| const animateBorderRadius = scrollY.interpolate({ | |
| inputRange: [0, 450 - 100], | |
| outputRange: [40, 0], | |
| }) | |
| return ( | |
| <Animated.ScrollView | |
| showsVerticalScrollIndicator={false} | |
| contentContainerStyle={{ | |
| paddingBottom: 200, | |
| backgroundColor: 'transparent', | |
| marginTop: -100, | |
| }} | |
| onScroll={Animated.event( | |
| [{ nativeEvent: { contentOffset: { y: scrollY } } }], | |
| { useNativeDriver: true }, | |
| () => { }, // Optional async listener | |
| )} | |
| style={[{ paddingTop: imageHeight }]}> | |
| <Animated.View style={[ | |
| styles.block, | |
| { | |
| borderTopLeftRadius: animateBorderRadius, | |
| borderTopRightRadius: animateBorderRadius | |
| } | |
| ]}> | |
| {props.children} | |
| </Animated.View> | |
| <View style={{ height: 0.4 * deviceHeight }}></View> | |
| </Animated.ScrollView> | |
| ) | |
| } | |
| const styles = StyleSheet.create({ | |
| block: { | |
| backgroundColor: '#fff', | |
| width: deviceWidth, | |
| height: deviceHeight, | |
| } | |
| }) | |
| export default BottomContainer; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment