Skip to content

Fix issues #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Feb 4, 2018
Prev Previous commit
Next Next commit
Allow to override onScroll and style Props
  • Loading branch information
Nhacsam committed Feb 3, 2018
commit 0bb06fd3d98fd4e2ba453b74310dc7ad358c8330
16 changes: 12 additions & 4 deletions src/ImageHeaderScrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { Animated, ScrollView, StyleSheet, View } from 'react-native';
import type { ViewProps } from 'ViewPropTypes';

export type Props = {
children?: ?React$Element<any>,
Expand All @@ -17,6 +18,8 @@ export type Props = {
renderForeground: () => React$Element<any>,
renderHeader: () => React$Element<any>,
renderTouchableFixedForeground?: ?() => React$Element<any>,
style?: $PropertyType<ViewProps, 'style'>,
onScroll?: ?Function,
};

export type DefaultProps = {
Expand Down Expand Up @@ -216,6 +219,8 @@ class ImageHeaderScrollView extends Component<Props, State> {
renderForeground,
renderHeader,
renderTouchableFixedForeground,
style,
onScroll,
...scrollViewProps
} = this.props;
/* eslint-enable no-unused-vars */
Expand All @@ -239,12 +244,15 @@ class ImageHeaderScrollView extends Component<Props, State> {
<Animated.View style={[styles.container, { transform: [{ translateY: topMargin }] }]}>
<ScrollView
ref={ref => (this.scrollViewRef = ref)}
style={styles.container}
scrollEventThrottle={16}
onScroll={Animated.event([
{ nativeEvent: { contentOffset: { y: this.state.scrollY } } },
])}
{...scrollViewProps}
style={[styles.container, style]}
onScroll={Animated.event(
[{ nativeEvent: { contentOffset: { y: this.state.scrollY } } }],
{
listener: onScroll,
}
)}
>
<Animated.View style={childrenContainerStyle}>{children}</Animated.View>
</ScrollView>
Expand Down