Header to fade by default

Fixes https://github.com/react-navigation/react-navigation-stack/issues/12
This commit is contained in:
Eric Vicenti 2018-10-31 12:21:04 -07:00
parent 0e302b3cea
commit 758fcaa8e4
1 changed files with 15 additions and 3 deletions

View File

@ -324,11 +324,22 @@ function forCenterFromLeft(props) {
};
}
// Default to no transition
function forBackground() {
return null;
// Fade in background of header while transitioning
function forBackgroundWithFade(props) {
const { position, scene } = props;
const sceneRange = getSceneIndicesForInterpolationInputRange(props);
if (!sceneRange) return { opacity: 0 };
return {
opacity: position.interpolate({
inputRange: [sceneRange.first, scene.index, sceneRange.last],
outputRange: [0, 1, 1],
}),
};
}
// Default to fade transition
const forBackground = forBackgroundWithFade;
// Translate the background with the card
const BACKGROUND_OFFSET = Dimensions.get('window').width;
function forBackgroundWithTranslation(props) {
@ -360,5 +371,6 @@ export default {
forCenter,
forRight,
forBackground,
forBackgroundWithFade,
forBackgroundWithTranslation,
};