Skip to content

Commit 9c3fdad

Browse files
committed
Remove some extra props and libraries
1 parent 2f05f85 commit 9c3fdad

File tree

4 files changed

+704
-30
lines changed

4 files changed

+704
-30
lines changed

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@
4747
"react-native": ">=0.20.0"
4848
},
4949
"dependencies": {
50-
"prop-types": "^15.6.0",
51-
"react-native-image-header-scroll-view-ep": "^0.0.8",
52-
"react-native-view-overflow": "^0.0.3"
50+
"prop-types": "^15.6.0"
5351
},
5452
"eslintConfig": {
5553
"extends": "bambi/native"

src/ImageHeaderScrollView.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22
import React, { Component } from 'react';
33
import PropTypes from 'prop-types';
44
import { Animated, ScrollView, StyleSheet, View, Image, Dimensions } from 'react-native';
5-
import OverflowView from 'react-native-view-overflow';
65
import type { ViewProps } from 'ViewPropTypes';
76
import type { FlatList, SectionList, ListView } from 'react-native';
87

9-
const AnimatedOverflow = Animated.createAnimatedComponent(OverflowView);
10-
118
type ScrollViewProps = {
129
onScroll?: ?Function,
1310
style?: $PropertyType<ViewProps, 'style'>,
@@ -153,16 +150,18 @@ class ImageHeaderScrollView extends Component<Props, State> {
153150
{ opacity: overlayOpacity, backgroundColor: this.props.overlayColor },
154151
];
155152

153+
const disableOverlay =
154+
this.props.minOverlayOpacity === this.props.maxOverlayOpacity &&
155+
this.props.maxOverlayOpacity === 0;
156+
156157
return (
157-
<AnimatedOverflow
158-
style={[styles.header, headerTransformStyle, this.props.headerContainerStyle]}
159-
>
158+
<Animated.View style={[styles.header, headerTransformStyle, this.props.headerContainerStyle]}>
160159
{this.renderHeaderProps()}
161-
{!this.props.disableOverlay && <Animated.View style={overlayStyle} />}
160+
{!disableOverlay && <Animated.View style={overlayStyle} />}
162161
<View style={[styles.fixedForeground, this.props.fixedForegroundContainerStyles]}>
163162
{this.props.renderFixedForeground()}
164163
</View>
165-
</AnimatedOverflow>
164+
</Animated.View>
166165
);
167166
}
168167

@@ -280,10 +279,6 @@ class ImageHeaderScrollView extends Component<Props, State> {
280279
<ScrollViewComponent
281280
scrollEventThrottle={useNativeDriver ? 1 : 16}
282281
ref={ref => {
283-
if (getScrollViewRef) {
284-
getScrollViewRef(ref);
285-
}
286-
287282
this.scrollViewRef = ref;
288283
}}
289284
overScrollMode="never"

src/TriggeringView.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type Props = {
1313
children?: React$Node,
1414
onLayout?: Function,
1515
bottomOffset?: number,
16+
topOffset?: number,
1617
};
1718

1819
type DefaultProps = {
@@ -23,6 +24,7 @@ type DefaultProps = {
2324
onTouchTop: Function,
2425
onTouchBottom: Function,
2526
bottomOffset: number,
27+
topOffset: number,
2628
};
2729

2830
type State = {
@@ -58,6 +60,7 @@ class TriggeringView extends Component<Props, State> {
5860
onTouchTop: () => {},
5961
onTouchBottom: () => {},
6062
bottomOffset: 0,
63+
topOffset: 0,
6164
};
6265

6366
constructor(props: Props) {
@@ -107,21 +110,22 @@ class TriggeringView extends Component<Props, State> {
107110
};
108111

109112
triggerEvents(value: number, top: number, bottom: number) {
110-
if (!this.state.touched && value >= top) {
113+
const { bottomOffset, topOffset } = this.props;
114+
if (!this.state.touched && value >= top + topOffset) {
111115
this.setState({ touched: true });
112116
this.props.onBeginHidden();
113117
this.props.onTouchTop(true);
114-
} else if (this.state.touched && value < top) {
118+
} else if (this.state.touched && value < top + topOffset) {
115119
this.setState({ touched: false });
116120
this.props.onDisplay();
117121
this.props.onTouchTop(false);
118122
}
119123

120-
if (!this.state.hidden && value >= bottom + this.props.bottomOffset) {
124+
if (!this.state.hidden && value >= bottom + bottomOffset) {
121125
this.setState({ hidden: true });
122126
this.props.onHide();
123127
this.props.onTouchBottom(true);
124-
} else if (this.state.hidden && value < bottom + this.props.bottomOffset) {
128+
} else if (this.state.hidden && value < bottom + bottomOffset) {
125129
this.setState({ hidden: false });
126130
this.props.onBeginDisplayed();
127131
this.props.onTouchBottom(false);

0 commit comments

Comments
 (0)