Created
February 22, 2018 15:31
-
-
Save jasongaare/4bb79c027d77be2ec6f014667516fac8 to your computer and use it in GitHub Desktop.
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 { 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