【发布时间】:2018-11-11 09:17:37
【问题描述】:
我正在尝试获取视图的滚动位置。但是 Y 到页面的偏移量 的值与视图的位置无关。
ScrollView 层次结构:
<ScrollView>
- MyComponent1
- MyComponent2
- SubView1
- SubView2
- <View> (Added ref to this view and passing Y offset value through props)
- MyComponent3
</ScrollView>
SubView2 组件:
this.myComponent.measure( (fx, fy, width, height, px, py) => {
console.log('Component width is: ' + width)
console.log('Component height is: ' + height)
console.log('X offset to frame: ' + fx)
console.log('Y offset to frame: ' + fy)
console.log('X offset to page: ' + px)
console.log('Y offset to page: ' + py)
this.props.moveScrollToParticularView(py)
})
<View ref={view => { this.myComponent = view; }}>
我在onScroll 方法上检查了SubView2 视图的确切位置。但确实与measure value 匹配。我可以弄清楚measure value 是错误的。
是不是ScrollView层次问题?
【问题讨论】:
标签: javascript react-native uiscrollview scrollview