Skip to content

Instantly share code, notes, and snippets.

@jasongaare
Created February 22, 2018 15:31
Show Gist options
  • Save jasongaare/4bb79c027d77be2ec6f014667516fac8 to your computer and use it in GitHub Desktop.
Save jasongaare/4bb79c027d77be2ec6f014667516fac8 to your computer and use it in GitHub Desktop.
import { I18nManager } from 'react-native';
import getSceneIndicesForInterpolationInputRange from 'react-navigation/src/utils/getSceneIndicesForInterpolationInputRange';
const forHorizontalNoSlideOut = (props) => {
const { layout, position, scene } = props;
const interpolate = getSceneIndicesForInterpolationInputRange(props);
if (!interpolate) return { opacity: 0 };
const { first, last } = interpolate;
const index = scene.index;
const opacity = position.interpolate({
inputRange: [first, first + 0.01, index, last - 0.01, last],
outputRange: [0, 1, 1, 1, 0],
});
const width = layout.initWidth;
const translateX = position.interpolate({
inputRange: [first, index, last],
outputRange: I18nManager.isRTL ? [-width, 0, 0] : [width, 0, 0],
});
const translateY = 0;
return {
opacity,
transform: [{ translateX }, { translateY }],
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment