FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat: cancel contradictory gesture events by MCurran16 · Pull Request #7296 · NativeScript/NativeScript · GitHub

feat: cancel contradictory gesture events - #7296

Merged
MartoYankov merged 14 commits into
NativeScript:masterfrom
MCurran16:gestures-fix
Jun 12, 2019
Merged

MartoYankov merged 14 commits into
NativeScript:masterfrom
MCurran16:gestures-fix

Conversation

MCurran16 commented Jun 2, 2019 •
edited by MartoYankov
Loading

Copy link
Copy Markdown
Contributor

PR Checklist

What is the current behavior?

When you have a tap and double tap gesture recognizer on a view and you attempt to double tap, the tap handler fires. The tap gesture event should not fire if you're attempting a double tap.

What is the new behavior?

For both platforms, the tap event will not be fired when you're attempting a doubleTap gesture.

Implements #7281

Additional Context

@MartoYankov

For android, I decided to not use onSingleTapConfirmed due to the delay that is described in this SO answer: https://stackoverflow.com/a/48844866 . I did try using onSingleTapConfirmed and there was consistently a noticeable delay and sometimes it wasn't even fired.

For iOS, the solution in the attached issue was implemented.

I also tried to get those files I changed to follow the NS code convention a bit more... hoping that's okay!

BREAKING CHANGES:

Old behavior:

  • iOS/Android:
    • double tap: child tap -> parent tap -> child double tap -> parent double tap
    • tap: child tap -> parent tap

New behavior:

  • iOS
    • double tap: child double tap
    • tap: child tap
  • Android
    • double tap: child double tap -> parent double tap
    • tap: child tap -> parent tap

Migration steps:
Move event handlers accordingly.

MCurran16 added 9 commits May 23, 2019 09:08
… gestures-fix

* 'gestures-fix' of github.com:MCurran16/NativeScript:
  Reset tns-<android/ios> for test app
  refact(iOS): code convention for iOS gestures
  fix(gestures-android): Handle tap and double tap listeners on the same target
  Fix simultaneous tap gestures for iOS

# Conflicts:
#	tns-core-modules/ui/gestures/gestures.android.ts
cla-bot Bot added the cla: yes label Jun 2, 2019
MCurran16 changed the title Gestures fix enhance(iOS/Android): Fix contradictory gesture events Jun 2, 2019

Copy link
Copy Markdown
Contributor

Also, I think this should be considered as behavior breaking change.

// If both gesture recognizers are of type UITapGestureRecognizer, do not allow
// simultaneous recognition.
if (gestureRecognizer instanceof UITapGestureRecognizer && otherGestureRecognizer instanceof UITapGestureRecognizer) {
return false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I imagine this is going to change the behavior where a tap was recognized by both parent and child. This change makes it so only one tap gesture is recognized on iOS, but seems to be unchanged on Android, which may lead to inconsistent behavior that was previously patched out (for more context see #7310)

Old behavior:

iOS and Android:
double tap: child tap -> parent tap -> child double tap -> parent double tap
tap: child tap -> parent tap

New behavior (iOS):
double tap: child double tap
tap: child tap

New behavior (Android):
double tap: child double tap -> parent double tap
tap: child tap -> parent tap

MCurran16 Jun 10, 2019 •
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@edusperoni It is already inconsistent between the platforms and this PR was not intending to fix child/parent intercepting/cancelling/bubbling.

My understanding of the iOS implementation was that the UIGestureRecognizerDelegateImpl was for a single view as the NS view is passed in which can be seen here. It sounds like that is an incorrect understanding.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Actually, the current implementation of events (and bubbling) seem to be consistent in both platforms (all events bubble and the same events trigger).

I'm aware this PR does not intend to fix child/parent bubbling, I'm pointing out that this is a behavior breaking change. The same delegate is used by all views, as seen here, so that line will affect child/parent bubbling and break consistency.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Okay that is fair. I'm understanding now.

In your mind, where do we go from here? What would you like me to do?

Maybe @MartoYankov can weigh in on next steps?

edusperoni Jun 10, 2019 •
edited
Loading

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I don't believe this is a negative change, but I can think of 3 options:

  1. if we're detecting a tap gesture, bubble this information up to views on android and prevent tap recognition up the chain
    if (this.parent instanceof View) {
    this.parent.handleGestureTouch(event);
    }
  2. Compare targets and required taps in if (gestureRecognizer instanceof UITapGestureRecognizer && otherGestureRecognizer instanceof UITapGestureRecognizer) {, so events will keep bubbling
  3. Document it as a breaking change

I believe 1 is out of scope of this PR and 2 may add unneeded complexity. Maybe the best option is really 3 until we reach a consensus on how gesture disambiguation should work in NS?

The impact of the change should be really low. The only plugin I know to handle multiple taps (nativescript-windowed-modal) only does it to prevent a parent tap when the child was tapped (using Hit Testing). My own plugin (nativescript-ng-ripple, soon to become one with nativescript-ripple) uses touch, so it probably won't be affected.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

We discussed this internally and we agree that 3 is probably the best option for now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@MCurran16 @edusperoni @MartoYankov Seems we have a problem with this specific change in UIGestureRecognizerDelegateImpl.gestureRecognizerShouldRecognizeSimultaneouslyWithGestureRecognizer(...) that breaks ActionBar usage scenario in all master/detail templates so I am reverting it for the time being -- see #7400.

Copy link
Copy Markdown
Contributor

test

MartoYankov changed the title enhance(iOS/Android): Fix contradictory gesture events feat: cancel contradictory gesture events Jun 12, 2019
MartoYankov added the docs needed Additional documentation on this issue/PR is needed label Jun 12, 2019
MartoYankov merged commit b8a82f2 into NativeScript:master Jun 12, 2019
MCurran16 deleted the gestures-fix branch June 12, 2019 12:56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes docs needed Additional documentation on this issue/PR is needed e2e test needed

Projects

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL