Created
March 14, 2016 20:51
-
-
Save vdel26/6c9318f9e88ca6f27b83 to your computer and use it in GitHub Desktop.
Custom Scene transition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Navigator } from 'react-native'; | |
import PixelRatio from 'PixelRatio'; | |
import Dimensions from 'Dimensions'; | |
import buildStyleInterpolator from 'buildStyleInterpolator'; | |
// use FloatFromRight as starting template | |
const BaseConfig = Navigator.SceneConfigs.FloatFromRight; | |
// create custom navigator transition | |
const PushFromRightFast = Object.assign({}, BaseConfig, { | |
springFriction: 25, | |
springTension: 215, | |
}); | |
const FlatFadeToTheLeft = { | |
transformTranslate: { | |
from: {x: 0, y: 0, z: 0}, | |
to: {x: -Math.round(Dimensions.get('window').width * 1.5), y: 0, z: 0}, | |
min: 0, | |
max: 1, | |
type: 'linear', | |
extrapolate: true, | |
round: PixelRatio.get(), | |
}, | |
opacity: { | |
from: 1, | |
to: 0, | |
min: 0, | |
max: 1, | |
type: 'linear', | |
extrapolate: false, | |
round: 100, | |
}, | |
translateX: { | |
from: 0, | |
to: -Math.round(Dimensions.get('window').width * 0.5), | |
min: 0, | |
max: 1, | |
type: 'linear', | |
extrapolate: true, | |
round: PixelRatio.get(), | |
}, | |
}; | |
PushFromRightFast.animationInterpolators.out = buildStyleInterpolator(FlatFadeToTheLeft); | |
export default PushFromRightFast; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment