【发布时间】:2018-05-04 22:14:15
【问题描述】:
我有水平滚动视图中的图像,我只希望在第一次滑动时所有图像滚动以平滑动画结束,以便用户可以通过一次滑动查看所有图像。
使用 prop scrollToEnd 对我没有帮助,因为它滚动得太快了。
这是我当前的代码。
<ScrollView
contentContainerStyle={styles.container}
horizontal={true}
ref="scrollview"
onScrollEndDrag={()=> this.refs.scrollview.scrollToEnd({animated: true})}
>
<Image width={1800} source={require('./assets/1.png')} />
<Image width={1800} source={require('./assets/2.png')} />
<Image width={1800} source={require('./assets/3.png')} />
<Image width={1800} source={require('./assets/4.png')} />
<Image width={1800} source={require('./assets/5.png')} />
<Image width={1800} source={require('./assets/7.png')} />
<Image width={1800} source={require('./assets/8.png')} />
<Image width={1800} source={require('./assets/9.png')} />
<Image width={1800} source={require('./assets/10.png')} />
</ScrollView>
const styles = StyleSheet.create({
container: {
flexGrow:1,
flexDirection: 'row',
},
cover: {
flexGrow: 1,
height: "90%"
}
});
【问题讨论】:
-
plus refs 在这里被定义了。
this.refs.scrollview.scrollToEnd({animated: false})} >
标签: android ios animation react-native scrollview