Title: Gestures: tap and double tap on the same View · Issue #7281 · NativeScript/NativeScript · GitHub
Open Graph Title: Gestures: tap and double tap on the same View · Issue #7281 · NativeScript/NativeScript
X Title: Gestures: tap and double tap on the same View · Issue #7281 · NativeScript/NativeScript
Description: Environment CLI: latest Cross-platform modules: 5.4.0 Android Runtime: 5.4.0 iOS Runtime: 5.4.0 Describe the bug When you have a tap and double tap gesture recognizer on a view and you attempt to double tap, the tap handler fires. The ta...
Open Graph Description: Environment CLI: latest Cross-platform modules: 5.4.0 Android Runtime: 5.4.0 iOS Runtime: 5.4.0 Describe the bug When you have a tap and double tap gesture recognizer on a view and you attempt to d...
X Description: Environment CLI: latest Cross-platform modules: 5.4.0 Android Runtime: 5.4.0 iOS Runtime: 5.4.0 Describe the bug When you have a tap and double tap gesture recognizer on a view and you attempt to d...
Opengraph URL: https://github.com/NativeScript/NativeScript/issues/7281
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Gestures: tap and double tap on the same View","articleBody":"**Environment**\r\n - CLI: latest\r\n - Cross-platform modules: 5.4.0\r\n - Android Runtime: 5.4.0\r\n - iOS Runtime: 5.4.0\r\n\r\n**Describe the bug**\r\nWhen 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. Take a look at the \"Additional context\" for the commit that allowed this.\r\n\r\n**To Reproduce**\r\n\r\n```\r\nexport class TestLayout extends StackLayout {\r\n onLoaded() {\r\n super.onLoaded();\r\n\r\n this.on(GestureTypes.tap, () =\u003e console.log('Tapped'));\r\n this.on(GestureTypes.doubleTap, () =\u003e console.log('Double tapped'));\r\n }\r\n}\r\n```\r\n\r\nIf you attempt to double tap on the `TestLayout`, the console will show:\r\n\u003e `Tapped`\r\n\u003e `Double tapped`\r\n\r\n**Expected behavior**\r\nIf you try to double tap on a view with a tap gesture recognizer and a double tap gesture recognizer, the double tap event should fire and the tap should not. \r\n\r\n**Additional context**\r\n\r\nI have been working through this issue with @MartoYankov .\r\n\r\n[Here is the commit that allowed simultaneous gesture events](https://github.com/NativeScript/NativeScript/commit/fe72a43e49cc318d7a4cc2488d66aaf9e07feab1)\r\n\r\n[Here are the docs to the delegate method that could be implemented for iOS](https://developer.apple.com/documentation/uikit/uigesturerecognizerdelegate/1624229-gesturerecognizer?language=objc)\r\n- I have already implemented this ^ for iOS (see below). The issue now is getting the same functionality for Android.\r\n\r\n\r\n**Potential solution (iOS)**\r\n\r\n`gestures.ios.ts`\r\n```\r\nclass UIGestureRecognizerDelegateImpl extends NSObject implements UIGestureRecognizerDelegate {\r\n public static ObjCProtocols = [UIGestureRecognizerDelegate];\r\n\r\n public gestureRecognizerShouldRecognizeSimultaneouslyWithGestureRecognizer(gestureRecognizer: UIGestureRecognizer, otherGestureRecognizer: UIGestureRecognizer): boolean {\r\n // If both gesture recognizers are of type UITapGestureRecognizer, do not allow\r\n // simultaneous recognition.\r\n if (gestureRecognizer instanceof UITapGestureRecognizer \u0026\u0026 otherGestureRecognizer instanceof UITapGestureRecognizer) {\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n public gestureRecognizerShouldRequireFailureOfGestureRecognizer(gestureRecognizer: UIGestureRecognizer, otherGestureRecognizer: UIGestureRecognizer): boolean {\r\n // If both gesture recognizers are of type UITapGestureRecognizer \u0026 one of them is a doubleTap,\r\n // we must require a failure.\r\n if (gestureRecognizer instanceof UITapGestureRecognizer\r\n \u0026\u0026 otherGestureRecognizer instanceof UITapGestureRecognizer\r\n \u0026\u0026 otherGestureRecognizer.numberOfTapsRequired === 2) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n}\r\n```","author":{"url":"https://github.com/MCurran16","@type":"Person","name":"MCurran16"},"datePublished":"2019-05-23T18:45:26.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/7281/NativeScript/issues/7281"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:671e57ff-1b62-5f92-6fec-b04ed4bf7d4d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DB72:2F9E:1D03490:255B6AD:69749E99 |
| html-safe-nonce | 77bbb050f14e3e3e4aadb0b1a5d0eed8fd820a1ab48934f3649c32664128c5c9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQjcyOjJGOUU6MUQwMzQ5MDoyNTVCNkFEOjY5NzQ5RTk5IiwidmlzaXRvcl9pZCI6IjgwNTU4NDA4NjY0OTU3NzExMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 48c8700a1b868a3dbe4f118d4fe3fcc3f530c8bdbdf599f4a96c9d4f1234c093 |
| hovercard-subject-tag | issue:447817253 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/NativeScript/NativeScript/7281/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b840b32937ecd397f4e9b0195cbccd4f289bb03d2fef5a8b7d406faf0e497b2c/NativeScript/NativeScript/issues/7281 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b840b32937ecd397f4e9b0195cbccd4f289bb03d2fef5a8b7d406faf0e497b2c/NativeScript/NativeScript/issues/7281 |
| og:image:alt | Environment CLI: latest Cross-platform modules: 5.4.0 Android Runtime: 5.4.0 iOS Runtime: 5.4.0 Describe the bug When you have a tap and double tap gesture recognizer on a view and you attempt to d... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | MCurran16 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4a4bf5f4e28041a9d2e5c107d7d20b78b4294ba261cab243b28167c16a623a1f |
| turbo-cache-control | no-preview |
| go-import | github.com/NativeScript/NativeScript git https://github.com/NativeScript/NativeScript.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 31492490 |
| octolytics-dimension-repository_nwo | NativeScript/NativeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31492490 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/NativeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 488b30e96dfd057fbbe44c6665ccbc030b729dde |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width