55 StyleSheet ,
66 View ,
77 } from 'react-native' ;
8+ import _ from 'lodash' ;
9+
10+ const SCROLLVIEW_REF = 'ScrollView' ;
811
912const styles = StyleSheet . create ( {
1013 container : {
@@ -41,6 +44,27 @@ class ImageHeaderScrollView extends Component {
4144 } ;
4245 }
4346
47+ /*
48+ * Expose `ScrollView` API so this component is composable
49+ * with any component that expects a `ScrollView`.
50+ */
51+ getScrollResponder ( ) {
52+ return this [ SCROLLVIEW_REF ] . getScrollResponder ( ) ;
53+ }
54+ getScrollableNode ( ) {
55+ return this . getScrollResponder ( ) . getScrollableNode ( ) ;
56+ }
57+ getInnerViewNode ( ) {
58+ return this . getScrollResponder ( ) . getInnerViewNode ( ) ;
59+ }
60+ setNativeProps ( props ) {
61+ this [ SCROLLVIEW_REF ] . setNativeProps ( props ) ;
62+ }
63+ scrollTo ( ...args ) {
64+ this . getScrollResponder ( ) . scrollTo ( ...args ) ;
65+ }
66+
67+
4468 interpolateOnImageHeight ( outputRange ) {
4569 const headerScrollDistance = this . props . maxHeight - this . props . minHeight ;
4670 return this . state . scrollY . interpolate ( {
@@ -96,14 +120,17 @@ class ImageHeaderScrollView extends Component {
96120 }
97121
98122 render ( ) {
123+ const scrollViewProps = _ . pick ( this . props , _ . keys ( ScrollView . propTypes ) ) ;
99124 return (
100125 < View style = { styles . container } >
101126 < ScrollView
127+ ref = { ( sv ) => { this [ SCROLLVIEW_REF ] = sv ; } }
102128 style = { styles . container }
103129 scrollEventThrottle = { 16 }
104130 onScroll = { Animated . event (
105131 [ { nativeEvent : { contentOffset : { y : this . state . scrollY } } } ] ,
106132 ) }
133+ { ...scrollViewProps }
107134 >
108135 < Animated . View style = { [ { paddingTop : this . props . maxHeight } , this . props . childrenStyle ] } >
109136 { this . props . children }
@@ -127,6 +154,7 @@ ImageHeaderScrollView.propTypes = {
127154 childrenStyle : View . propTypes . style ,
128155 foregroundParallaxRatio : React . PropTypes . number ,
129156 fadeOutForeground : React . PropTypes . bool ,
157+ ...ScrollView . propTypes ,
130158} ;
131159
132160ImageHeaderScrollView . defaultProps = {
0 commit comments