From 62864805719cc5f629ab46c4dfa063a25bf7300e Mon Sep 17 00:00:00 2001 From: James Ide Date: Wed, 8 Apr 2015 23:55:09 -0700 Subject: [PATCH] [RFC][ScrollView] Add `getScrollResponder` to ScrollView for composition This is a proposal to add `getScrollResponder` to all ScrollView-like components, including ListView. This allows multiple higher-order scroll views to be composed while allowing the owner of the top-level scroll view to call `scrollableView.getScrollResponder().scrollTo(...)` regardless of whether `scrollableView` is a ScrollView, ListView, InvertedScrollView, etc. --- Libraries/Components/ScrollView/ScrollView.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index fc7fc7223c861f..65501c5d7225d2 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -190,6 +190,16 @@ var ScrollView = React.createClass({ this.refs[SCROLLVIEW].setNativeProps(props); }, + /** + * Returns a reference to the underlying scroll responder, which supports + * operations like `scrollTo`. All ScrollView-like components should + * implement this method so that they can be composed while providing access + * to the underlying scroll responder's methods. + */ + getScrollResponder: function(): ReactComponent { + return this; + }, + getInnerViewNode: function(): any { return this.refs[INNERVIEW].getNodeHandle(); },