Skip to content
This repository has been archived by the owner on Feb 25, 2020. It is now read-only.

Animate headerBackground between scene transitions #3

Merged

Conversation

erickreutz
Copy link
Contributor

@erickreutz erickreutz commented Aug 8, 2018

Bringing this over from react-navigation/react-navigation#4787

Currently, headerBackground is sort of just plopped in place between scene changes which leads to it looking pretty jarring between transitions. What I'm proposing here is that we keep headerBackground rendered absolutely between scenes much like we do for the left, right and center. The default background interpolator transforms the x-axis moving it to the left and right as the scene transitions. This allows one to pull off the below in a much smoother fashion.

background

@erickreutz
Copy link
Contributor Author

@brentvatne think we could get this merged?

@brentvatne brentvatne merged commit 6a76bf6 into react-navigation:master Aug 21, 2018
@erickreutz
Copy link
Contributor Author

Thank you!

@brentvatne
Copy link
Member

I ended up reverting back to using no transition by default in order to not make this a breaking change, and so that we can test this out a bit before we make it default. To opt into using it until then you can do the following in stack config:

    transitionConfig: () => ({
      headerBackgroundInterpolator:
        HeaderStyleInterpolator.forBackgroundWithTranslation,
    }),

I exported HeaderStyleInterpolator from react-navigation in 2.12.0

@brentvatne
Copy link
Member

in 3.x this will be available in stack config as headerBackgroundTransitionPreset: 'toggle' | 'fade' | 'translate' - default is toggle.

https://github.com/react-navigation/react-navigation-stack/blob/d08d584c738b29d734ce179efa375859cc4ca599/example/src/HeaderBackgrounds.js#L92-L98

@erickreutz
Copy link
Contributor Author

@brentvatne awesome!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants