react-native-gesture-handler 2.8.0 → 2.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (285) hide show
  1. package/README.md +1 -0
  2. package/RNGestureHandler.podspec +2 -2
  3. package/android/build.gradle +107 -65
  4. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt +1 -1
  5. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +2 -0
  6. package/android/src/main/java/com/swmansion/gesturehandler/core/NativeViewGestureHandler.kt +39 -0
  7. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +9 -2
  8. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.kt +14 -2
  9. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +5 -1
  10. package/android/src/main/jni/CMakeLists.txt +10 -44
  11. package/android/src/main/jni/cpp-adapter.cpp +16 -13
  12. package/ios/Handlers/RNFlingHandler.m +39 -37
  13. package/ios/Handlers/RNForceTouchHandler.m +19 -17
  14. package/ios/Handlers/RNLongPressHandler.m +20 -22
  15. package/ios/Handlers/RNManualHandler.m +2 -3
  16. package/ios/Handlers/RNNativeViewHandler.mm +96 -92
  17. package/ios/Handlers/RNPanHandler.m +28 -32
  18. package/ios/Handlers/RNPinchHandler.m +9 -10
  19. package/ios/Handlers/RNRotationHandler.m +11 -14
  20. package/ios/Handlers/RNTapHandler.m +26 -26
  21. package/ios/RNGestureHandler.h +31 -24
  22. package/ios/RNGestureHandler.m +278 -273
  23. package/ios/RNGestureHandlerActionType.h +6 -4
  24. package/ios/RNGestureHandlerButton.m +11 -12
  25. package/ios/RNGestureHandlerButtonComponentView.h +2 -2
  26. package/ios/RNGestureHandlerButtonComponentView.mm +2 -2
  27. package/ios/RNGestureHandlerButtonManager.m +6 -5
  28. package/ios/RNGestureHandlerDirection.h +4 -4
  29. package/ios/RNGestureHandlerEvents.h +3 -4
  30. package/ios/RNGestureHandlerEvents.m +114 -119
  31. package/ios/RNGestureHandlerManager.h +1 -2
  32. package/ios/RNGestureHandlerManager.mm +9 -9
  33. package/ios/RNGestureHandlerModule.h +1 -2
  34. package/ios/RNGestureHandlerModule.mm +142 -138
  35. package/ios/RNGestureHandlerPointerTracker.h +1 -1
  36. package/ios/RNGestureHandlerPointerTracker.m +40 -37
  37. package/ios/RNGestureHandlerRegistry.h +3 -1
  38. package/ios/RNGestureHandlerRegistry.m +24 -22
  39. package/ios/RNGestureHandlerRootViewComponentView.mm +2 -2
  40. package/ios/RNGestureHandlerState.h +6 -6
  41. package/ios/RNGestureHandlerStateManager.h +1 -1
  42. package/ios/RNManualActivationRecognizer.m +9 -9
  43. package/ios/RNRootViewGestureRecognizer.m +39 -42
  44. package/lib/commonjs/EnableNewWebImplementation.js +35 -0
  45. package/lib/commonjs/EnableNewWebImplementation.js.map +1 -0
  46. package/lib/commonjs/GestureHandlerRootViewContext.js +15 -0
  47. package/lib/commonjs/GestureHandlerRootViewContext.js.map +1 -0
  48. package/lib/commonjs/RNGestureHandlerModule.macos.js +6 -6
  49. package/lib/commonjs/RNGestureHandlerModule.macos.js.map +1 -1
  50. package/lib/commonjs/RNGestureHandlerModule.web.js +6 -6
  51. package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
  52. package/lib/commonjs/RNGestureHandlerModule.windows.js +6 -6
  53. package/lib/commonjs/RNGestureHandlerModule.windows.js.map +1 -1
  54. package/lib/commonjs/components/DrawerLayout.js.map +1 -1
  55. package/lib/commonjs/components/GestureComponents.web.js +6 -5
  56. package/lib/commonjs/components/GestureComponents.web.js.map +1 -1
  57. package/lib/commonjs/components/GestureHandlerButton.js +3 -5
  58. package/lib/commonjs/components/GestureHandlerButton.js.map +1 -1
  59. package/lib/commonjs/{GestureHandlerRootView.android.js → components/GestureHandlerRootView.android.js} +8 -7
  60. package/lib/commonjs/components/GestureHandlerRootView.android.js.map +1 -0
  61. package/lib/commonjs/{GestureHandlerRootView.js → components/GestureHandlerRootView.js} +8 -2
  62. package/lib/commonjs/components/GestureHandlerRootView.js.map +1 -0
  63. package/lib/commonjs/{GestureHandlerRootView.web.js → components/GestureHandlerRootView.web.js} +7 -1
  64. package/lib/commonjs/components/GestureHandlerRootView.web.js.map +1 -0
  65. package/lib/commonjs/components/Swipeable.js +17 -3
  66. package/lib/commonjs/components/Swipeable.js.map +1 -1
  67. package/lib/commonjs/{gestureHandlerRootHOC.js → components/gestureHandlerRootHOC.js} +2 -1
  68. package/lib/commonjs/components/gestureHandlerRootHOC.js.map +1 -0
  69. package/lib/commonjs/handlers/LongPressGestureHandler.js +3 -1
  70. package/lib/commonjs/handlers/LongPressGestureHandler.js.map +1 -1
  71. package/lib/commonjs/handlers/TapGestureHandler.js +3 -1
  72. package/lib/commonjs/handlers/TapGestureHandler.js.map +1 -1
  73. package/lib/commonjs/handlers/createHandler.js +21 -13
  74. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  75. package/lib/commonjs/handlers/gestureHandlerCommon.js +5 -4
  76. package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
  77. package/lib/commonjs/handlers/gestures/GestureDetector.js +89 -37
  78. package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
  79. package/lib/commonjs/handlers/gestures/longPressGesture.js +1 -0
  80. package/lib/commonjs/handlers/gestures/longPressGesture.js.map +1 -1
  81. package/lib/commonjs/handlers/gestures/reanimatedWrapper.js +22 -19
  82. package/lib/commonjs/handlers/gestures/reanimatedWrapper.js.map +1 -1
  83. package/lib/commonjs/handlers/gestures/tapGesture.js +1 -0
  84. package/lib/commonjs/handlers/gestures/tapGesture.js.map +1 -1
  85. package/lib/commonjs/index.js +16 -4
  86. package/lib/commonjs/index.js.map +1 -1
  87. package/lib/commonjs/utils.js +0 -6
  88. package/lib/commonjs/utils.js.map +1 -1
  89. package/lib/commonjs/web/handlers/FlingGestureHandler.js +0 -5
  90. package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
  91. package/lib/commonjs/web/handlers/GestureHandler.js +3 -0
  92. package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
  93. package/lib/commonjs/web/handlers/LongPressGestureHandler.js +0 -1
  94. package/lib/commonjs/web/handlers/LongPressGestureHandler.js.map +1 -1
  95. package/lib/commonjs/web/handlers/ManualGestureHandler.js +0 -5
  96. package/lib/commonjs/web/handlers/ManualGestureHandler.js.map +1 -1
  97. package/lib/commonjs/web/handlers/NativeViewGestureHandler.js +0 -6
  98. package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -1
  99. package/lib/commonjs/web/handlers/PanGestureHandler.js +2 -12
  100. package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
  101. package/lib/commonjs/web/handlers/PinchGestureHandler.js +0 -5
  102. package/lib/commonjs/web/handlers/PinchGestureHandler.js.map +1 -1
  103. package/lib/commonjs/web/handlers/RotationGestureHandler.js +0 -6
  104. package/lib/commonjs/web/handlers/RotationGestureHandler.js.map +1 -1
  105. package/lib/commonjs/web/handlers/TapGestureHandler.js +0 -7
  106. package/lib/commonjs/web/handlers/TapGestureHandler.js.map +1 -1
  107. package/lib/commonjs/web/tools/CircularBuffer.js +59 -0
  108. package/lib/commonjs/web/tools/CircularBuffer.js.map +1 -0
  109. package/lib/commonjs/web/tools/LeastSquareSolver.js +204 -0
  110. package/lib/commonjs/web/tools/LeastSquareSolver.js.map +1 -0
  111. package/lib/commonjs/web/tools/PointerEventManager.js +27 -0
  112. package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
  113. package/lib/commonjs/web/tools/PointerTracker.js +11 -7
  114. package/lib/commonjs/web/tools/PointerTracker.js.map +1 -1
  115. package/lib/commonjs/web/tools/VelocityTracker.js +111 -0
  116. package/lib/commonjs/web/tools/VelocityTracker.js.map +1 -0
  117. package/lib/commonjs/web_hammer/GestureHandler.js +1 -1
  118. package/lib/commonjs/web_hammer/GestureHandler.js.map +1 -1
  119. package/lib/module/EnableNewWebImplementation.js +22 -0
  120. package/lib/module/EnableNewWebImplementation.js.map +1 -0
  121. package/lib/module/GestureHandlerRootViewContext.js +3 -0
  122. package/lib/module/GestureHandlerRootViewContext.js.map +1 -0
  123. package/lib/module/RNGestureHandlerModule.macos.js +6 -6
  124. package/lib/module/RNGestureHandlerModule.macos.js.map +1 -1
  125. package/lib/module/RNGestureHandlerModule.web.js +6 -6
  126. package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
  127. package/lib/module/RNGestureHandlerModule.windows.js +6 -6
  128. package/lib/module/RNGestureHandlerModule.windows.js.map +1 -1
  129. package/lib/module/components/DrawerLayout.js.map +1 -1
  130. package/lib/module/components/GestureComponents.web.js +5 -6
  131. package/lib/module/components/GestureComponents.web.js.map +1 -1
  132. package/lib/module/components/GestureHandlerButton.js +1 -4
  133. package/lib/module/components/GestureHandlerButton.js.map +1 -1
  134. package/lib/module/components/GestureHandlerRootView.android.js +14 -0
  135. package/lib/module/components/GestureHandlerRootView.android.js.map +1 -0
  136. package/lib/module/{GestureHandlerRootView.js → components/GestureHandlerRootView.js} +5 -2
  137. package/lib/module/components/GestureHandlerRootView.js.map +1 -0
  138. package/lib/module/components/GestureHandlerRootView.web.js +9 -0
  139. package/lib/module/components/GestureHandlerRootView.web.js.map +1 -0
  140. package/lib/module/components/Swipeable.js +17 -3
  141. package/lib/module/components/Swipeable.js.map +1 -1
  142. package/lib/module/{gestureHandlerRootHOC.js → components/gestureHandlerRootHOC.js} +2 -1
  143. package/lib/module/components/gestureHandlerRootHOC.js.map +1 -0
  144. package/lib/module/handlers/LongPressGestureHandler.js +3 -1
  145. package/lib/module/handlers/LongPressGestureHandler.js.map +1 -1
  146. package/lib/module/handlers/TapGestureHandler.js +3 -1
  147. package/lib/module/handlers/TapGestureHandler.js.map +1 -1
  148. package/lib/module/handlers/createHandler.js +20 -13
  149. package/lib/module/handlers/createHandler.js.map +1 -1
  150. package/lib/module/handlers/gestureHandlerCommon.js +5 -4
  151. package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
  152. package/lib/module/handlers/gestures/GestureDetector.js +89 -38
  153. package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
  154. package/lib/module/handlers/gestures/longPressGesture.js +1 -0
  155. package/lib/module/handlers/gestures/longPressGesture.js.map +1 -1
  156. package/lib/module/handlers/gestures/reanimatedWrapper.js +19 -16
  157. package/lib/module/handlers/gestures/reanimatedWrapper.js.map +1 -1
  158. package/lib/module/handlers/gestures/tapGesture.js +1 -0
  159. package/lib/module/handlers/gestures/tapGesture.js.map +1 -1
  160. package/lib/module/index.js +4 -4
  161. package/lib/module/index.js.map +1 -1
  162. package/lib/module/utils.js +0 -4
  163. package/lib/module/utils.js.map +1 -1
  164. package/lib/module/web/handlers/FlingGestureHandler.js +0 -5
  165. package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
  166. package/lib/module/web/handlers/GestureHandler.js +3 -0
  167. package/lib/module/web/handlers/GestureHandler.js.map +1 -1
  168. package/lib/module/web/handlers/LongPressGestureHandler.js +0 -1
  169. package/lib/module/web/handlers/LongPressGestureHandler.js.map +1 -1
  170. package/lib/module/web/handlers/ManualGestureHandler.js +0 -5
  171. package/lib/module/web/handlers/ManualGestureHandler.js.map +1 -1
  172. package/lib/module/web/handlers/NativeViewGestureHandler.js +0 -6
  173. package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
  174. package/lib/module/web/handlers/PanGestureHandler.js +2 -9
  175. package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
  176. package/lib/module/web/handlers/PinchGestureHandler.js +0 -5
  177. package/lib/module/web/handlers/PinchGestureHandler.js.map +1 -1
  178. package/lib/module/web/handlers/RotationGestureHandler.js +0 -6
  179. package/lib/module/web/handlers/RotationGestureHandler.js.map +1 -1
  180. package/lib/module/web/handlers/TapGestureHandler.js +0 -7
  181. package/lib/module/web/handlers/TapGestureHandler.js.map +1 -1
  182. package/lib/module/web/tools/CircularBuffer.js +50 -0
  183. package/lib/module/web/tools/CircularBuffer.js.map +1 -0
  184. package/lib/module/web/tools/LeastSquareSolver.js +195 -0
  185. package/lib/module/web/tools/LeastSquareSolver.js.map +1 -0
  186. package/lib/module/web/tools/PointerEventManager.js +27 -0
  187. package/lib/module/web/tools/PointerEventManager.js.map +1 -1
  188. package/lib/module/web/tools/PointerTracker.js +8 -7
  189. package/lib/module/web/tools/PointerTracker.js.map +1 -1
  190. package/lib/module/web/tools/VelocityTracker.js +98 -0
  191. package/lib/module/web/tools/VelocityTracker.js.map +1 -0
  192. package/lib/module/web_hammer/GestureHandler.js +1 -1
  193. package/lib/module/web_hammer/GestureHandler.js.map +1 -1
  194. package/lib/typescript/EnableNewWebImplementation.d.ts +3 -0
  195. package/lib/typescript/GestureHandlerRootViewContext.d.ts +3 -0
  196. package/lib/typescript/components/DrawerLayout.d.ts +3 -1
  197. package/lib/typescript/components/GestureComponents.web.d.ts +1 -1
  198. package/lib/typescript/components/Swipeable.d.ts +14 -2
  199. package/lib/typescript/components/gestureHandlerRootHOC.d.ts +3 -0
  200. package/lib/typescript/index.d.ts +4 -4
  201. package/lib/typescript/{fabric → specs}/RNGestureHandlerButtonNativeComponent.d.ts +1 -1
  202. package/lib/typescript/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.d.ts +1 -1
  203. package/lib/typescript/utils.d.ts +0 -1
  204. package/lib/typescript/web/handlers/FlingGestureHandler.d.ts +0 -1
  205. package/lib/typescript/web/handlers/ManualGestureHandler.d.ts +0 -1
  206. package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +0 -1
  207. package/lib/typescript/web/handlers/PanGestureHandler.d.ts +0 -1
  208. package/lib/typescript/web/handlers/PinchGestureHandler.d.ts +0 -1
  209. package/lib/typescript/web/handlers/RotationGestureHandler.d.ts +0 -1
  210. package/lib/typescript/web/handlers/TapGestureHandler.d.ts +0 -1
  211. package/lib/typescript/web/tools/CircularBuffer.d.ts +11 -0
  212. package/lib/typescript/web/tools/LeastSquareSolver.d.ts +12 -0
  213. package/lib/typescript/web/tools/PointerEventManager.d.ts +2 -0
  214. package/lib/typescript/web/tools/PointerTracker.d.ts +1 -0
  215. package/lib/typescript/web/tools/VelocityTracker.d.ts +13 -0
  216. package/package.json +6 -7
  217. package/src/EnableNewWebImplementation.ts +35 -0
  218. package/src/GestureHandlerRootViewContext.ts +3 -0
  219. package/src/RNGestureHandlerModule.macos.ts +6 -6
  220. package/src/RNGestureHandlerModule.web.ts +6 -6
  221. package/src/RNGestureHandlerModule.windows.ts +6 -6
  222. package/src/components/DrawerLayout.tsx +8 -4
  223. package/src/components/GestureComponents.web.tsx +5 -6
  224. package/src/components/GestureHandlerButton.tsx +2 -7
  225. package/src/components/GestureHandlerRootView.android.tsx +24 -0
  226. package/src/{GestureHandlerRootView.tsx → components/GestureHandlerRootView.tsx} +7 -2
  227. package/src/{GestureHandlerRootView.web.tsx → components/GestureHandlerRootView.web.tsx} +6 -1
  228. package/src/components/Swipeable.tsx +43 -12
  229. package/src/{gestureHandlerRootHOC.tsx → components/gestureHandlerRootHOC.tsx} +4 -1
  230. package/src/handlers/LongPressGestureHandler.ts +3 -1
  231. package/src/handlers/TapGestureHandler.ts +3 -1
  232. package/src/handlers/createHandler.tsx +20 -9
  233. package/src/handlers/gestureHandlerCommon.ts +5 -6
  234. package/src/handlers/gestures/GestureDetector.tsx +99 -36
  235. package/src/handlers/gestures/longPressGesture.ts +1 -0
  236. package/src/handlers/gestures/reanimatedWrapper.ts +21 -20
  237. package/src/handlers/gestures/tapGesture.ts +1 -0
  238. package/src/index.ts +7 -3
  239. package/src/utils.ts +0 -5
  240. package/src/web/handlers/FlingGestureHandler.ts +0 -5
  241. package/src/web/handlers/GestureHandler.ts +3 -0
  242. package/src/web/handlers/LongPressGestureHandler.ts +0 -1
  243. package/src/web/handlers/ManualGestureHandler.ts +0 -5
  244. package/src/web/handlers/NativeViewGestureHandler.ts +0 -6
  245. package/src/web/handlers/PanGestureHandler.ts +2 -9
  246. package/src/web/handlers/PinchGestureHandler.ts +0 -5
  247. package/src/web/handlers/RotationGestureHandler.ts +0 -7
  248. package/src/web/handlers/TapGestureHandler.ts +0 -7
  249. package/src/web/tools/CircularBuffer.ts +42 -0
  250. package/src/web/tools/LeastSquareSolver.ts +182 -0
  251. package/src/web/tools/PointerEventManager.ts +29 -0
  252. package/src/web/tools/PointerTracker.ts +7 -7
  253. package/src/web/tools/VelocityTracker.ts +98 -0
  254. package/src/web_hammer/GestureHandler.ts +1 -1
  255. package/lib/commonjs/EnableExperimentalWebImplementation.js +0 -31
  256. package/lib/commonjs/EnableExperimentalWebImplementation.js.map +0 -1
  257. package/lib/commonjs/GestureHandlerRootView.android.js.map +0 -1
  258. package/lib/commonjs/GestureHandlerRootView.js.map +0 -1
  259. package/lib/commonjs/GestureHandlerRootView.web.js.map +0 -1
  260. package/lib/commonjs/gestureHandlerRootHOC.js.map +0 -1
  261. package/lib/module/EnableExperimentalWebImplementation.js +0 -20
  262. package/lib/module/EnableExperimentalWebImplementation.js.map +0 -1
  263. package/lib/module/GestureHandlerRootView.android.js +0 -14
  264. package/lib/module/GestureHandlerRootView.android.js.map +0 -1
  265. package/lib/module/GestureHandlerRootView.js.map +0 -1
  266. package/lib/module/GestureHandlerRootView.web.js +0 -6
  267. package/lib/module/GestureHandlerRootView.web.js.map +0 -1
  268. package/lib/module/gestureHandlerRootHOC.js.map +0 -1
  269. package/lib/typescript/EnableExperimentalWebImplementation.d.ts +0 -2
  270. package/lib/typescript/gestureHandlerRootHOC.d.ts +0 -3
  271. package/src/EnableExperimentalWebImplementation.ts +0 -27
  272. package/src/GestureHandlerRootView.android.tsx +0 -24
  273. /package/lib/commonjs/{fabric → specs}/RNGestureHandlerButtonNativeComponent.js +0 -0
  274. /package/lib/commonjs/{fabric → specs}/RNGestureHandlerButtonNativeComponent.js.map +0 -0
  275. /package/lib/commonjs/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.js +0 -0
  276. /package/lib/commonjs/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.js.map +0 -0
  277. /package/lib/module/{fabric → specs}/RNGestureHandlerButtonNativeComponent.js +0 -0
  278. /package/lib/module/{fabric → specs}/RNGestureHandlerButtonNativeComponent.js.map +0 -0
  279. /package/lib/module/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.js +0 -0
  280. /package/lib/module/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.js.map +0 -0
  281. /package/lib/typescript/{GestureHandlerRootView.android.d.ts → components/GestureHandlerRootView.android.d.ts} +0 -0
  282. /package/lib/typescript/{GestureHandlerRootView.d.ts → components/GestureHandlerRootView.d.ts} +0 -0
  283. /package/lib/typescript/{GestureHandlerRootView.web.d.ts → components/GestureHandlerRootView.web.d.ts} +0 -0
  284. /package/src/{fabric → specs}/RNGestureHandlerButtonNativeComponent.ts +0 -0
  285. /package/src/{fabric → specs}/RNGestureHandlerRootViewNativeComponent.ts +0 -0
@@ -11,84 +11,84 @@
11
11
  @property (nonatomic, readonly) RNGestureHandler *gestureHandler;
12
12
  @end
13
13
 
14
-
15
14
  @implementation UIGestureRecognizer (GestureHandler)
16
15
 
17
16
  - (RNGestureHandler *)gestureHandler
18
17
  {
19
- id delegate = self.delegate;
20
- if ([delegate isKindOfClass:[RNGestureHandler class]]) {
21
- return (RNGestureHandler *)delegate;
22
- }
23
- return nil;
18
+ id delegate = self.delegate;
19
+ if ([delegate isKindOfClass:[RNGestureHandler class]]) {
20
+ return (RNGestureHandler *)delegate;
21
+ }
22
+ return nil;
24
23
  }
25
24
 
26
25
  @end
27
26
 
28
27
  typedef struct RNGHHitSlop {
29
- CGFloat top, left, bottom, right, width, height;
28
+ CGFloat top, left, bottom, right, width, height;
30
29
  } RNGHHitSlop;
31
30
 
32
- static RNGHHitSlop RNGHHitSlopEmpty = { NAN, NAN, NAN, NAN, NAN, NAN };
31
+ static RNGHHitSlop RNGHHitSlopEmpty = {NAN, NAN, NAN, NAN, NAN, NAN};
33
32
 
34
33
  #define RNGH_HIT_SLOP_GET(key) (prop[key] == nil ? NAN : [prop[key] doubleValue])
35
- #define RNGH_HIT_SLOP_IS_SET(hitSlop) (!isnan(hitSlop.left) || !isnan(hitSlop.right) || \
36
- !isnan(hitSlop.top) || !isnan(hitSlop.bottom))
34
+ #define RNGH_HIT_SLOP_IS_SET(hitSlop) \
35
+ (!isnan(hitSlop.left) || !isnan(hitSlop.right) || !isnan(hitSlop.top) || !isnan(hitSlop.bottom))
37
36
  #define RNGH_HIT_SLOP_INSET(key) (isnan(hitSlop.key) ? 0. : hitSlop.key)
38
37
 
39
- CGRect RNGHHitSlopInsetRect(CGRect rect, RNGHHitSlop hitSlop) {
40
- rect.origin.x -= RNGH_HIT_SLOP_INSET(left);
41
- rect.origin.y -= RNGH_HIT_SLOP_INSET(top);
38
+ CGRect RNGHHitSlopInsetRect(CGRect rect, RNGHHitSlop hitSlop)
39
+ {
40
+ rect.origin.x -= RNGH_HIT_SLOP_INSET(left);
41
+ rect.origin.y -= RNGH_HIT_SLOP_INSET(top);
42
42
 
43
- if (!isnan(hitSlop.width)) {
44
- if (!isnan(hitSlop.right)) {
45
- rect.origin.x = rect.size.width - hitSlop.width + RNGH_HIT_SLOP_INSET(right);
46
- }
47
- rect.size.width = hitSlop.width;
48
- } else {
49
- rect.size.width += (RNGH_HIT_SLOP_INSET(left) + RNGH_HIT_SLOP_INSET(right));
43
+ if (!isnan(hitSlop.width)) {
44
+ if (!isnan(hitSlop.right)) {
45
+ rect.origin.x = rect.size.width - hitSlop.width + RNGH_HIT_SLOP_INSET(right);
50
46
  }
51
- if (!isnan(hitSlop.height)) {
52
- if (!isnan(hitSlop.bottom)) {
53
- rect.origin.y = rect.size.height - hitSlop.height + RNGH_HIT_SLOP_INSET(bottom);
54
- }
55
- rect.size.height = hitSlop.height;
56
- } else {
57
- rect.size.height += (RNGH_HIT_SLOP_INSET(top) + RNGH_HIT_SLOP_INSET(bottom));
47
+ rect.size.width = hitSlop.width;
48
+ } else {
49
+ rect.size.width += (RNGH_HIT_SLOP_INSET(left) + RNGH_HIT_SLOP_INSET(right));
50
+ }
51
+ if (!isnan(hitSlop.height)) {
52
+ if (!isnan(hitSlop.bottom)) {
53
+ rect.origin.y = rect.size.height - hitSlop.height + RNGH_HIT_SLOP_INSET(bottom);
58
54
  }
59
- return rect;
55
+ rect.size.height = hitSlop.height;
56
+ } else {
57
+ rect.size.height += (RNGH_HIT_SLOP_INSET(top) + RNGH_HIT_SLOP_INSET(bottom));
58
+ }
59
+ return rect;
60
60
  }
61
61
 
62
62
  static NSHashTable<RNGestureHandler *> *allGestureHandlers;
63
63
 
64
64
  @implementation RNGestureHandler {
65
- RNGestureHandlerPointerTracker *_pointerTracker;
66
- RNGestureHandlerState _state;
67
- RNManualActivationRecognizer *_manualActivationRecognizer;
68
- NSArray<NSNumber *> *_handlersToWaitFor;
69
- NSArray<NSNumber *> *_simultaneousHandlers;
70
- RNGHHitSlop _hitSlop;
71
- uint16_t _eventCoalescingKey;
65
+ RNGestureHandlerPointerTracker *_pointerTracker;
66
+ RNGestureHandlerState _state;
67
+ RNManualActivationRecognizer *_manualActivationRecognizer;
68
+ NSArray<NSNumber *> *_handlersToWaitFor;
69
+ NSArray<NSNumber *> *_simultaneousHandlers;
70
+ RNGHHitSlop _hitSlop;
71
+ uint16_t _eventCoalescingKey;
72
72
  }
73
73
 
74
74
  - (instancetype)initWithTag:(NSNumber *)tag
75
75
  {
76
- if ((self = [super init])) {
77
- _pointerTracker = [[RNGestureHandlerPointerTracker alloc] initWithGestureHandler:self];
78
- _tag = tag;
79
- _lastState = RNGestureHandlerStateUndetermined;
80
- _hitSlop = RNGHHitSlopEmpty;
81
- _state = RNGestureHandlerStateBegan;
82
- _manualActivationRecognizer = nil;
83
-
84
- static dispatch_once_t onceToken;
85
- dispatch_once(&onceToken, ^{
86
- allGestureHandlers = [NSHashTable weakObjectsHashTable];
87
- });
88
-
89
- [allGestureHandlers addObject:self];
90
- }
91
- return self;
76
+ if ((self = [super init])) {
77
+ _pointerTracker = [[RNGestureHandlerPointerTracker alloc] initWithGestureHandler:self];
78
+ _tag = tag;
79
+ _lastState = RNGestureHandlerStateUndetermined;
80
+ _hitSlop = RNGHHitSlopEmpty;
81
+ _state = RNGestureHandlerStateBegan;
82
+ _manualActivationRecognizer = nil;
83
+
84
+ static dispatch_once_t onceToken;
85
+ dispatch_once(&onceToken, ^{
86
+ allGestureHandlers = [NSHashTable weakObjectsHashTable];
87
+ });
88
+
89
+ [allGestureHandlers addObject:self];
90
+ }
91
+ return self;
92
92
  }
93
93
 
94
94
  - (void)resetConfig
@@ -107,197 +107,201 @@ static NSHashTable<RNGestureHandler *> *allGestureHandlers;
107
107
  - (void)configure:(NSDictionary *)config
108
108
  {
109
109
  [self resetConfig];
110
- _handlersToWaitFor = [RCTConvert NSNumberArray:config[@"waitFor"]];
111
- _simultaneousHandlers = [RCTConvert NSNumberArray:config[@"simultaneousHandlers"]];
110
+ _handlersToWaitFor = [RCTConvert NSNumberArray:config[@"waitFor"]];
111
+ _simultaneousHandlers = [RCTConvert NSNumberArray:config[@"simultaneousHandlers"]];
112
112
 
113
- id prop = config[@"enabled"];
114
- if (prop != nil) {
115
- self.enabled = [RCTConvert BOOL:prop];
116
- }
113
+ id prop = config[@"enabled"];
114
+ if (prop != nil) {
115
+ self.enabled = [RCTConvert BOOL:prop];
116
+ }
117
117
 
118
- prop = config[@"shouldCancelWhenOutside"];
119
- if (prop != nil) {
120
- _shouldCancelWhenOutside = [RCTConvert BOOL:prop];
121
- }
122
-
123
- prop = config[@"cancelsTouchesInView"];
124
- if (prop != nil) {
125
- _recognizer.cancelsTouchesInView = [RCTConvert BOOL:prop];
118
+ prop = config[@"shouldCancelWhenOutside"];
119
+ if (prop != nil) {
120
+ _shouldCancelWhenOutside = [RCTConvert BOOL:prop];
121
+ }
122
+
123
+ prop = config[@"cancelsTouchesInView"];
124
+ if (prop != nil) {
125
+ _recognizer.cancelsTouchesInView = [RCTConvert BOOL:prop];
126
+ }
127
+
128
+ prop = config[@"needsPointerData"];
129
+ if (prop != nil) {
130
+ _needsPointerData = [RCTConvert BOOL:prop];
131
+ }
132
+
133
+ prop = config[@"manualActivation"];
134
+ if (prop != nil) {
135
+ self.manualActivation = [RCTConvert BOOL:prop];
136
+ }
137
+
138
+ prop = config[@"hitSlop"];
139
+ if ([prop isKindOfClass:[NSNumber class]]) {
140
+ _hitSlop.left = _hitSlop.right = _hitSlop.top = _hitSlop.bottom = [prop doubleValue];
141
+ } else if (prop != nil) {
142
+ _hitSlop.left = _hitSlop.right = RNGH_HIT_SLOP_GET(@"horizontal");
143
+ _hitSlop.top = _hitSlop.bottom = RNGH_HIT_SLOP_GET(@"vertical");
144
+ _hitSlop.left = RNGH_HIT_SLOP_GET(@"left");
145
+ _hitSlop.right = RNGH_HIT_SLOP_GET(@"right");
146
+ _hitSlop.top = RNGH_HIT_SLOP_GET(@"top");
147
+ _hitSlop.bottom = RNGH_HIT_SLOP_GET(@"bottom");
148
+ _hitSlop.width = RNGH_HIT_SLOP_GET(@"width");
149
+ _hitSlop.height = RNGH_HIT_SLOP_GET(@"height");
150
+ if (isnan(_hitSlop.left) && isnan(_hitSlop.right) && !isnan(_hitSlop.width)) {
151
+ RCTLogError(@"When width is set one of left or right pads need to be defined");
126
152
  }
127
-
128
- prop = config[@"needsPointerData"];
129
- if (prop != nil) {
130
- _needsPointerData = [RCTConvert BOOL:prop];
153
+ if (!isnan(_hitSlop.width) && !isnan(_hitSlop.left) && !isnan(_hitSlop.right)) {
154
+ RCTLogError(@"Cannot have all of left, right and width defined");
131
155
  }
132
-
133
- prop = config[@"manualActivation"];
134
- if (prop != nil) {
135
- self.manualActivation = [RCTConvert BOOL:prop];
156
+ if (isnan(_hitSlop.top) && isnan(_hitSlop.bottom) && !isnan(_hitSlop.height)) {
157
+ RCTLogError(@"When height is set one of top or bottom pads need to be defined");
136
158
  }
137
-
138
- prop = config[@"hitSlop"];
139
- if ([prop isKindOfClass:[NSNumber class]]) {
140
- _hitSlop.left = _hitSlop.right = _hitSlop.top = _hitSlop.bottom = [prop doubleValue];
141
- } else if (prop != nil) {
142
- _hitSlop.left = _hitSlop.right = RNGH_HIT_SLOP_GET(@"horizontal");
143
- _hitSlop.top = _hitSlop.bottom = RNGH_HIT_SLOP_GET(@"vertical");
144
- _hitSlop.left = RNGH_HIT_SLOP_GET(@"left");
145
- _hitSlop.right = RNGH_HIT_SLOP_GET(@"right");
146
- _hitSlop.top = RNGH_HIT_SLOP_GET(@"top");
147
- _hitSlop.bottom = RNGH_HIT_SLOP_GET(@"bottom");
148
- _hitSlop.width = RNGH_HIT_SLOP_GET(@"width");
149
- _hitSlop.height = RNGH_HIT_SLOP_GET(@"height");
150
- if (isnan(_hitSlop.left) && isnan(_hitSlop.right) && !isnan(_hitSlop.width)) {
151
- RCTLogError(@"When width is set one of left or right pads need to be defined");
152
- }
153
- if (!isnan(_hitSlop.width) && !isnan(_hitSlop.left) && !isnan(_hitSlop.right)) {
154
- RCTLogError(@"Cannot have all of left, right and width defined");
155
- }
156
- if (isnan(_hitSlop.top) && isnan(_hitSlop.bottom) && !isnan(_hitSlop.height)) {
157
- RCTLogError(@"When height is set one of top or bottom pads need to be defined");
158
- }
159
- if (!isnan(_hitSlop.height) && !isnan(_hitSlop.top) && !isnan(_hitSlop.bottom)) {
160
- RCTLogError(@"Cannot have all of top, bottom and height defined");
161
- }
159
+ if (!isnan(_hitSlop.height) && !isnan(_hitSlop.top) && !isnan(_hitSlop.bottom)) {
160
+ RCTLogError(@"Cannot have all of top, bottom and height defined");
162
161
  }
162
+ }
163
163
  }
164
164
 
165
165
  - (void)setEnabled:(BOOL)enabled
166
166
  {
167
- _enabled = enabled;
168
- self.recognizer.enabled = enabled;
167
+ _enabled = enabled;
168
+ self.recognizer.enabled = enabled;
169
169
  }
170
170
 
171
171
  - (void)bindToView:(UIView *)view
172
172
  {
173
- view.userInteractionEnabled = YES;
174
- self.recognizer.delegate = self;
175
- [view addGestureRecognizer:self.recognizer];
176
-
173
+ view.userInteractionEnabled = YES;
174
+ self.recognizer.delegate = self;
175
+ [view addGestureRecognizer:self.recognizer];
176
+
177
177
  [self bindManualActivationToView:view];
178
178
  }
179
179
 
180
180
  - (void)unbindFromView
181
181
  {
182
- [self.recognizer.view removeGestureRecognizer:self.recognizer];
183
- self.recognizer.delegate = nil;
184
-
185
- [self unbindManualActivation];
182
+ [self.recognizer.view removeGestureRecognizer:self.recognizer];
183
+ self.recognizer.delegate = nil;
184
+
185
+ [self unbindManualActivation];
186
186
  }
187
187
 
188
188
  - (RNGestureHandlerEventExtraData *)eventExtraData:(UIGestureRecognizer *)recognizer
189
189
  {
190
- return [RNGestureHandlerEventExtraData
191
- forPosition:[recognizer locationInView:recognizer.view]
192
- withAbsolutePosition:[recognizer locationInView:recognizer.view.window]
193
- withNumberOfTouches:recognizer.numberOfTouches];
190
+ return [RNGestureHandlerEventExtraData forPosition:[recognizer locationInView:recognizer.view]
191
+ withAbsolutePosition:[recognizer locationInView:recognizer.view.window]
192
+ withNumberOfTouches:recognizer.numberOfTouches];
194
193
  }
195
194
 
196
195
  - (void)handleGesture:(UIGestureRecognizer *)recognizer
197
196
  {
198
- // it may happen that the gesture recognizer is reset after it's been unbound from the view,
199
- // it that recognizer tried to send event, the app would crash because the target of the event
200
- // would be nil.
201
- if (recognizer.view.reactTag == nil) {
202
- return;
203
- }
204
-
205
- _state = [self recognizerState];
206
- [self handleGesture:recognizer inState:_state];
197
+ // it may happen that the gesture recognizer is reset after it's been unbound from the view,
198
+ // it that recognizer tried to send event, the app would crash because the target of the event
199
+ // would be nil.
200
+ if (recognizer.view.reactTag == nil) {
201
+ return;
202
+ }
203
+
204
+ _state = [self recognizerState];
205
+ [self handleGesture:recognizer inState:_state];
207
206
  }
208
207
 
209
208
  - (void)handleGesture:(UIGestureRecognizer *)recognizer inState:(RNGestureHandlerState)state
210
209
  {
211
- _state = state;
212
- RNGestureHandlerEventExtraData *eventData = [self eventExtraData:recognizer];
213
- [self sendEventsInState:self.state forViewWithTag:recognizer.view.reactTag withExtraData:eventData];
210
+ _state = state;
211
+ RNGestureHandlerEventExtraData *eventData = [self eventExtraData:recognizer];
212
+ [self sendEventsInState:self.state forViewWithTag:recognizer.view.reactTag withExtraData:eventData];
214
213
  }
215
214
 
216
215
  - (void)sendEventsInState:(RNGestureHandlerState)state
217
216
  forViewWithTag:(nonnull NSNumber *)reactTag
218
217
  withExtraData:(RNGestureHandlerEventExtraData *)extraData
219
218
  {
220
- if (state != _lastState) {
221
- // don't send change events from END to FAILED or CANCELLED, this may happen when gesture is ended in `onTouchesUp` callback
222
- if (_lastState == RNGestureHandlerStateEnd && (state == RNGestureHandlerStateFailed || state == RNGestureHandlerStateCancelled)) {
223
- return;
224
- }
225
-
226
- if (state == RNGestureHandlerStateActive) {
227
- // Generate a unique coalescing-key each time the gesture-handler becomes active. All events will have
228
- // the same coalescing-key allowing RCTEventDispatcher to coalesce RNGestureHandlerEvents when events are
229
- // generated faster than they can be treated by JS thread
230
- static uint16_t nextEventCoalescingKey = 0;
231
- self->_eventCoalescingKey = nextEventCoalescingKey++;
232
-
233
- } else if (state == RNGestureHandlerStateEnd && _lastState != RNGestureHandlerStateActive && !_manualActivation) {
234
- id event = [[RNGestureHandlerStateChange alloc] initWithReactTag:reactTag
235
- handlerTag:_tag
236
- state:RNGestureHandlerStateActive
237
- prevState:_lastState
238
- extraData:extraData];
239
- [self sendEvent:event];
240
- _lastState = RNGestureHandlerStateActive;
241
- }
242
- id stateEvent = [[RNGestureHandlerStateChange alloc] initWithReactTag:reactTag
243
- handlerTag:_tag
244
- state:state
245
- prevState:_lastState
246
- extraData:extraData];
247
- [self sendEvent:stateEvent];
248
- _lastState = state;
219
+ if (state != _lastState) {
220
+ // don't send change events from END to FAILED or CANCELLED, this may happen when gesture is ended in `onTouchesUp`
221
+ // callback
222
+ if (_lastState == RNGestureHandlerStateEnd &&
223
+ (state == RNGestureHandlerStateFailed || state == RNGestureHandlerStateCancelled)) {
224
+ return;
249
225
  }
250
226
 
251
227
  if (state == RNGestureHandlerStateActive) {
252
- id touchEvent = [[RNGestureHandlerEvent alloc] initWithReactTag:reactTag
253
- handlerTag:_tag
254
- state:state
255
- extraData:extraData
256
- coalescingKey:self->_eventCoalescingKey];
257
- [self sendEvent:touchEvent];
228
+ // Generate a unique coalescing-key each time the gesture-handler becomes active. All events will have
229
+ // the same coalescing-key allowing RCTEventDispatcher to coalesce RNGestureHandlerEvents when events are
230
+ // generated faster than they can be treated by JS thread
231
+ static uint16_t nextEventCoalescingKey = 0;
232
+ self->_eventCoalescingKey = nextEventCoalescingKey++;
233
+
234
+ } else if (state == RNGestureHandlerStateEnd && _lastState != RNGestureHandlerStateActive && !_manualActivation) {
235
+ id event = [[RNGestureHandlerStateChange alloc] initWithReactTag:reactTag
236
+ handlerTag:_tag
237
+ state:RNGestureHandlerStateActive
238
+ prevState:_lastState
239
+ extraData:extraData];
240
+ [self sendEvent:event];
241
+ _lastState = RNGestureHandlerStateActive;
258
242
  }
243
+ id stateEvent = [[RNGestureHandlerStateChange alloc] initWithReactTag:reactTag
244
+ handlerTag:_tag
245
+ state:state
246
+ prevState:_lastState
247
+ extraData:extraData];
248
+ [self sendEvent:stateEvent];
249
+ _lastState = state;
250
+ }
251
+
252
+ if (state == RNGestureHandlerStateActive) {
253
+ id touchEvent = [[RNGestureHandlerEvent alloc] initWithReactTag:reactTag
254
+ handlerTag:_tag
255
+ state:state
256
+ extraData:extraData
257
+ coalescingKey:self->_eventCoalescingKey];
258
+ [self sendEvent:touchEvent];
259
+ }
259
260
  }
260
261
 
261
262
  - (void)sendEvent:(RNGestureHandlerStateChange *)event
262
263
  {
263
- [self.emitter sendEvent:event withActionType:self.actionType];
264
+ [self.emitter sendEvent:event withActionType:self.actionType];
264
265
  }
265
266
 
266
- - (void)sendTouchEventInState:(RNGestureHandlerState)state
267
- forViewWithTag:(NSNumber *)reactTag
267
+ - (void)sendTouchEventInState:(RNGestureHandlerState)state forViewWithTag:(NSNumber *)reactTag
268
268
  {
269
269
  id extraData = [RNGestureHandlerEventExtraData forEventType:_pointerTracker.eventType
270
270
  withChangedPointers:_pointerTracker.changedPointersData
271
271
  withAllPointers:_pointerTracker.allPointersData
272
272
  withNumberOfTouches:_pointerTracker.trackedPointersCount];
273
- id event = [[RNGestureHandlerEvent alloc] initWithReactTag:reactTag handlerTag:_tag state:state extraData:extraData coalescingKey:[_tag intValue]];
274
-
273
+ id event = [[RNGestureHandlerEvent alloc] initWithReactTag:reactTag
274
+ handlerTag:_tag
275
+ state:state
276
+ extraData:extraData
277
+ coalescingKey:[_tag intValue]];
278
+
275
279
  [self.emitter sendEvent:event withActionType:self.actionType];
276
280
  }
277
281
 
278
282
  - (RNGestureHandlerState)recognizerState
279
283
  {
280
- switch (_recognizer.state) {
281
- case UIGestureRecognizerStateBegan:
282
- case UIGestureRecognizerStatePossible:
283
- return RNGestureHandlerStateBegan;
284
- case UIGestureRecognizerStateEnded:
285
- return RNGestureHandlerStateEnd;
286
- case UIGestureRecognizerStateFailed:
287
- return RNGestureHandlerStateFailed;
288
- case UIGestureRecognizerStateCancelled:
289
- return RNGestureHandlerStateCancelled;
290
- case UIGestureRecognizerStateChanged:
291
- return RNGestureHandlerStateActive;
292
- }
293
- return RNGestureHandlerStateUndetermined;
284
+ switch (_recognizer.state) {
285
+ case UIGestureRecognizerStateBegan:
286
+ case UIGestureRecognizerStatePossible:
287
+ return RNGestureHandlerStateBegan;
288
+ case UIGestureRecognizerStateEnded:
289
+ return RNGestureHandlerStateEnd;
290
+ case UIGestureRecognizerStateFailed:
291
+ return RNGestureHandlerStateFailed;
292
+ case UIGestureRecognizerStateCancelled:
293
+ return RNGestureHandlerStateCancelled;
294
+ case UIGestureRecognizerStateChanged:
295
+ return RNGestureHandlerStateActive;
296
+ }
297
+ return RNGestureHandlerStateUndetermined;
294
298
  }
295
299
 
296
300
  - (RNGestureHandlerState)state
297
301
  {
298
- // instead of mapping state of the recognizer directly, use value mapped when handleGesture was
299
- // called, making it correct while awaiting for another handler failure
300
- return _state;
302
+ // instead of mapping state of the recognizer directly, use value mapped when handleGesture was
303
+ // called, making it correct while awaiting for another handler failure
304
+ return _state;
301
305
  }
302
306
 
303
307
  #pragma mark Manual activation
@@ -312,7 +316,7 @@ static NSHashTable<RNGestureHandler *> *allGestureHandlers;
312
316
  - (void)setManualActivation:(BOOL)manualActivation
313
317
  {
314
318
  _manualActivation = manualActivation;
315
-
319
+
316
320
  if (manualActivation) {
317
321
  _manualActivationRecognizer = [[RNManualActivationRecognizer alloc] initWithGestureHandler:self];
318
322
 
@@ -343,135 +347,136 @@ static NSHashTable<RNGestureHandler *> *allGestureHandlers;
343
347
 
344
348
  + (RNGestureHandler *)findGestureHandlerByRecognizer:(UIGestureRecognizer *)recognizer
345
349
  {
346
- RNGestureHandler *handler = recognizer.gestureHandler;
347
- if (handler != nil) {
348
- return handler;
349
- }
350
+ RNGestureHandler *handler = recognizer.gestureHandler;
351
+ if (handler != nil) {
352
+ return handler;
353
+ }
350
354
 
351
- // We may try to extract "DummyGestureHandler" in case when "otherGestureRecognizer" belongs to
352
- // a native view being wrapped with "NativeViewGestureHandler"
353
- UIView *reactView = recognizer.view;
354
- while (reactView != nil && reactView.reactTag == nil) {
355
- reactView = reactView.superview;
356
- }
355
+ // We may try to extract "DummyGestureHandler" in case when "otherGestureRecognizer" belongs to
356
+ // a native view being wrapped with "NativeViewGestureHandler"
357
+ UIView *reactView = recognizer.view;
358
+ while (reactView != nil && reactView.reactTag == nil) {
359
+ reactView = reactView.superview;
360
+ }
357
361
 
358
- for (UIGestureRecognizer *recognizer in reactView.gestureRecognizers) {
359
- if ([recognizer isKindOfClass:[RNDummyGestureRecognizer class]]) {
360
- return recognizer.gestureHandler;
361
- }
362
+ for (UIGestureRecognizer *recognizer in reactView.gestureRecognizers) {
363
+ if ([recognizer isKindOfClass:[RNDummyGestureRecognizer class]]) {
364
+ return recognizer.gestureHandler;
362
365
  }
366
+ }
363
367
 
364
- return nil;
368
+ return nil;
365
369
  }
366
370
 
367
371
  - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
368
- shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
372
+ shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
369
373
  {
370
- RNGestureHandler *handler = [RNGestureHandler findGestureHandlerByRecognizer:otherGestureRecognizer];
371
- if ([handler isKindOfClass:[RNNativeViewGestureHandler class]]) {
372
- for (NSNumber *handlerTag in handler->_handlersToWaitFor) {
373
- if ([_tag isEqual:handlerTag]) {
374
- return YES;
375
- }
376
- }
374
+ RNGestureHandler *handler = [RNGestureHandler findGestureHandlerByRecognizer:otherGestureRecognizer];
375
+ if ([handler isKindOfClass:[RNNativeViewGestureHandler class]]) {
376
+ for (NSNumber *handlerTag in handler->_handlersToWaitFor) {
377
+ if ([_tag isEqual:handlerTag]) {
378
+ return YES;
379
+ }
377
380
  }
381
+ }
378
382
 
379
- return NO;
383
+ return NO;
380
384
  }
381
385
 
382
386
  - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
383
- shouldRequireFailureOfGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
387
+ shouldRequireFailureOfGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
384
388
  {
385
- if ([_handlersToWaitFor count]) {
386
- RNGestureHandler *handler = [RNGestureHandler findGestureHandlerByRecognizer:otherGestureRecognizer];
387
- if (handler != nil) {
388
- for (NSNumber *handlerTag in _handlersToWaitFor) {
389
- if ([handler.tag isEqual:handlerTag]) {
390
- return YES;
391
- }
392
- }
389
+ if ([_handlersToWaitFor count]) {
390
+ RNGestureHandler *handler = [RNGestureHandler findGestureHandlerByRecognizer:otherGestureRecognizer];
391
+ if (handler != nil) {
392
+ for (NSNumber *handlerTag in _handlersToWaitFor) {
393
+ if ([handler.tag isEqual:handlerTag]) {
394
+ return YES;
393
395
  }
396
+ }
394
397
  }
395
- return NO;
398
+ }
399
+ return NO;
396
400
  }
397
401
 
398
402
  - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
399
- shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
403
+ shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
400
404
  {
401
- if (_recognizer.state == UIGestureRecognizerStateBegan && _recognizer.state == UIGestureRecognizerStatePossible) {
402
- return YES;
403
- }
404
-
405
- RNGestureHandler *handler = [RNGestureHandler findGestureHandlerByRecognizer:otherGestureRecognizer];
406
- if (handler != nil) {
407
- if ([_simultaneousHandlers count]) {
408
- for (NSNumber *handlerTag in _simultaneousHandlers) {
409
- if ([handler.tag isEqual:handlerTag]) {
410
- return YES;
411
- }
412
- }
413
- } else if (handler->_simultaneousHandlers) {
414
- for (NSNumber *handlerTag in handler->_simultaneousHandlers) {
415
- if ([self.tag isEqual:handlerTag]) {
416
- return YES;
417
- }
418
- }
405
+ if (_recognizer.state == UIGestureRecognizerStateBegan && _recognizer.state == UIGestureRecognizerStatePossible) {
406
+ return YES;
407
+ }
408
+
409
+ RNGestureHandler *handler = [RNGestureHandler findGestureHandlerByRecognizer:otherGestureRecognizer];
410
+ if (handler != nil) {
411
+ if ([_simultaneousHandlers count]) {
412
+ for (NSNumber *handlerTag in _simultaneousHandlers) {
413
+ if ([handler.tag isEqual:handlerTag]) {
414
+ return YES;
419
415
  }
416
+ }
417
+ } else if (handler->_simultaneousHandlers) {
418
+ for (NSNumber *handlerTag in handler->_simultaneousHandlers) {
419
+ if ([self.tag isEqual:handlerTag]) {
420
+ return YES;
421
+ }
422
+ }
420
423
  }
421
- return NO;
424
+ }
425
+ return NO;
422
426
  }
423
427
 
424
428
  - (void)reset
425
429
  {
426
- // do not reset states while gesture is tracking pointers, as gestureRecognizerShouldBegin
427
- // might be called after some pointers are down, and after state manipulation by the user.
428
- // Pointer tracker calls this method when it resets, and in that case it no longer tracks
429
- // any pointers, thus entering this if
430
- if (!_needsPointerData || _pointerTracker.trackedPointersCount == 0) {
431
- _lastState = RNGestureHandlerStateUndetermined;
432
- _state = RNGestureHandlerStateBegan;
433
- }
430
+ // do not reset states while gesture is tracking pointers, as gestureRecognizerShouldBegin
431
+ // might be called after some pointers are down, and after state manipulation by the user.
432
+ // Pointer tracker calls this method when it resets, and in that case it no longer tracks
433
+ // any pointers, thus entering this if
434
+ if (!_needsPointerData || _pointerTracker.trackedPointersCount == 0) {
435
+ _lastState = RNGestureHandlerStateUndetermined;
436
+ _state = RNGestureHandlerStateBegan;
437
+ }
434
438
  }
435
439
 
436
- - (BOOL)containsPointInView
437
- {
438
- CGPoint pt = [_recognizer locationInView:_recognizer.view];
439
- CGRect hitFrame = RNGHHitSlopInsetRect(_recognizer.view.bounds, _hitSlop);
440
- return CGRectContainsPoint(hitFrame, pt);
441
- }
440
+ - (BOOL)containsPointInView
441
+ {
442
+ CGPoint pt = [_recognizer locationInView:_recognizer.view];
443
+ CGRect hitFrame = RNGHHitSlopInsetRect(_recognizer.view.bounds, _hitSlop);
444
+ return CGRectContainsPoint(hitFrame, pt);
445
+ }
442
446
 
443
447
  - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
444
448
  {
445
- if ([_handlersToWaitFor count]) {
446
- for (RNGestureHandler *handler in [allGestureHandlers allObjects]) {
447
- if (handler != nil
448
- && (handler.state == RNGestureHandlerStateActive || handler->_recognizer.state == UIGestureRecognizerStateBegan)) {
449
- for (NSNumber *handlerTag in _handlersToWaitFor) {
450
- if ([handler.tag isEqual:handlerTag]) {
451
- return NO;
452
- }
453
- }
454
- }
449
+ if ([_handlersToWaitFor count]) {
450
+ for (RNGestureHandler *handler in [allGestureHandlers allObjects]) {
451
+ if (handler != nil &&
452
+ (handler.state == RNGestureHandlerStateActive ||
453
+ handler->_recognizer.state == UIGestureRecognizerStateBegan)) {
454
+ for (NSNumber *handlerTag in _handlersToWaitFor) {
455
+ if ([handler.tag isEqual:handlerTag]) {
456
+ return NO;
457
+ }
455
458
  }
459
+ }
456
460
  }
461
+ }
457
462
 
458
- [self reset];
459
- return YES;
463
+ [self reset];
464
+ return YES;
460
465
  }
461
466
 
462
467
  - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
463
468
  {
464
- // If hitSlop is set we use it to determine if a given gesture recognizer should start processing
465
- // touch stream. This only works for negative values of hitSlop as this method won't be triggered
466
- // unless touch startes in the bounds of the attached view. To acheve similar effect with positive
467
- // values of hitSlop one should set hitSlop for the underlying view. This limitation is due to the
468
- // fact that hitTest method is only available at the level of UIView
469
- if (RNGH_HIT_SLOP_IS_SET(_hitSlop)) {
470
- CGPoint location = [touch locationInView:gestureRecognizer.view];
471
- CGRect hitFrame = RNGHHitSlopInsetRect(gestureRecognizer.view.bounds, _hitSlop);
472
- return CGRectContainsPoint(hitFrame, location);
473
- }
474
- return YES;
469
+ // If hitSlop is set we use it to determine if a given gesture recognizer should start processing
470
+ // touch stream. This only works for negative values of hitSlop as this method won't be triggered
471
+ // unless touch startes in the bounds of the attached view. To acheve similar effect with positive
472
+ // values of hitSlop one should set hitSlop for the underlying view. This limitation is due to the
473
+ // fact that hitTest method is only available at the level of UIView
474
+ if (RNGH_HIT_SLOP_IS_SET(_hitSlop)) {
475
+ CGPoint location = [touch locationInView:gestureRecognizer.view];
476
+ CGRect hitFrame = RNGHHitSlopInsetRect(gestureRecognizer.view.bounds, _hitSlop);
477
+ return CGRectContainsPoint(hitFrame, location);
478
+ }
479
+ return YES;
475
480
  }
476
481
 
477
482
  @end