Skip to content

Commit 3c37ff1

Browse files
authored
Merge pull request #62 from RyverApp/feature/add-prop-for-extrapolation
Prop for foreground extrapolation
2 parents 3d9d011 + 1ef7078 commit 3c37ff1

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ The `HeaderImageScrollView` handle also the following props. None is required :
8484
| -------- | ---- | ------- | ----------- | ------- |
8585
| `renderForeground` | `function` | Empty view | Function which return the component to use at foreground. The component is render in front of the header and scroll with the ScrollView. It can return a title for example.| [example](https://github.com/bamlab/react-native-image-header-scroll-view-example/blob/master/src/Pages/TvShow.js#L112) |
8686
| `renderFixedForeground` | `function` | Empty view | Function which return the component to use as fixed foreground. The component is displayed with the header but not affected by the overlay.| [example](https://github.com/bamlab/react-native-image-header-scroll-view-example/blob/3b9d2d0d7f71c6bf877e2d10cc65c9ab7e1b484d/src/Pages/TvShow.js#L100) |
87+
| `foregroundExtrapolate` | `string` | `clamp` | Optional prop that allows override extrapolate mode for foreground. Use `null` to allow extrapolation, which is usefull for using foreground as bottom title | - |
8788
| `foregroundParallaxRatio` | `number` | `1` | Ration for parallax effect of foreground when scrolling. If 2, the header goes up two times faster than the scroll | [example](https://github.com/bamlab/react-native-image-header-scroll-view-example/blob/master/src/Pages/Colors.js#L23) |
8889
| `fadeOutForeground` | `bool` | `false` | If set, add a fade out effect on the foreground when scroll up | [example](https://github.com/bamlab/react-native-image-header-scroll-view-example/blob/master/src/Pages/Colors.js#L13) |
8990
| `renderTouchableFixedForeground` | `function` | Empty view | Same as `renderFixedForeground` but allow to use touchable in it. [*Can cause performances issues on Android*](https://github.com/bamlab/react-native-image-header-scroll-view/issues/6)| [example](https://github.com/bamlab/react-native-image-header-scroll-view-example/blob/master/src/Pages/PullToRefresh.js#L45) |

src/ImageHeaderScrollView.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export type Props = ScrollViewProps & {
3838
renderFixedForeground: () => React$Element<any>,
3939
renderForeground?: () => React$Element<any>,
4040
renderHeader: () => React$Element<any>,
41+
foregroundExtrapolate: ?string,
4142
renderTouchableFixedForeground?: ?() => React$Element<any>,
4243
ScrollViewComponent: React$ComponentType<ScrollViewProps>,
4344
scrollViewBackgroundColor: string,
@@ -58,6 +59,7 @@ export type DefaultProps = {
5859
minOverlayOpacity: number,
5960
renderFixedForeground: () => React$Element<any>,
6061
renderHeader: () => React$Element<any>,
62+
foregroundExtrapolate: string,
6163
ScrollViewComponent: React$ComponentType<ScrollViewProps>,
6264
scrollViewBackgroundColor: string,
6365
};
@@ -84,6 +86,7 @@ class ImageHeaderScrollView extends Component<Props, State> {
8486
minHeight: 80,
8587
minOverlayOpacity: 0,
8688
renderFixedForeground: () => <View />,
89+
foregroundExtrapolate: 'clamp',
8790
renderHeader: () => <View />,
8891
ScrollViewComponent: ScrollView,
8992
scrollViewBackgroundColor: 'white',
@@ -169,7 +172,7 @@ class ImageHeaderScrollView extends Component<Props, State> {
169172
const headerTranslate = this.state.scrollY.interpolate({
170173
inputRange: [0, this.props.maxHeight * 2],
171174
outputRange: [0, -this.props.maxHeight * 2 * this.props.foregroundParallaxRatio],
172-
extrapolate: 'clamp',
175+
extrapolate: this.props.foregroundExtrapolate,
173176
});
174177

175178
const headerTransformStyle = {

src/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ declare module "react-native-image-header-scroll-view" {
3333
renderFixedForeground?: () => React.ReactElement;
3434
renderForeground?: () => React.ReactElement;
3535
renderHeader?: () => React.ReactElement; // default is an empty view.
36+
foregroundExtrapolate: ?string;
3637
renderTouchableFixedForeground?: () => React.ReactElement;
3738
ScrollViewComponent?: React.ComponentType<ScrollViewProps>;
3839
scrollViewBackgroundColor?: string; // defaults to white.

0 commit comments

Comments
 (0)