有没有办法引用缩放的ScrollView的当前尺寸或比例?该文档提到了zoomScale,但是返回为undefined.
到目前为止我已尝试过以下内容:
onScrollUpdate() {
console.log(this.refs.pageScrollView.zoomScale); // returns undefined
RCTUIManager.measure(findNodeHandle(this.refs.pageScrollView), (x, y, width, height, pageX, pageY) => {
console.log(width); // returns initial size, but not scaled - this number change when zooming
});
}
<ScrollView
ref='pageScrollView'
onScroll={this.onScrollUpdate.bind(this)}
minimumZoomScale={0.95}
maximumZoomScale={2}
showsHorizontalScrollIndicator={false}
showsVerticalScrollIndicator={false}
scrollEventThrottle={2}
>
Run Code Online (Sandbox Code Playgroud)
编辑:我找到了答案,所以这可能有助于其他人.onScroll事件接收包含zoomScale数量的nativeEvent:
onScrollUpdate(event) {
console.log(event.nativeEvent.zoomScale) // returns accurate zoomscale
}
Run Code Online (Sandbox Code Playgroud)