I made a gif of the repo you linked to, and the associated snack.
I had a similar need a while ago, and stumbled upon this: https://www.youtube.com/watch?v=xutPT1oZL2M
This video show a lot more complicated transition, but is similar to the way it's done in your Coinbase example:
- Use your own
Views to create this effect
- Use (or not) an animation library to interpolate opacities of elements & positioning based on the
Scrollview's current scroll position
All documentation I found at that time on ReactNavigation is about transitioning views / title or else while navigation is occurring. I understand that you don't want to avoid ReactNavigation on a particular screen just to make an animation.
Now, based on this, you might try to animate a custom component, passed in your Screen's navigationOptions, which would apply a transition (opacity or whatever) to its child component, based on a props passed with ReactNavigation state mechanism and its dispatch method.
Not tested pseudo code, to show the idea:
class ScreenWithAnimatedNavBar extends Component {
static navigationOptions = ({navigation}) => ({
headerTitle: <CustomNavbar shouldDisplayTitle={navigation.state.params.shouldDisplayTitle} title="Your title" />,
})
...
render() {
<ScrollView onScroll={this.handleScroll}>
...
}
handleScroll (event) => {
//Decide whether you should trigger the animation, based on event.nativeEvent.contentOffset.y and your threshold
//Dispatch the animation in ReactNavigation's state if needed
// https://reactnavigation.org/docs/navigation-actions/#setparams
navigation.dispatch(CommonActions.setParams({ shouldDisplayTitle: true | false }));
}
With a CustomNavbar triggering an animation based on shouldDisplayTitle props (not illustrated, as not relevant - see how it's done in the video or in Coinbase example).
If the animation doesn't rely on the scroll position value - I mean it'll trigger back and forth only at a certain threshold, not directly following user finger - you won't dispatch to often, and it shouldn't be to laggy. If it somehow is, then you should rely on non-blocking code for animation (see the linked video for an example), and / or shift on custom views to have total control.