Reputation: 164
I don't see any built in method that can tell you if the user has touched the screen recently in react native. Is there anyway you can keep track of how long it's been since the user has touched the screen.
Upvotes: 0
Views: 428
Reputation: 71
PanResponder
this._panResponder = PanResponder.create({
onMoveShouldSetResponderCapture: () => true,
onMoveShouldSetPanResponderCapture: () => true,
// Initially, set the Y position offset when touch start
onPanResponderGrant: (e, gestureState) => {
this.setState({
offset: e.nativeEvent.pageY,
isDividerClicked: true
})
},
// When we drag the divider, set the bottomHeight (component state) again.
onPanResponderMove: (e, gestureState) => {
this.setState({
bottomHeight : gestureState.moveY > (this.state.deviceHeight - 40) ? 40 : this.state.deviceHeight - gestureState.moveY,
offset: e.nativeEvent.pageY
})
},
onPanResponderRelease: (e, gestureState) => {
// Do something here for the touch end event
this.setState({
offset: e.nativeEvent.pageY,
isDividerClicked: false
})
}
});
Upvotes: 2