【问题标题】:scroll the view simultaneously as the scrollView scrolls在 scrollView 滚动时同时滚动视图
【发布时间】:2015-12-21 05:49:53
【问题描述】:
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>

此代码有效,但它以相反的方向滚动动画视图。我如何使它朝同一个方向滚动。 这是关于这个问题 - React Native ScrollView Sticky View Element

【问题讨论】:

    标签: android scrollview react-native sticky


    【解决方案1】:

    使用interpolate:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-23
      • 2012-10-26
      • 1970-01-01
      • 1970-01-01
      • 2017-12-01
      相关资源
      最近更新 更多