Created
January 17, 2018 14:02
-
-
Save loganpowell/5d706c4275d85d46f1f2b345cd10e15d to your computer and use it in GitHub Desktop.
Use Recompose with Animated
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
// from: https://github.com/acdlite/recompose/issues/427#issuecomment-320080852 | |
compose( | |
withState( | |
'interaction', | |
'setInteraction', | |
// Props get passed in here, but we're ignoring them. | |
() => { | |
const interaction = { | |
scrollPositionY: new Animated.Value(0), | |
}; | |
interaction.scrollEventY = Animated.event( | |
[{ nativeEvent: { contentOffset: { y: interaction.scrollPositionY } } }], | |
{ useNativeDriver: true }, | |
); | |
return interaction; | |
}, | |
) | |
)((props) => ( | |
<Animated.ScrollView | |
onScroll={props.interaction.scrollEventY} | |
scrollEventThrottle={1} | |
> | |
<View> | |
{console.log(props.interaction.scrollPositionY)} | |
</View> | |
</Animated.ScrollView> | |
)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment