I am using createBottomTabNavigator
for tab bar.
I can hide and show tabbar using tabBarVisible
prop by setting it true
or false
.
Problem I have is ,I want it to hide with animation.
any links will be helpful.
I am using createBottomTabNavigator
for tab bar.
I can hide and show tabbar using tabBarVisible
prop by setting it true
or false
.
Problem I have is ,I want it to hide with animation.
any links will be helpful.
Share Improve this question edited Feb 21, 2019 at 5:09 Jaydeep Galani asked Feb 8, 2019 at 9:10 Jaydeep GalaniJaydeep Galani 4,9613 gold badges30 silver badges48 bronze badges2 Answers
Reset to default 5 +50You might wanna use new Animated.Value(0) And change the bottom value of the tab. https://github./react-navigation/react-navigation/issues/888 this has a solution.
You can create custom tabBarComponent
, and then hide/show it with what animation you want. I catch the props of tabbar
in ponentWillReceiveProps
I used react-native-animatable
for animation.
ponentWillReceiveProps(props) {
const oldState = this.props.navigation.state;
const oldRoute = oldState.routes[oldState.index].routes[0];
const oldParams = oldRoute.params;
const wasVisible = !oldParams || oldParams.visible;
const newState = props.navigation.state;
const newRoute = newState.routes[newState.index].routes[0];
const newParams = newRoute.params;
const isVisible = !newParams || newParams.visible;
if (wasVisible && !isVisible) {
this.view.slideOutDown(500);
this.setState({
hidden: true,
});
} else if (isVisible && !wasVisible) {
this.view.slideInUp(500).then(() => {
this.setState({
hidden: false,
});
});
}
}
render() {
return (
<Animatable.View
ref={ref => { this.view = ref; }}
style={[styles.container, {
position: this.state.hidden ? 'absolute' : 'relative',
}]}
useNativeDriver
>
<BottomTabBar
{...this.props}
/>
</Animatable.View>
);
}