From 1a6858599027dd57c654e93585732578d47e223a Mon Sep 17 00:00:00 2001 From: Eric Vicenti Date: Tue, 12 May 2015 14:52:38 -0700 Subject: [PATCH] [ReactNative] Navigator fix rapid gesture breakage Summary: When gesturing rapidly between scenes, the navigator can get into an unresponsive state. A few minor fixes can avoid that case @public Test Plan: Rapid gestures on iOS device and simulator can no longer get into bad state --- Libraries/CustomComponents/Navigator/Navigator.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Libraries/CustomComponents/Navigator/Navigator.js b/Libraries/CustomComponents/Navigator/Navigator.js index c8263c4a8..c3ce76951 100644 --- a/Libraries/CustomComponents/Navigator/Navigator.js +++ b/Libraries/CustomComponents/Navigator/Navigator.js @@ -582,7 +582,7 @@ var Navigator = React.createClass({ * This happens at the end of a transition started by transitionTo, and when the spring catches up to a pending gesture */ _completeTransition: function() { - if (this.spring.getCurrentValue() !== 1) { + if (this.spring.getCurrentValue() !== 1 && this.spring.getCurrentValue() !== 0) { // The spring has finished catching up to a gesture in progress. Remove the pending progress // and we will be in a normal activeGesture state if (this.state.pendingGestureProgress) { @@ -883,7 +883,10 @@ var Navigator = React.createClass({ var gesturingToIndex = this.state.presentedIndex + this._deltaForGestureAction(this.state.activeGesture); this._transitionBetween(this.state.presentedIndex, gesturingToIndex, 0); this._detachGesture(); - this.spring.setCurrentValue(0); + if (this.state.pendingGestureProgress != null) { + this.spring.setCurrentValue(0); + } + return; } if (this._doesGestureOverswipe(this.state.activeGesture)) { var frictionConstant = gesture.overswipe.frictionConstant;