【发布时间】:2018-03-25 00:01:30
【问题描述】:
我正在努力做到这一点,所以每当新的东西被渲染到滚动视图中时,滚动视图将保持不变并且不会上下颠簸。现在如果渲染了一个新组件,滚动视图似乎被重置为 0。
有没有办法阻止这种行为并保持位置?
现在我正在使用的滚动视图:
handleScrollt(event){
this.scroll = event.nativeEvent.contentOffset.y
}
handleSizet(width, height){
if (this.scroll) {
const position = this.scroll + height - this.height
this.refs.sv.scrollTo({x: 0, y: position, animated: false})
}
this.height = height
}
<ScrollView
ref="sv"
scrollEventThrottle={16}
onScroll={this.handleScrollt.bind(this)}
onContentSizeChange={this.handleSizet.bind(this)}
这个问题是滚动视图会短暂渲染,然后滚动到正确的偏移量。所以看起来屏幕顶部有短暂的飞溅
【问题讨论】:
标签: react-native react-native-scrollview