How to remove the bottom and top navigation on scrolling? Many apps like youtube hide their bottom and top navigation when a user is scrolling it can post feeds etc How can I do this with my code? for example, if a user is scrolling it hides the bottom and top navigation with smooth animation, and then posts cover the screen and when I stop it comes back bottom and top navigation can anyone help me to do that?
I created a small app on Expo Snack if you want to consider helping me feel free to check that out link https://snack.expo.dev/@syblus/stackoverflowquastion the web version if not good but the expo go version is good
2
Answers
You could try use something like this and use
headerIsShown
state to apply a class that animates it in/out withtransform: [{ translateY: headerIsShown ? 0 : - 60 }],
If you want to animate it, you could use react native interpolation
https://reactnative.dev/docs/animations#interpolation
The top answer to this question: how to Show or hide Navbar when scroll use react.js? is a nice example of how this can be done. The below is a modified version of this where the scroll logic is placed into a custom hook. You then need to set the positioning of your top and bottom navs as
position: fixed
and change the location of them (top/bottom) depending on theshow
state.