React Native Scroll to jump to a specified location
First, the structure
<ScrollView horizontal={true} ref={(view) => { this.myScrollView = view; }}> <View></View> ... <ScrollView>
Second, implementation
1) give a onLayout increasing property View
<View onLayout={event=>{this.layoutX = event.nativeEvent.layout.x}}>
2) then this can be achieved by rolling to a specified position following:
this.myScrollView.scrollTo({ x: this.layoutX, y: 0, animated: true});
Note: The above code is a jump in the horizontal direction, the vertical direction corresponding to the change can be made!
This blog address: wukong1688
This article Original Address: https://www.cnblogs.com/wukong1688/p/10962020.html
Please reprint famous source! Thank you ~ ~