Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Gesture.Manual().shouldCancelWhenOutside(true) doesn't work on iOS or web #2265

Closed
elliotwaite opened this issue Oct 10, 2022 · 7 comments
Closed
Labels
Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Platform: Web Repro provided A reproduction with a snack or repo is provided

Comments

@elliotwaite
Copy link

elliotwaite commented Oct 10, 2022

Description

Using Gesture.Manual().shouldCancelWhenOutside(true) doesn't seem to work on iOS or web. As can be seen in this demo:

ezgif-5-9f11e5bccb

UPDATE: I did some more testing to compare how Tap, LongPress, and Manual work when using shouldCancelWhenOutside(true).

On Android it works correctly for all three gestures (Tap, LongPress, and Manual):
ezgif-android

On iOS it works correctly for Tap and LongPress but not Manual:
ezgif-ios

On the web:

  • It doesn't work for Tap.
  • It works for LongPress if the press starts near the center of the element, but it doesn't work if the press starts near the edge of the element.
  • It doesn't work for Manual.
    ezgif-web

Steps to reproduce

You can test out the Android and iOS versions using this Snack demo, but I haven't figured out how to get the web version to work on Snack yet. If I try to use enableExperimentalWebImplementation(true), it says it's not a function. Any suggestions? However, I tested the web version on my local machine as can be seen in the animated GIFs.

Snack or a link to a repository

https://snack.expo.dev/@elliotwaite/rngh-shouldcancelwhenoutside

Gesture Handler version

2.7.0

React Native version

0.69.0

Platforms

Android, iOS, Web

JavaScript runtime

No response

Workflow

No response

Architecture

No response

Build type

No response

Device

No response

Device model

No response

Acknowledgements

Yes

@github-actions github-actions bot added Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Platform: Web Repro provided A reproduction with a snack or repo is provided labels Oct 10, 2022
@m-bert
Copy link
Contributor

m-bert commented Oct 11, 2022

Hi @elliotwaite 👋 Please have a look at this PR, which should solve problems on web version.

@elliotwaite
Copy link
Author

@Warus15, okay, nice, thanks for the update.

m-bert added a commit that referenced this issue Oct 13, 2022
## Description

This PR solves web part of #2265 issue. I've modified `onPointerOut` method to act similar as on android. Right now, if pointer leaves handler and `shouldCancelWhenOutside` is set to `true`, handler goes to `cancel` state if it was `active`, or to `fail`, if it was in `began`

This change also affects `ManualGestureHandler`, which now cancels properly.

## Test plan

Tested on example app
@m-bert
Copy link
Contributor

m-bert commented Oct 14, 2022

Hi @elliotwaite!

I've also managed to solve this problem on iOS, could you have a look at this PR and check whether it indeed solves your issue?

@elliotwaite
Copy link
Author

Hey @Warus15, yeah, I just tested out that new PR and it fixed the issue for me on iOS. And that previous PR fixed the web version. Thanks!

Should I close this issue now or wait till that PR is merged?

@m-bert
Copy link
Contributor

m-bert commented Oct 17, 2022

Hello @elliotwaite! You can close this issue, this PR should be merged pretty quickly so there's no need to wait for that.

m-bert added a commit that referenced this issue Oct 17, 2022
## Description

This PR adds changes in `ManualGestureHandler` on iOS. It should now properly react to `shouldCancelWhenOutside` prop. This PR should solve part of #2265 issue.

## Test plan

Tested on example app
@m-bert
Copy link
Contributor

m-bert commented Oct 17, 2022

I'm closing this issue since the PR has been merged. Feel free to re-open it if something isn't right.

@m-bert m-bert closed this as completed Oct 17, 2022
@elliotwaite
Copy link
Author

@Warus15, sounds good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Android This issue is specific to Android Platform: iOS This issue is specific to iOS Platform: Web Repro provided A reproduction with a snack or repo is provided
Projects
None yet
Development

No branches or pull requests

2 participants