A ScrollView-like component that:
$ npm install react-native-image-header-scroll-view --save
import HeaderImageScrollView, { TriggeringView } from 'react-native-image-header-scroll-view';
// Inside of a component's render() method:
render() {
return (
<HeaderImageScrollView
maxHeight={200}
minHeight={MIN_HEIGHT}
headerImage={require("../../assets/NZ.jpg")}
renderForeground={() => (
<View style={{ height: 150, justifyContent: "center", alignItems: "center" }} >
<TouchableOpacity onPress={() => console.log("tap!!")}>
<Text style={{ backgroundColor: "transparent" }}>Tap Me!</Text>
</TouchableOpacity>
</View>
)}
>
<View style={{ height: 1000 }}>
<TriggeringView onHide={() => console.log("text hidden")}>
<Text>Scroll Me!</Text>
</TriggeringView>
</View>
</HeaderImageScrollView>
);
}
Result :
You can find examples in a dedicated repository.
All of the properties of ScrollView
are supported. Please refer to the ScrollView
documentation for more detail.
The HeaderImageScrollView
handle also the following props. None is required :
The module also export a TriggeringView component. It is a spy View you put on the page that will can call various callback during the scroll. It accept callback called when it disappear or appear at the top of the ImageHeaderScrollView. You can see an exemple in the dedicated repository.
All of the properties of View
are supported.
Just set the maxOverlayOpacity
to 0
.
<HeaderImageScrollView
minOverlayOpacity={0}
maxOverlayOpacity={0}
{/* ... */}
/>
You have two solutions :
disableHeaderGrow
props. It will keep the ios elastic scroll effect.bounces={false}
props from the scroll view.Results :
All contributions are welcomed, that might be either adding new features, doing some refaco of the exisiting code or fixing bugs.
How to contribute
Author: bamlab
GitHub: https://github.com/bamlab/react-native-image-header-scroll-view
#react-native #programming