我没有看到任何内置的方法可以告诉你用户最近是否在react原生中触摸过屏幕。有没有什么你可以跟踪用户有多久没有触摸过屏幕。
发布于 2019-05-24 04:06:30
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
})
}
});
https://stackoverflow.com/questions/56282205
复制相似问题