Skip to content

Instantly share code, notes, and snippets.

@neciu
Created March 3, 2016 20:27
Show Gist options
  • Save neciu/391127f1f70b3eb69adf to your computer and use it in GitHub Desktop.
Save neciu/391127f1f70b3eb69adf to your computer and use it in GitHub Desktop.
NavigatorSceneConfig fixing issue: https://github.com/facebook/react-native/issues/1655
import {
Dimensions,
PixelRatio,
Navigator,
} from 'react-native';
import buildStyleInterpolator from 'react-native/Libraries/Utilities/buildStyleInterpolator';
const SCREEN_WIDTH = Dimensions.get('window').width;
const FromTheRight = {
opacity: {
value: 1.0,
type: 'constant',
},
transformTranslate: {
from: {x: SCREEN_WIDTH, y: 0, z: 0},
to: {x: 0, y: 0, z: 0},
min: 0,
max: 1,
type: 'linear',
extrapolate: true,
round: PixelRatio.get(),
},
translateX: {
from: SCREEN_WIDTH,
to: 0,
min: 0,
max: 1,
type: 'linear',
extrapolate: true,
round: PixelRatio.get(),
},
scaleX: {
value: 1,
type: 'constant',
},
scaleY: {
value: 1,
type: 'constant',
},
};
const ToTheLeftIOS = {
transformTranslate: {
from: {x: 0, y: 0, z: 0},
to: {x: -SCREEN_WIDTH*0.3, y: 0, z: 0},
min: 0,
max: 1,
type: 'linear',
extrapolate: true,
round: PixelRatio.get(),
},
opacity: {
value: 1.0,
type: 'constant',
},
};
export default {
...Navigator.SceneConfigs.PushFromRight,
animationInterpolators: {
into: buildStyleInterpolator(FromTheRight),
out: buildStyleInterpolator(ToTheLeftIOS),
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment