React native 使用React Native使scrollView在x轴上移动一定大小?
我有scrollView和pagingEnabled可以滚动图像,这很好,但它可以滚动第二幅图像的一半,请参阅附带的动画gif 代码:React native 使用React Native使scrollView在x轴上移动一定大小?,react-native,React Native,我有scrollView和pagingEnabled可以滚动图像,这很好,但它可以滚动第二幅图像的一半,请参阅附带的动画gif 代码: <ScrollView style={{flex:1}} horizontal ref={(scrollView) => { this.scrollView = scrollView }} automaticallyAdjustContentInsets={false} directionalLo
<ScrollView
style={{flex:1}}
horizontal
ref={(scrollView) => { this.scrollView = scrollView }}
automaticallyAdjustContentInsets={false}
directionalLockEnabled
alwaysBounceVertical={false}
pagingEnabled
scrollsToTop={false}>
<Image style={styles.destination} source={require("../images/favdest1.jpg")} />
<Image style={styles.destination} source={require("../images/favdest1.jpg")} />
<Image style={styles.destination} source={require("../images/favdest1.jpg")} />
</ScrollView>
{this.scrollView=scrollView}
automaticallyAdjustContentInsets={false}
方向锁定启用
alwaysBounceVertical={false}
分页
scrollsToTop={false}>
如何使scrollView捕捉到特定宽度或子视图?React Native
scrollView
无法直接捕捉到给定宽度;但是,您可以使用以下道具来实现这一点:
onScrollEndDrag:在用户滚动后将手指从屏幕上提起时,会立即调用该函数
onMomentumScrollEnd:当用户将手指抬离屏幕后,ScrollView由于模拟动量而停止滑动时,会调用该函数
您可以使用这些方法确定用户是否已停止滚动,并在ScrollView
上调用scrollTo
,以使视图“捕捉”到所需的宽度
但是,这是非常重要的,并且您想要的功能已经作为组件存在了。:)