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:
nvojnovic
2019-10-21 10:08:36 +02:00
parent eb51bab778
commit ff9dd732ad

View File

@@ -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}