Skip to content

Instantly share code, notes, and snippets.

@Karthik-B-06
Last active June 5, 2020 11:26
Show Gist options
  • Save Karthik-B-06/c3c55c34318ffda0a7aa37f4dcf416e2 to your computer and use it in GitHub Desktop.
Save Karthik-B-06/c3c55c34318ffda0a7aa37f4dcf416e2 to your computer and use it in GitHub Desktop.
Bottom Container for Overlapping Container
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