2
scrollPositionX: new Animated.Value(0),    

scrollEventThrottle={16}
onScroll={Animated.event([{nativeEvent: {contentOffset: {x: this.state.scrollPositionX}}}] )}

<Animated.View style={[styles.times, {
     transform: [{translateX: this.state.scrollPositionX}]
}]}>
   ...
</Animated.View>

This code works but it scrolls the animated view in opposite direction. How do i make it scroll in the same direction. this is with respect to the issue - React Native ScrollView Sticky View Element

Community
  • 1
  • 1

1 Answers1

1

Use interpolate:

<Animated.View style={[styles.times, {
  transform: [{
    translateX: this.state.scrollPositionX.interpolate({
      inputRange: [0, 1], 
      outputRange: [0, -1]
    })
  }]
}]}>
oblador
  • 2,954
  • 19
  • 15