I am trying to use left/right swipe to call a function on my page - I cant see an obvious way to do this?
I assume there is built in functionality to detect these kinds of gestures and then call a predefined function?
I am trying to use this as a navigation gesture - and a left and right swipe will load a component passing in a date and loading data based on that date.
Please let know if anyone can help with this. Thanks
I'll recommend this library as I don't know of any inbuilt function to achieve your need so easy. Swipe gestures
<GestureRecognizer
onSwipe={(direction, state) => this.onSwipe(direction, state)}
onSwipeUp={(state) => this.onSwipeUp(state)}
onSwipeDown={(state) => this.onSwipeDown(state)}
onSwipeLeft={(state) => this.onSwipeLeft(state)}
onSwipeRight={(state) => this.onSwipeRight(state)}
config={config}
style={{
flex: 1,
backgroundColor: this.state.backgroundColor
}}
>
<Text>{this.state.myText}</Text>
<Text>onSwipe callback received gesture: {this.state.gestureName}</Text>
</GestureRecognizer>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With