3

I am trying to show a search bar on pulling down the screen and hiding it on scroll the view up.

Below is my react-native code:

render() {
    return (
        <View style={styles.container}>
            <ScrollView
                style={styles.scrollView}
                onScroll={() => { console.log('onMomentumScrollBegin'); }}
                onScrollBeginDrag={() => { console.log('onScrollBeginDrag'); }}
                onScrollEndDrag={() => { console.log('onScrollEndDrag'); }}
            >
                <SearchBar
                    onChangeText={(obj) => {console.log(obj);}}
                    placeholder='Type Here...'
                    icon={{ type: 'font-awesome', name: 'search' }}
                />
                <View style={styles.innerContainer}>
                    <Text>Hello</Text>
                </View>
                <View style={styles.innerContainer}>
                    <Text>Hello</Text>
                </View>
            </ScrollView>
        </View>
    );
}

onScroll, onScrollBeginDrag, onScrollEndDrag is not calling if there are not enough elements for scroll.

Here is screenshot of my screen:

enter image description here

If anyone has any idea about how to achieve it, that will be very helpful.

Thanks in advance.

Shubham
  • 1,755
  • 3
  • 17
  • 33
  • take the scroll value and compare to old one if its negative then you are going up and if its positive then you are going down – Jigar Sep 04 '18 at 13:25
  • @Jigar, how to take scroll value if these events are not firing? Is there any other way to achieve it? – Shubham Sep 05 '18 at 04:10

0 Answers0