This was fairly concise, and I ran into the source code.
You can try the following:
required:
var RCTUIManager = require('NativeModules').UIManager;
Render:
<ScrollView ref = {component=>{this._scrollView=component;}}> </ScrollView>
Event:
someEvent: function() { RCTUIManager.measure(this._scrollView.getInnerViewNode(), (...data)=>{console.log(data)}); }
From the data, you can get the contents of the scroll whose height is the fourth data element. Of course, you can get content bias from it. Run the source code RCTUIMananger.m for more details.
When you use getInnerViewNode , you can get the frame of the inner ScrollView frame. If you want to get a ScrollView frame, you must use React.findNodeHandle(this._scrollView) , and the ScrollView frame is not always equal to its inner view frame.
(updated)
If you want to replace (...data)=>{console.log(data)} with callback , you should use it like this:
RCTUIManager.measure(this._scrollView.getInnerViewNode(), callback.bind(this));
Kchen
source share