mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-02-13 09:39:18 +08:00
fix: navigation drawer sometimes not closing when pressed outside (#126)
I noticed this issue only on android devices. After many rewrites of this component I ended up with this simple change and now drawer is closing properly every time. Most important part is to set new state inside function with state: (s: Animated.Value<number>) => set(this.gestureState, s) because I was also experiencing some issues when setting it like this state: this.gestureState
This commit is contained in:
@@ -428,7 +428,14 @@ export default class DrawerView extends React.PureComponent<Props> {
|
||||
x: this.touchX,
|
||||
translationX: this.gestureX,
|
||||
velocityX: this.velocityX,
|
||||
state: this.gestureState,
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
private handleGestureStateChange = event([
|
||||
{
|
||||
nativeEvent: {
|
||||
state: (s: Animated.Value<number>) => set(this.gestureState, s),
|
||||
},
|
||||
},
|
||||
]);
|
||||
@@ -520,7 +527,7 @@ export default class DrawerView extends React.PureComponent<Props> {
|
||||
activeOffsetX={[-SWIPE_DISTANCE_MINIMUM, SWIPE_DISTANCE_MINIMUM]}
|
||||
failOffsetY={[-SWIPE_DISTANCE_MINIMUM, SWIPE_DISTANCE_MINIMUM]}
|
||||
onGestureEvent={this.handleGestureEvent}
|
||||
onHandlerStateChange={this.handleGestureEvent}
|
||||
onHandlerStateChange={this.handleGestureStateChange}
|
||||
hitSlop={hitSlop}
|
||||
enabled={!locked}
|
||||
{...gestureHandlerProps}
|
||||
|
||||
Reference in New Issue
Block a user