Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix: swiping in navigator too quickly causes the gesture to be lost #6249

Conversation

felixakiragreen
Copy link
Contributor

Issue:

In the Navigator if a user attempts to navigate backwards (or forwards) through the route stack by swiping and they perform the gesture too quickly, the gesture is lost and nothing happens.

Cause:

In the _matchGestureAction function, the variable moveStartedInRegion is created and evaluates the gesture to determine if it was initiated in a valid region, (a.k.a. within the edgeHitWidth). The issue arises because moveStartedInRegion uses currentLoc (which is created from gestureState.moveX/Y) and when the gesture is performed using a flick of the finger, the first value of the currentLoc is outside of the edgeHitWidth.

Solution:

The solution is to track the coordinates of the initial grant (gestureState.x0/y0), and use that value instead of the currentLoc when evaluating moveStartedInRegion. The currentLoc is still needed however, for when the gestureState does not have a an initial x and y value, because the pan responder has not been granted.

@facebook-github-bot
Copy link
Contributor

By analyzing the blame information on this pull request, we identified @jmstout, @ericvicenti and @hedgerwang to be potential reviewers.

@facebook-github-bot facebook-github-bot added GH Review: review-needed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Mar 2, 2016
@felixakiragreen felixakiragreen force-pushed the bug-navigator-swiping-too-fast branch from 0fce616 to a178be0 Compare March 2, 2016 19:26
@@ -804,8 +806,11 @@ var Navigator = React.createClass({
-(SCREEN_HEIGHT - edgeHitWidth) :
-(SCREEN_WIDTH - edgeHitWidth);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eqeqeq: Expected '===' and instead saw '=='.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@felixakiragreen felixakiragreen force-pushed the bug-navigator-swiping-too-fast branch from a178be0 to 7a729da Compare March 14, 2016 16:13
@facebook-github-bot
Copy link
Contributor

@DUBERT updated the pull request.

1 similar comment
@facebook-github-bot
Copy link
Contributor

@DUBERT updated the pull request.

@felixakiragreen felixakiragreen force-pushed the bug-navigator-swiping-too-fast branch from 3d74e6b to c07c69e Compare March 14, 2016 16:16
@felixakiragreen felixakiragreen changed the title Swiping in navigator too quickly causes the gesture to be lost Fix: swiping in navigator too quickly causes the gesture to be lost Mar 14, 2016
@felixakiragreen felixakiragreen force-pushed the bug-navigator-swiping-too-fast branch from c07c69e to d638957 Compare March 29, 2016 15:08
@facebook-github-bot
Copy link
Contributor

@DUBERT updated the pull request.

@felixakiragreen
Copy link
Contributor Author

Would @jmstout, @ericvicenti or @hedgerwang mind reviewing this? It's a pretty annoying and significant bug.

@ghost
Copy link

ghost commented Apr 12, 2016

@ericvicenti would you mind taking a look at this pull request? It's been a while since the last commit was reviewed.

@ericvicenti
Copy link
Contributor

Sorry for the big delay for such a clear fix!

@ericvicenti
Copy link
Contributor

@facebook-github-bot shipit

@facebook-github-bot
Copy link
Contributor

Thanks for importing. If you are an FB employee go to Phabricator to review.

format code

change == to ===
@felixakiragreen felixakiragreen force-pushed the bug-navigator-swiping-too-fast branch from d638957 to 56dd6f6 Compare April 12, 2016 17:42
@facebook-github-bot
Copy link
Contributor

@DUBERT updated the pull request.

@ghost ghost closed this in ca2fb70 Apr 12, 2016
@felixakiragreen felixakiragreen deleted the bug-navigator-swiping-too-fast branch April 12, 2016 18:25
zebulgar pushed a commit to nightingale/react-native that referenced this pull request Jun 18, 2016
Summary:**Issue:**

In the Navigator if a user attempts to navigate backwards (or forwards) through the route stack by swiping and they perform the gesture too quickly, the gesture is lost and nothing happens.

**Cause:**

In the `_matchGestureAction` function, the variable `moveStartedInRegion` is created and evaluates the gesture to determine if it was initiated in a valid region, (a.k.a. within the `edgeHitWidth`). The issue arises because `moveStartedInRegion` uses `currentLoc` (which is created from `gestureState.moveX`/`Y`) and when the gesture is performed using a flick of the finger, the first value of the `currentLoc` is outside of the `edgeHitWidth`.

**Solution:**

The solution is to track the coordinates of the initial grant (`gestureState.x0`/`y0`), and use that value instead of the `currentLoc` when evaluating `moveStartedInRegion`. The `currentLoc` is still needed however, for when the gestureState does not have a an initial x and y value, because the pan responder has not been granted.
Closes facebook#6249

Differential Revision: D3168726

Pulled By: ericvicenti

fb-gh-sync-id: f2ac462e59bdc38536b99cac6a4877c99fa4e869
fbshipit-source-id: f2ac462e59bdc38536b99cac6a4877c99fa4e869
This pull request was closed.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants