Skip to content

Commit 0bb06fd

Browse files
committed
Allow to override onScroll and style Props
1 parent eccfd1e commit 0bb06fd

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/ImageHeaderScrollView.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import React, { Component } from 'react';
33
import PropTypes from 'prop-types';
44
import { Animated, ScrollView, StyleSheet, View } from 'react-native';
5+
import type { ViewProps } from 'ViewPropTypes';
56

67
export type Props = {
78
children?: ?React$Element<any>,
@@ -17,6 +18,8 @@ export type Props = {
1718
renderForeground: () => React$Element<any>,
1819
renderHeader: () => React$Element<any>,
1920
renderTouchableFixedForeground?: ?() => React$Element<any>,
21+
style?: $PropertyType<ViewProps, 'style'>,
22+
onScroll?: ?Function,
2023
};
2124

2225
export type DefaultProps = {
@@ -216,6 +219,8 @@ class ImageHeaderScrollView extends Component<Props, State> {
216219
renderForeground,
217220
renderHeader,
218221
renderTouchableFixedForeground,
222+
style,
223+
onScroll,
219224
...scrollViewProps
220225
} = this.props;
221226
/* eslint-enable no-unused-vars */
@@ -239,12 +244,15 @@ class ImageHeaderScrollView extends Component<Props, State> {
239244
<Animated.View style={[styles.container, { transform: [{ translateY: topMargin }] }]}>
240245
<ScrollView
241246
ref={ref => (this.scrollViewRef = ref)}
242-
style={styles.container}
243247
scrollEventThrottle={16}
244-
onScroll={Animated.event([
245-
{ nativeEvent: { contentOffset: { y: this.state.scrollY } } },
246-
])}
247248
{...scrollViewProps}
249+
style={[styles.container, style]}
250+
onScroll={Animated.event(
251+
[{ nativeEvent: { contentOffset: { y: this.state.scrollY } } }],
252+
{
253+
listener: onScroll,
254+
}
255+
)}
248256
>
249257
<Animated.View style={childrenContainerStyle}>{children}</Animated.View>
250258
</ScrollView>

0 commit comments

Comments
 (0)