Skip to content
This repository was archived by the owner on Feb 25, 2020. It is now read-only.

Commit 2220252

Browse files
nvojnovicosdnk
authored andcommitted
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
1 parent 5aca552 commit 2220252

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/views/Drawer.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,14 @@ export default class DrawerView extends React.PureComponent<Props> {
428428
x: this.touchX,
429429
translationX: this.gestureX,
430430
velocityX: this.velocityX,
431-
state: this.gestureState,
431+
},
432+
},
433+
]);
434+
435+
private handleGestureStateChange = event([
436+
{
437+
nativeEvent: {
438+
state: (s: Animated.Value<number>) => set(this.gestureState, s),
432439
},
433440
},
434441
]);
@@ -520,7 +527,7 @@ export default class DrawerView extends React.PureComponent<Props> {
520527
activeOffsetX={[-SWIPE_DISTANCE_MINIMUM, SWIPE_DISTANCE_MINIMUM]}
521528
failOffsetY={[-SWIPE_DISTANCE_MINIMUM, SWIPE_DISTANCE_MINIMUM]}
522529
onGestureEvent={this.handleGestureEvent}
523-
onHandlerStateChange={this.handleGestureEvent}
530+
onHandlerStateChange={this.handleGestureStateChange}
524531
hitSlop={hitSlop}
525532
enabled={!locked}
526533
{...gestureHandlerProps}

0 commit comments

Comments
 (0)