[ListView] Operate on the true scroll responder instead of the scroll component

Summary:
When composing scroll views, `this.refs[SCROLLVIEW_REF]` may refer to another higher-order scroll component instead of a ScrollView. This can cause issues if you expect to need it to be a ScrollView backed by an RCTScrollView.

The solution is to call `getScrollResponder()` - as long as all higher-order scroll components implement this method, it will make its way down to the true ScrollView, which is what ListView wants here.

Closes https://github.com/facebook/react-native/pull/1927
Github Author: James Ide <ide@jameside.com>
This commit is contained in:
James Ide 2015-07-13 12:26:57 -07:00
parent d5943b0e47
commit 9f07b9a2b6

View File

@ -221,7 +221,7 @@ var ListView = React.createClass({
* such as scrollTo.
*/
getScrollResponder: function() {
return this.refs[SCROLLVIEW_REF];
return this.refs[SCROLLVIEW_REF].getScrollResponder();
},
setNativeProps: function(props) {
@ -399,14 +399,15 @@ var ListView = React.createClass({
*/
_measureAndUpdateScrollProps: function() {
var scrollComponent = this.getScrollResponder();
RCTUIManager.measureLayout(
this.refs[SCROLLVIEW_REF].getInnerViewNode(),
React.findNodeHandle(this.refs[SCROLLVIEW_REF]),
scrollComponent.getInnerViewNode(),
React.findNodeHandle(scrollComponent),
logError,
this._setScrollContentHeight
);
RCTUIManager.measureLayoutRelativeToParent(
React.findNodeHandle(this.refs[SCROLLVIEW_REF]),
React.findNodeHandle(scrollComponent),
logError,
this._setScrollVisibleHeight
);
@ -414,7 +415,7 @@ var ListView = React.createClass({
// RKScrollViewManager.calculateChildFrames not available on every platform
RKScrollViewManager && RKScrollViewManager.calculateChildFrames &&
RKScrollViewManager.calculateChildFrames(
React.findNodeHandle(this.refs[SCROLLVIEW_REF]),
React.findNodeHandle(scrollComponent),
this._updateChildFrames,
);
},