Fix navigation jump on multi-tap

Summary:
On iOS, if a non-selected breadcrumb is tapped multiple times, the navigator will transition to the tapped breadcrumb, then back to the previously selected breadcrumb. Then, when another breadcrumb is tapped, it would go to the previously multi-tapped breadcrumb.

This seems to be because transitions are queued when they shouldn't be. I've reverted to the way it was before PR 8701, but added a `transitionQueue.length === 0`. This should solve the race condition from 8701, ensuring all transitions in the queue are flushed in sequence, and thus landing on the finally tapped one.

Reviewed By: hedgerwang

Differential Revision: D3469901

fbshipit-source-id: 0143a27d6c875d47d28b77eed4e5a28b1c40c8bb
This commit is contained in:
Fred Liu 2016-06-22 11:00:17 -07:00 committed by Facebook Github Bot 7
parent 550fed5ce8
commit b3886652ab
1 changed files with 7 additions and 3 deletions

View File

@ -373,6 +373,12 @@ var Navigator = React.createClass({
},
_transitionTo: function(destIndex, velocity, jumpSpringTo, cb) {
if (
destIndex === this.state.presentedIndex &&
this.state.transitionQueue.length === 0
) {
return;
}
if (this.state.transitionFromIndex !== null) {
this.state.transitionQueue.push({
destIndex,
@ -381,9 +387,7 @@ var Navigator = React.createClass({
});
return;
}
if (destIndex === this.state.presentedIndex) {
return;
}
this.state.transitionFromIndex = this.state.presentedIndex;
this.state.presentedIndex = destIndex;
this.state.transitionCb = cb;