Vertical Step indicator
May 06, 2023
1 min
Property | Type | Default | Description |
---|---|---|---|
renderHeader | function | Empty view | Function which return the component to use as header. It can return background image for example. |
headerImage | Image source Props (object or number) | undefined | Shortcut for renderHeader={() => <Image source={this.props.headerImage} style={{ height: this.props.maxHeight, width: Dimensions.get('window').width }} />} -example/blob/master/src/Pages/BasicUsage.js#L26) |
maxHeight | number | 125 | Max height for the header |
minHeight | number | 80 | Min height for the header (in navbar mode) |
minOverlayOpacity | number | 0 | Opacity of a black overlay on the header before any scroll |
maxOverlayOpacity | number | 0.3 | Opacity of a black overlay on the header when in navbar mode |
overlayColor | string | black | Color of the overlay on the header |
useNativeDriver | boolean | false | Use native driver for the animation for performance improvement. A few props are unsupported at the moment if useNativeDriver=true (onScroll , ScrollComponent , renderTouchableFixedForeground ) |
headerContainerStyle | Object | undefined | Optional styles to be passed to the container of the header component |
disableHeaderGrow | boolean | undefined | Disable to grow effect on the header |
Property | Type | Default | Description |
---|---|---|---|
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. |
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. |
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 |
foregroundParallaxRatio | number | 1 | Ration for parallax effect of foreground when scrolling. If 2, the header goes up two times faster than the scroll |
fadeOutForeground | bool | false | If set, add a fade out effect on the foreground when scroll up |
renderTouchableFixedForeground | function | Empty view | Same as renderFixedForeground but allow to use touchable in it. |
fixedForegroundContainerStyles | Object | undefined | Optional styles to be passed to the container of the fixed foreground component |
Property | Type | Default | Description |
---|---|---|---|
ScrollViewComponent | Component | ScrollView | The component to be used for scrolling. Can be any component with an onScroll props (ie. ListView , FlatList , SectionList or ScrollView ) |
scrollViewBackgroundColor | string | white | Background color of the scrollView content |
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.
All of the properties of View
are supported.
Property | Type | Description |
---|---|---|
onBeginHidden | function | Called when the component start to be hidden at the top of the scroll view. |
onHide | function | Called when the component is not displayed any more after scroll up |
onBeginDisplayed | function | Called when the component begin to be displayed again after scroll down |
onDisplay | function | Called when the component finished to be displayed again. |
onTouchTop | function | Called when the Top of the component touch the Top of the ScrollView. (onDisplay + onBeginHidden ) |
onTouchBottom | function | Called when the Bottom of the component touch the Top of the ScrollView. (onHide + onBeginDisplayed ) |
npm install react-native-image-header-scroll-view --save
import React from 'react'; import { StyleSheet, View, Text, TouchableOpacity, Image } from 'react-native'; import { ImageHeaderScrollView, TriggeringView } from 'react-native-image-header-scroll-view'; export default function App() { const MIN_HEIGHT = 50; // Set the minimum height for the header image return ( <View style={{ flex: 1 }}> <ImageHeaderScrollView maxHeight={200} minHeight={MIN_HEIGHT} headerImage={require("./assets/snack-icon.png")} renderForeground={() => ( <View style={styles.header}> <TouchableOpacity onPress={() => console.log("tap!!")}> <Text style={styles.headerText}>Tap Me!</Text> </TouchableOpacity> </View> )} > <View style={styles.content}> <TriggeringView onHide={() => console.log("text hidden")}> <Text style={styles.title}>Welcome to My App</Text> </TriggeringView> <Text style={styles.paragraph}> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </Text> <Text style={styles.paragraph}> Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. </Text> <Text style={styles.paragraph}> Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. </Text> </View> </ImageHeaderScrollView> </View> ); } const styles = StyleSheet.create({ header: { height: 150, justifyContent: "center", alignItems: "center" }, headerText: { backgroundColor: "transparent", color: "#fff", fontSize: 24 }, content: { padding: 20 }, title: { fontSize: 36, fontWeight: "bold", marginBottom: 20 }, paragraph: { fontSize: 18, marginBottom: 20 } });
Coming Soon…
Quick Links
Legal Stuff