i'm new in react native and Animated API, so what i'm trying to do a simple parallax header and Animated SectionList like this
my code is
export default class Edit extends Component {
constructor(props) {
super(props)
this.state = {
fullName: '',
scrollEnabled: true,
scrollY: new Animated.Value(0),
}
}
_renderSectionHeader(section){
return <View style={[styles.SectionHeaderViewStyle]}><Text style={styles.SectionHeaderStyle}> {section.title} </Text></View>;
}
_renderItem(item){
return <View><TextFieldValidate /></View>;
}
_onScroll(event) {
// console.log(event.nativeEvent.contentOffset.y);
}
render() {
const backgroundScrollY = this.state.scrollY.interpolate({
inputRange: [0, 224],
outputRange: [0, -170],
extrapolate: 'clamp',
});
const listScrollY = this.state.scrollY.interpolate({
inputRange: [0, 224],
outputRange: [0, -170],
extrapolate: 'clamp',
});
const infoOpacity = this.state.scrollY.interpolate({
inputRange: [0, 0.5, 150],
outputRange: [1, 1, 0],
extrapolate: 'clamp',
});
const AnimatedSectionList = Animated.createAnimatedComponent(SectionList)
return (
<View style={{flex: 1}}>
<View style={{position: 'relative', height: 224, justifyContent: 'center', alignItems: 'center'}}>
<Animated.Image source={Images.profileEdit} style={[styles.background, {transform: [{translateY: backgroundScrollY}]}]} blurRadius={1.5}/>
<Text style={styles.fullNameHeader}>Steve Smith</Text>
<Animated.View style={{opacity: infoOpacity, position: 'relative', justifyContent: 'center', alignItems: 'center'}}>
<AnimatedCircularProgress size={76} width={4} fill={50} rotation={0} tintColor={Colors.cyan} backgroundColor={Colors.white}>
{
(fill) => (
<Image source={require('./img/details_icon.png')}/>
)
}
</AnimatedCircularProgress>
<Text style={styles.communityNameHeader}>Jumeirah Village Circle</Text>
<Text style={styles.profileCompletionHeader}>50% Profile Completion</Text>
</Animated.View>
</View>
<AnimatedSectionList
bounces={false}
scrollEnabled={this.state.scrollEnabled}
style={[{position: 'relative'}, {transform: [{translateY: listScrollY}]}]}
onScroll={
Animated.event(
[{nativeEvent: {contentOffset: {y: (this.state.scrollY)}}}],
{useNativeDriver: true, listener: this._onScroll.bind(this)}
)
}
sections={[
{title: 'MY DETAILS', data: myDetailsFields},
{title: 'MY COMMUNITY', data: myCommunity},
{title: 'MY FAMILY', data: myFamily},
]}
renderSectionHeader={({section}) => this._renderSectionHeader(section)}
renderItem={({item}) => this._renderItem(item)}
keyExtractor={(item, index) => index}
stickySectionHeadersEnabled={true}
/>
</View>
);
}
}
please any help to remove the bottom white space when scrolling i tried paddingBottom:950 in the "AnimatedSectionList" style but it missed up the keyboard viewing and scrolling
style={[{position: 'relative'}, {paddingBottom:950}, {transform: [{translateY: listScrollY}]}]}
AFTER ADDING marginBottom
if any one interested in the Answer i just added "marginBottom:-170" to the AnimatedSectionList instead of "paddingBottom:950"
style={[{position: 'relative'}, {marginBottom:-170}, {backgroundColor:'blue'}, {transform: [{translateY: listScrollY}]}]}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With