react-native-gesture-handler 3.0.0-beta.3 → 3.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (419) hide show
  1. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt +42 -38
  2. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +34 -8
  3. package/android/src/main/java/com/swmansion/gesturehandler/core/HoverGestureHandler.kt +3 -6
  4. package/android/src/main/java/com/swmansion/gesturehandler/core/ManualGestureHandler.kt +2 -0
  5. package/android/src/main/java/com/swmansion/gesturehandler/core/NativeViewGestureHandler.kt +68 -7
  6. package/android/src/main/java/com/swmansion/gesturehandler/core/OnJSResponderCancelListener.kt +6 -0
  7. package/android/src/main/java/com/swmansion/gesturehandler/core/PanGestureHandler.kt +2 -0
  8. package/android/src/main/java/com/swmansion/gesturehandler/core/PinchGestureHandler.kt +16 -6
  9. package/android/src/main/java/com/swmansion/gesturehandler/core/RotationGestureHandler.kt +17 -4
  10. package/android/src/main/java/com/swmansion/gesturehandler/core/ViewConfigurationHelper.kt +0 -1
  11. package/android/src/main/java/com/swmansion/gesturehandler/react/Extensions.kt +21 -0
  12. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +160 -55
  13. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerDetectorView.kt +75 -98
  14. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.kt +1 -1
  15. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +7 -10
  16. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRegistry.kt +64 -2
  17. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +18 -8
  18. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt +15 -4
  19. package/android/src/main/java/com/swmansion/gesturehandler/react/RNViewConfigurationHelper.kt +0 -6
  20. package/apple/Handlers/RNForceTouchHandler.m +1 -1
  21. package/apple/Handlers/RNHoverHandler.m +11 -11
  22. package/apple/Handlers/RNLongPressHandler.m +2 -2
  23. package/apple/Handlers/RNManualHandler.m +5 -0
  24. package/apple/Handlers/RNNativeViewHandler.mm +114 -53
  25. package/apple/Handlers/RNPanHandler.m +7 -3
  26. package/apple/Handlers/RNPinchHandler.m +9 -3
  27. package/apple/Handlers/RNRotationHandler.m +7 -2
  28. package/apple/Handlers/RNTapHandler.m +1 -1
  29. package/apple/RNGestureHandler.h +18 -0
  30. package/apple/RNGestureHandler.mm +82 -33
  31. package/apple/RNGestureHandlerButton.h +12 -2
  32. package/apple/RNGestureHandlerButton.mm +208 -38
  33. package/apple/RNGestureHandlerButtonComponentView.mm +102 -6
  34. package/apple/RNGestureHandlerDetector.mm +99 -75
  35. package/apple/RNGestureHandlerModule.mm +11 -14
  36. package/apple/RNGestureHandlerRegistry.h +14 -1
  37. package/apple/RNGestureHandlerRegistry.m +56 -0
  38. package/apple/RNRootViewGestureRecognizer.m +4 -15
  39. package/lib/module/RNGestureHandlerModule.web.js +5 -1
  40. package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
  41. package/lib/module/components/GestureButtons.js +23 -12
  42. package/lib/module/components/GestureButtons.js.map +1 -1
  43. package/lib/module/components/GestureHandlerButton.js.map +1 -1
  44. package/lib/module/components/GestureHandlerButton.web.js +113 -31
  45. package/lib/module/components/GestureHandlerButton.web.js.map +1 -1
  46. package/lib/module/components/Pressable/Pressable.js +2 -1
  47. package/lib/module/components/Pressable/Pressable.js.map +1 -1
  48. package/lib/module/components/Pressable/stateDefinitions.js +2 -0
  49. package/lib/module/components/Pressable/stateDefinitions.js.map +1 -1
  50. package/lib/module/components/ReanimatedDrawerLayout.js.map +1 -1
  51. package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeable.js +38 -5
  52. package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeable.js.map +1 -1
  53. package/lib/module/components/touchables/GenericTouchable.js +2 -6
  54. package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
  55. package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js +1 -2
  56. package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js.map +1 -1
  57. package/lib/module/handlers/gestures/GestureDetector/utils.js +11 -48
  58. package/lib/module/handlers/gestures/GestureDetector/utils.js.map +1 -1
  59. package/lib/module/handlers/gestures/flingGesture.js +8 -0
  60. package/lib/module/handlers/gestures/flingGesture.js.map +1 -1
  61. package/lib/module/handlers/gestures/forceTouchGesture.js +3 -3
  62. package/lib/module/handlers/gestures/gesture.js +8 -0
  63. package/lib/module/handlers/gestures/gesture.js.map +1 -1
  64. package/lib/module/handlers/gestures/gestureComposition.js +28 -0
  65. package/lib/module/handlers/gestures/gestureComposition.js.map +1 -1
  66. package/lib/module/handlers/gestures/gestureObjects.js +27 -1
  67. package/lib/module/handlers/gestures/gestureObjects.js.map +1 -1
  68. package/lib/module/handlers/gestures/gestureStateManager.js +9 -0
  69. package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -1
  70. package/lib/module/handlers/gestures/hoverGesture.js +8 -0
  71. package/lib/module/handlers/gestures/hoverGesture.js.map +1 -1
  72. package/lib/module/handlers/gestures/longPressGesture.js +8 -0
  73. package/lib/module/handlers/gestures/longPressGesture.js.map +1 -1
  74. package/lib/module/handlers/gestures/manualGesture.js +8 -0
  75. package/lib/module/handlers/gestures/manualGesture.js.map +1 -1
  76. package/lib/module/handlers/gestures/nativeGesture.js +8 -0
  77. package/lib/module/handlers/gestures/nativeGesture.js.map +1 -1
  78. package/lib/module/handlers/gestures/panGesture.js +13 -0
  79. package/lib/module/handlers/gestures/panGesture.js.map +1 -1
  80. package/lib/module/handlers/gestures/pinchGesture.js +13 -0
  81. package/lib/module/handlers/gestures/pinchGesture.js.map +1 -1
  82. package/lib/module/handlers/gestures/reanimatedWrapper.js +14 -2
  83. package/lib/module/handlers/gestures/reanimatedWrapper.js.map +1 -1
  84. package/lib/module/handlers/gestures/rotationGesture.js +8 -0
  85. package/lib/module/handlers/gestures/rotationGesture.js.map +1 -1
  86. package/lib/module/handlers/gestures/tapGesture.js +8 -0
  87. package/lib/module/handlers/gestures/tapGesture.js.map +1 -1
  88. package/lib/module/mocks/module.js +3 -2
  89. package/lib/module/mocks/module.js.map +1 -1
  90. package/lib/module/specs/NativeRNGestureHandlerModule.js.map +1 -1
  91. package/lib/module/specs/RNGestureHandlerButtonNativeComponent.ts +28 -13
  92. package/lib/module/v3/NativeProxy.js +5 -3
  93. package/lib/module/v3/NativeProxy.js.map +1 -1
  94. package/lib/module/v3/NativeProxy.web.js +2 -2
  95. package/lib/module/v3/NativeProxy.web.js.map +1 -1
  96. package/lib/module/v3/components/GestureButtons.js +11 -6
  97. package/lib/module/v3/components/GestureButtons.js.map +1 -1
  98. package/lib/module/v3/components/Pressable.js +3 -2
  99. package/lib/module/v3/components/Pressable.js.map +1 -1
  100. package/lib/module/v3/components/Touchable/Touchable.js +119 -32
  101. package/lib/module/v3/components/Touchable/Touchable.js.map +1 -1
  102. package/lib/module/v3/detectors/HostGestureDetector.web.js +180 -59
  103. package/lib/module/v3/detectors/HostGestureDetector.web.js.map +1 -1
  104. package/lib/module/v3/detectors/NativeDetector.js +3 -2
  105. package/lib/module/v3/detectors/NativeDetector.js.map +1 -1
  106. package/lib/module/v3/detectors/VirtualDetector/InterceptingGestureDetector.js +3 -4
  107. package/lib/module/v3/detectors/VirtualDetector/InterceptingGestureDetector.js.map +1 -1
  108. package/lib/module/v3/detectors/VirtualDetector/VirtualDetector.js +4 -2
  109. package/lib/module/v3/detectors/VirtualDetector/VirtualDetector.js.map +1 -1
  110. package/lib/module/v3/detectors/useGestureRelationsUpdater.js +23 -0
  111. package/lib/module/v3/detectors/useGestureRelationsUpdater.js.map +1 -0
  112. package/lib/module/v3/detectors/useNativeGestureRole.js +6 -0
  113. package/lib/module/v3/detectors/useNativeGestureRole.js.map +1 -0
  114. package/lib/module/v3/detectors/useNativeGestureRole.web.js +27 -0
  115. package/lib/module/v3/detectors/useNativeGestureRole.web.js.map +1 -0
  116. package/lib/module/v3/detectors/utils.js +10 -8
  117. package/lib/module/v3/detectors/utils.js.map +1 -1
  118. package/lib/module/v3/hooks/callbacks/useReanimatedEventHandler.js +17 -2
  119. package/lib/module/v3/hooks/callbacks/useReanimatedEventHandler.js.map +1 -1
  120. package/lib/module/v3/hooks/gestures/fling/useFlingGesture.js +2 -1
  121. package/lib/module/v3/hooks/gestures/fling/useFlingGesture.js.map +1 -1
  122. package/lib/module/v3/hooks/gestures/hover/useHoverGesture.js +2 -1
  123. package/lib/module/v3/hooks/gestures/hover/useHoverGesture.js.map +1 -1
  124. package/lib/module/v3/hooks/gestures/longPress/useLongPressGesture.js +2 -1
  125. package/lib/module/v3/hooks/gestures/longPress/useLongPressGesture.js.map +1 -1
  126. package/lib/module/v3/hooks/gestures/manual/useManualGesture.js +2 -1
  127. package/lib/module/v3/hooks/gestures/manual/useManualGesture.js.map +1 -1
  128. package/lib/module/v3/hooks/gestures/native/NativeTypes.js +1 -1
  129. package/lib/module/v3/hooks/gestures/native/NativeTypes.js.map +1 -1
  130. package/lib/module/v3/hooks/gestures/native/useNativeGesture.js +2 -1
  131. package/lib/module/v3/hooks/gestures/native/useNativeGesture.js.map +1 -1
  132. package/lib/module/v3/hooks/gestures/pan/usePanGesture.js +2 -1
  133. package/lib/module/v3/hooks/gestures/pan/usePanGesture.js.map +1 -1
  134. package/lib/module/v3/hooks/gestures/pinch/usePinchGesture.js +2 -1
  135. package/lib/module/v3/hooks/gestures/pinch/usePinchGesture.js.map +1 -1
  136. package/lib/module/v3/hooks/gestures/rotation/useRotationGesture.js +2 -1
  137. package/lib/module/v3/hooks/gestures/rotation/useRotationGesture.js.map +1 -1
  138. package/lib/module/v3/hooks/gestures/tap/useTapGesture.js +2 -1
  139. package/lib/module/v3/hooks/gestures/tap/useTapGesture.js.map +1 -1
  140. package/lib/module/v3/hooks/useGesture.js +4 -22
  141. package/lib/module/v3/hooks/useGesture.js.map +1 -1
  142. package/lib/module/v3/hooks/utils/configUtils.js +8 -6
  143. package/lib/module/v3/hooks/utils/configUtils.js.map +1 -1
  144. package/lib/module/v3/hooks/utils/eventHandlersUtils.js +31 -29
  145. package/lib/module/v3/hooks/utils/eventHandlersUtils.js.map +1 -1
  146. package/lib/module/v3/hooks/utils/index.js +1 -1
  147. package/lib/module/v3/hooks/utils/index.js.map +1 -1
  148. package/lib/module/v3/hooks/utils/propsWhiteList.js +1 -1
  149. package/lib/module/v3/hooks/utils/propsWhiteList.js.map +1 -1
  150. package/lib/module/v3/hooks/utils/reanimatedUtils.js +8 -2
  151. package/lib/module/v3/hooks/utils/reanimatedUtils.js.map +1 -1
  152. package/lib/module/web/constants.js +1 -0
  153. package/lib/module/web/constants.js.map +1 -1
  154. package/lib/module/web/detectors/RotationGestureDetector.js +18 -5
  155. package/lib/module/web/detectors/RotationGestureDetector.js.map +1 -1
  156. package/lib/module/web/detectors/ScaleGestureDetector.js +9 -1
  157. package/lib/module/web/detectors/ScaleGestureDetector.js.map +1 -1
  158. package/lib/module/web/handlers/GestureHandler.js +25 -5
  159. package/lib/module/web/handlers/GestureHandler.js.map +1 -1
  160. package/lib/module/web/handlers/HoverGestureHandler.js +1 -4
  161. package/lib/module/web/handlers/HoverGestureHandler.js.map +1 -1
  162. package/lib/module/web/handlers/ManualGestureHandler.js +1 -0
  163. package/lib/module/web/handlers/ManualGestureHandler.js.map +1 -1
  164. package/lib/module/web/handlers/NativeViewGestureHandler.js +65 -17
  165. package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
  166. package/lib/module/web/handlers/PanGestureHandler.js +1 -0
  167. package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
  168. package/lib/module/web/handlers/PinchGestureHandler.js +4 -6
  169. package/lib/module/web/handlers/PinchGestureHandler.js.map +1 -1
  170. package/lib/module/web/handlers/RotationGestureHandler.js +4 -3
  171. package/lib/module/web/handlers/RotationGestureHandler.js.map +1 -1
  172. package/lib/module/web/interfaces.js +6 -0
  173. package/lib/module/web/interfaces.js.map +1 -1
  174. package/lib/module/web/tools/GestureHandlerOrchestrator.js +8 -2
  175. package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
  176. package/lib/module/web/tools/GestureLifecycleEvents.js +10 -0
  177. package/lib/module/web/tools/GestureLifecycleEvents.js.map +1 -0
  178. package/lib/module/web/tools/NodeManager.js +44 -0
  179. package/lib/module/web/tools/NodeManager.js.map +1 -1
  180. package/lib/module/web/tools/PointerEventManager.js +9 -0
  181. package/lib/module/web/tools/PointerEventManager.js.map +1 -1
  182. package/lib/typescript/RNGestureHandlerModule.web.d.ts +1 -1
  183. package/lib/typescript/RNGestureHandlerModule.web.d.ts.map +1 -1
  184. package/lib/typescript/components/GestureButtons.d.ts +14 -6
  185. package/lib/typescript/components/GestureButtons.d.ts.map +1 -1
  186. package/lib/typescript/components/GestureHandlerButton.d.ts +62 -8
  187. package/lib/typescript/components/GestureHandlerButton.d.ts.map +1 -1
  188. package/lib/typescript/components/GestureHandlerButton.web.d.ts +14 -3
  189. package/lib/typescript/components/GestureHandlerButton.web.d.ts.map +1 -1
  190. package/lib/typescript/components/Pressable/Pressable.d.ts.map +1 -1
  191. package/lib/typescript/components/Pressable/PressableProps.d.ts +1 -1
  192. package/lib/typescript/components/Pressable/PressableProps.d.ts.map +1 -1
  193. package/lib/typescript/components/Pressable/stateDefinitions.d.ts.map +1 -1
  194. package/lib/typescript/components/ReanimatedDrawerLayout.d.ts +16 -14
  195. package/lib/typescript/components/ReanimatedDrawerLayout.d.ts.map +1 -1
  196. package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeable.d.ts +2 -1
  197. package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeable.d.ts.map +1 -1
  198. package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeableProps.d.ts +30 -34
  199. package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeableProps.d.ts.map +1 -1
  200. package/lib/typescript/components/touchables/GenericTouchable.d.ts.map +1 -1
  201. package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.d.ts.map +1 -1
  202. package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts +0 -1
  203. package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts.map +1 -1
  204. package/lib/typescript/handlers/gestures/flingGesture.d.ts +6 -0
  205. package/lib/typescript/handlers/gestures/flingGesture.d.ts.map +1 -1
  206. package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +3 -3
  207. package/lib/typescript/handlers/gestures/gesture.d.ts +6 -0
  208. package/lib/typescript/handlers/gestures/gesture.d.ts.map +1 -1
  209. package/lib/typescript/handlers/gestures/gestureComposition.d.ts +21 -0
  210. package/lib/typescript/handlers/gestures/gestureComposition.d.ts.map +1 -1
  211. package/lib/typescript/handlers/gestures/gestureObjects.d.ts +27 -1
  212. package/lib/typescript/handlers/gestures/gestureObjects.d.ts.map +1 -1
  213. package/lib/typescript/handlers/gestures/gestureStateManager.d.ts +6 -0
  214. package/lib/typescript/handlers/gestures/gestureStateManager.d.ts.map +1 -1
  215. package/lib/typescript/handlers/gestures/hoverGesture.d.ts +6 -0
  216. package/lib/typescript/handlers/gestures/hoverGesture.d.ts.map +1 -1
  217. package/lib/typescript/handlers/gestures/longPressGesture.d.ts +6 -0
  218. package/lib/typescript/handlers/gestures/longPressGesture.d.ts.map +1 -1
  219. package/lib/typescript/handlers/gestures/manualGesture.d.ts +6 -0
  220. package/lib/typescript/handlers/gestures/manualGesture.d.ts.map +1 -1
  221. package/lib/typescript/handlers/gestures/nativeGesture.d.ts +6 -0
  222. package/lib/typescript/handlers/gestures/nativeGesture.d.ts.map +1 -1
  223. package/lib/typescript/handlers/gestures/panGesture.d.ts +9 -0
  224. package/lib/typescript/handlers/gestures/panGesture.d.ts.map +1 -1
  225. package/lib/typescript/handlers/gestures/pinchGesture.d.ts +9 -0
  226. package/lib/typescript/handlers/gestures/pinchGesture.d.ts.map +1 -1
  227. package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts.map +1 -1
  228. package/lib/typescript/handlers/gestures/rotationGesture.d.ts +6 -0
  229. package/lib/typescript/handlers/gestures/rotationGesture.d.ts.map +1 -1
  230. package/lib/typescript/handlers/gestures/tapGesture.d.ts +6 -0
  231. package/lib/typescript/handlers/gestures/tapGesture.d.ts.map +1 -1
  232. package/lib/typescript/mocks/module.d.ts +1 -1
  233. package/lib/typescript/mocks/module.d.ts.map +1 -1
  234. package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts +2 -2
  235. package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts.map +1 -1
  236. package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts +19 -11
  237. package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts.map +1 -1
  238. package/lib/typescript/v3/NativeProxy.d.ts +1 -1
  239. package/lib/typescript/v3/NativeProxy.d.ts.map +1 -1
  240. package/lib/typescript/v3/NativeProxy.web.d.ts +1 -1
  241. package/lib/typescript/v3/NativeProxy.web.d.ts.map +1 -1
  242. package/lib/typescript/v3/components/GestureButtons.d.ts +1 -37
  243. package/lib/typescript/v3/components/GestureButtons.d.ts.map +1 -1
  244. package/lib/typescript/v3/components/GestureButtonsProps.d.ts +1 -1
  245. package/lib/typescript/v3/components/GestureButtonsProps.d.ts.map +1 -1
  246. package/lib/typescript/v3/components/GestureComponents.d.ts +3 -0
  247. package/lib/typescript/v3/components/GestureComponents.d.ts.map +1 -1
  248. package/lib/typescript/v3/components/GestureComponents.web.d.ts +4 -0
  249. package/lib/typescript/v3/components/GestureComponents.web.d.ts.map +1 -1
  250. package/lib/typescript/v3/components/Pressable.d.ts.map +1 -1
  251. package/lib/typescript/v3/components/Touchable/Touchable.d.ts.map +1 -1
  252. package/lib/typescript/v3/components/Touchable/TouchableProps.d.ts +48 -1
  253. package/lib/typescript/v3/components/Touchable/TouchableProps.d.ts.map +1 -1
  254. package/lib/typescript/v3/detectors/HostGestureDetector.web.d.ts +1 -1
  255. package/lib/typescript/v3/detectors/HostGestureDetector.web.d.ts.map +1 -1
  256. package/lib/typescript/v3/detectors/NativeDetector.d.ts.map +1 -1
  257. package/lib/typescript/v3/detectors/VirtualDetector/InterceptingGestureDetector.d.ts.map +1 -1
  258. package/lib/typescript/v3/detectors/VirtualDetector/VirtualDetector.d.ts.map +1 -1
  259. package/lib/typescript/v3/detectors/useGestureRelationsUpdater.d.ts +3 -0
  260. package/lib/typescript/v3/detectors/useGestureRelationsUpdater.d.ts.map +1 -0
  261. package/lib/typescript/v3/detectors/useNativeGestureRole.d.ts +3 -0
  262. package/lib/typescript/v3/detectors/useNativeGestureRole.d.ts.map +1 -0
  263. package/lib/typescript/v3/detectors/useNativeGestureRole.web.d.ts +3 -0
  264. package/lib/typescript/v3/detectors/useNativeGestureRole.web.d.ts.map +1 -0
  265. package/lib/typescript/v3/detectors/utils.d.ts +3 -3
  266. package/lib/typescript/v3/detectors/utils.d.ts.map +1 -1
  267. package/lib/typescript/v3/hooks/callbacks/useReanimatedEventHandler.d.ts.map +1 -1
  268. package/lib/typescript/v3/hooks/gestures/fling/useFlingGesture.d.ts +1 -1
  269. package/lib/typescript/v3/hooks/gestures/fling/useFlingGesture.d.ts.map +1 -1
  270. package/lib/typescript/v3/hooks/gestures/hover/useHoverGesture.d.ts +1 -1
  271. package/lib/typescript/v3/hooks/gestures/hover/useHoverGesture.d.ts.map +1 -1
  272. package/lib/typescript/v3/hooks/gestures/longPress/useLongPressGesture.d.ts +1 -1
  273. package/lib/typescript/v3/hooks/gestures/longPress/useLongPressGesture.d.ts.map +1 -1
  274. package/lib/typescript/v3/hooks/gestures/manual/useManualGesture.d.ts +1 -1
  275. package/lib/typescript/v3/hooks/gestures/manual/useManualGesture.d.ts.map +1 -1
  276. package/lib/typescript/v3/hooks/gestures/native/NativeTypes.d.ts +7 -0
  277. package/lib/typescript/v3/hooks/gestures/native/NativeTypes.d.ts.map +1 -1
  278. package/lib/typescript/v3/hooks/gestures/native/useNativeGesture.d.ts +1 -1
  279. package/lib/typescript/v3/hooks/gestures/native/useNativeGesture.d.ts.map +1 -1
  280. package/lib/typescript/v3/hooks/gestures/pan/usePanGesture.d.ts +1 -1
  281. package/lib/typescript/v3/hooks/gestures/pan/usePanGesture.d.ts.map +1 -1
  282. package/lib/typescript/v3/hooks/gestures/pinch/usePinchGesture.d.ts +1 -1
  283. package/lib/typescript/v3/hooks/gestures/pinch/usePinchGesture.d.ts.map +1 -1
  284. package/lib/typescript/v3/hooks/gestures/rotation/useRotationGesture.d.ts +1 -1
  285. package/lib/typescript/v3/hooks/gestures/rotation/useRotationGesture.d.ts.map +1 -1
  286. package/lib/typescript/v3/hooks/gestures/tap/useTapGesture.d.ts +1 -1
  287. package/lib/typescript/v3/hooks/gestures/tap/useTapGesture.d.ts.map +1 -1
  288. package/lib/typescript/v3/hooks/useGesture.d.ts.map +1 -1
  289. package/lib/typescript/v3/hooks/utils/configUtils.d.ts +2 -2
  290. package/lib/typescript/v3/hooks/utils/configUtils.d.ts.map +1 -1
  291. package/lib/typescript/v3/hooks/utils/eventHandlersUtils.d.ts.map +1 -1
  292. package/lib/typescript/v3/hooks/utils/index.d.ts +1 -1
  293. package/lib/typescript/v3/hooks/utils/index.d.ts.map +1 -1
  294. package/lib/typescript/v3/hooks/utils/propsWhiteList.d.ts +2 -2
  295. package/lib/typescript/v3/hooks/utils/propsWhiteList.d.ts.map +1 -1
  296. package/lib/typescript/v3/hooks/utils/reanimatedUtils.d.ts +1 -0
  297. package/lib/typescript/v3/hooks/utils/reanimatedUtils.d.ts.map +1 -1
  298. package/lib/typescript/v3/types/ConfigTypes.d.ts +1 -0
  299. package/lib/typescript/v3/types/ConfigTypes.d.ts.map +1 -1
  300. package/lib/typescript/web/constants.d.ts +1 -0
  301. package/lib/typescript/web/constants.d.ts.map +1 -1
  302. package/lib/typescript/web/detectors/RotationGestureDetector.d.ts.map +1 -1
  303. package/lib/typescript/web/detectors/ScaleGestureDetector.d.ts.map +1 -1
  304. package/lib/typescript/web/handlers/GestureHandler.d.ts +8 -2
  305. package/lib/typescript/web/handlers/GestureHandler.d.ts.map +1 -1
  306. package/lib/typescript/web/handlers/HoverGestureHandler.d.ts +1 -1
  307. package/lib/typescript/web/handlers/HoverGestureHandler.d.ts.map +1 -1
  308. package/lib/typescript/web/handlers/IGestureHandler.d.ts +2 -0
  309. package/lib/typescript/web/handlers/IGestureHandler.d.ts.map +1 -1
  310. package/lib/typescript/web/handlers/ManualGestureHandler.d.ts +1 -0
  311. package/lib/typescript/web/handlers/ManualGestureHandler.d.ts.map +1 -1
  312. package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +13 -3
  313. package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts.map +1 -1
  314. package/lib/typescript/web/handlers/PanGestureHandler.d.ts +1 -0
  315. package/lib/typescript/web/handlers/PanGestureHandler.d.ts.map +1 -1
  316. package/lib/typescript/web/handlers/PinchGestureHandler.d.ts +1 -0
  317. package/lib/typescript/web/handlers/PinchGestureHandler.d.ts.map +1 -1
  318. package/lib/typescript/web/handlers/RotationGestureHandler.d.ts +1 -0
  319. package/lib/typescript/web/handlers/RotationGestureHandler.d.ts.map +1 -1
  320. package/lib/typescript/web/interfaces.d.ts +6 -0
  321. package/lib/typescript/web/interfaces.d.ts.map +1 -1
  322. package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts +1 -0
  323. package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts.map +1 -1
  324. package/lib/typescript/web/tools/GestureLifecycleEvents.d.ts +7 -0
  325. package/lib/typescript/web/tools/GestureLifecycleEvents.d.ts.map +1 -0
  326. package/lib/typescript/web/tools/NodeManager.d.ts +7 -0
  327. package/lib/typescript/web/tools/NodeManager.d.ts.map +1 -1
  328. package/lib/typescript/web/tools/PointerEventManager.d.ts.map +1 -1
  329. package/package.json +3 -3
  330. package/src/RNGestureHandlerModule.web.ts +5 -1
  331. package/src/components/GestureButtons.tsx +33 -16
  332. package/src/components/GestureHandlerButton.tsx +70 -8
  333. package/src/components/GestureHandlerButton.web.tsx +184 -48
  334. package/src/components/Pressable/Pressable.tsx +3 -1
  335. package/src/components/Pressable/PressableProps.tsx +2 -1
  336. package/src/components/Pressable/stateDefinitions.ts +3 -0
  337. package/src/components/ReanimatedDrawerLayout.tsx +27 -23
  338. package/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx +51 -5
  339. package/src/components/ReanimatedSwipeable/ReanimatedSwipeableProps.ts +31 -39
  340. package/src/components/touchables/GenericTouchable.tsx +2 -5
  341. package/src/handlers/gestures/GestureDetector/useDetectorUpdater.ts +1 -2
  342. package/src/handlers/gestures/GestureDetector/utils.ts +11 -53
  343. package/src/handlers/gestures/flingGesture.ts +6 -0
  344. package/src/handlers/gestures/forceTouchGesture.ts +3 -3
  345. package/src/handlers/gestures/gesture.ts +6 -0
  346. package/src/handlers/gestures/gestureComposition.ts +21 -0
  347. package/src/handlers/gestures/gestureObjects.ts +27 -1
  348. package/src/handlers/gestures/gestureStateManager.ts +6 -0
  349. package/src/handlers/gestures/hoverGesture.ts +6 -0
  350. package/src/handlers/gestures/longPressGesture.ts +6 -0
  351. package/src/handlers/gestures/manualGesture.ts +6 -0
  352. package/src/handlers/gestures/nativeGesture.ts +6 -0
  353. package/src/handlers/gestures/panGesture.ts +9 -0
  354. package/src/handlers/gestures/pinchGesture.ts +9 -0
  355. package/src/handlers/gestures/reanimatedWrapper.ts +20 -2
  356. package/src/handlers/gestures/rotationGesture.ts +6 -0
  357. package/src/handlers/gestures/tapGesture.ts +6 -0
  358. package/src/mocks/module.tsx +4 -2
  359. package/src/specs/NativeRNGestureHandlerModule.ts +2 -4
  360. package/src/specs/RNGestureHandlerButtonNativeComponent.ts +28 -13
  361. package/src/v3/NativeProxy.ts +9 -7
  362. package/src/v3/NativeProxy.web.ts +2 -2
  363. package/src/v3/components/GestureButtons.tsx +18 -10
  364. package/src/v3/components/GestureButtonsProps.ts +1 -0
  365. package/src/v3/components/Pressable.tsx +2 -1
  366. package/src/v3/components/Touchable/Touchable.tsx +144 -50
  367. package/src/v3/components/Touchable/TouchableProps.ts +64 -2
  368. package/src/v3/detectors/HostGestureDetector.web.tsx +268 -108
  369. package/src/v3/detectors/NativeDetector.tsx +3 -2
  370. package/src/v3/detectors/VirtualDetector/InterceptingGestureDetector.tsx +3 -4
  371. package/src/v3/detectors/VirtualDetector/VirtualDetector.tsx +5 -2
  372. package/src/v3/detectors/useGestureRelationsUpdater.ts +30 -0
  373. package/src/v3/detectors/useNativeGestureRole.ts +8 -0
  374. package/src/v3/detectors/useNativeGestureRole.web.ts +42 -0
  375. package/src/v3/detectors/utils.ts +28 -12
  376. package/src/v3/hooks/callbacks/useReanimatedEventHandler.ts +23 -7
  377. package/src/v3/hooks/gestures/fling/useFlingGesture.ts +5 -1
  378. package/src/v3/hooks/gestures/hover/useHoverGesture.ts +5 -1
  379. package/src/v3/hooks/gestures/longPress/useLongPressGesture.ts +3 -1
  380. package/src/v3/hooks/gestures/manual/useManualGesture.ts +5 -1
  381. package/src/v3/hooks/gestures/native/NativeTypes.ts +13 -1
  382. package/src/v3/hooks/gestures/native/useNativeGesture.ts +5 -1
  383. package/src/v3/hooks/gestures/pan/usePanGesture.ts +5 -1
  384. package/src/v3/hooks/gestures/pinch/usePinchGesture.ts +5 -1
  385. package/src/v3/hooks/gestures/rotation/useRotationGesture.ts +3 -1
  386. package/src/v3/hooks/gestures/tap/useTapGesture.ts +5 -1
  387. package/src/v3/hooks/useGesture.ts +4 -18
  388. package/src/v3/hooks/utils/configUtils.ts +18 -8
  389. package/src/v3/hooks/utils/eventHandlersUtils.ts +43 -32
  390. package/src/v3/hooks/utils/index.ts +0 -1
  391. package/src/v3/hooks/utils/propsWhiteList.ts +1 -0
  392. package/src/v3/hooks/utils/reanimatedUtils.ts +10 -10
  393. package/src/v3/types/ConfigTypes.ts +1 -0
  394. package/src/web/constants.ts +1 -0
  395. package/src/web/detectors/RotationGestureDetector.ts +19 -5
  396. package/src/web/detectors/ScaleGestureDetector.ts +9 -3
  397. package/src/web/handlers/GestureHandler.ts +36 -6
  398. package/src/web/handlers/HoverGestureHandler.ts +2 -5
  399. package/src/web/handlers/IGestureHandler.ts +2 -0
  400. package/src/web/handlers/ManualGestureHandler.ts +2 -0
  401. package/src/web/handlers/NativeViewGestureHandler.ts +122 -19
  402. package/src/web/handlers/PanGestureHandler.ts +2 -0
  403. package/src/web/handlers/PinchGestureHandler.ts +5 -7
  404. package/src/web/handlers/RotationGestureHandler.ts +5 -5
  405. package/src/web/interfaces.ts +7 -0
  406. package/src/web/tools/GestureHandlerOrchestrator.ts +11 -3
  407. package/src/web/tools/GestureLifecycleEvents.ts +14 -0
  408. package/src/web/tools/NodeManager.ts +57 -0
  409. package/src/web/tools/PointerEventManager.ts +12 -0
  410. package/lib/module/RNRenderer.js +0 -6
  411. package/lib/module/RNRenderer.js.map +0 -1
  412. package/lib/module/RNRenderer.web.js +0 -6
  413. package/lib/module/RNRenderer.web.js.map +0 -1
  414. package/lib/typescript/RNRenderer.d.ts +0 -2
  415. package/lib/typescript/RNRenderer.d.ts.map +0 -1
  416. package/lib/typescript/RNRenderer.web.d.ts +0 -4
  417. package/lib/typescript/RNRenderer.web.d.ts.map +0 -1
  418. package/src/RNRenderer.ts +0 -3
  419. package/src/RNRenderer.web.ts +0 -3
@@ -9,7 +9,6 @@ import android.view.MotionEvent
9
9
  import android.view.MotionEvent.PointerCoords
10
10
  import android.view.MotionEvent.PointerProperties
11
11
  import android.view.View
12
- import androidx.core.view.isNotEmpty
13
12
  import com.facebook.react.bridge.Arguments
14
13
  import com.facebook.react.bridge.ReactContext
15
14
  import com.facebook.react.bridge.ReadableMap
@@ -48,6 +47,26 @@ open class GestureHandler {
48
47
  }
49
48
  }
50
49
 
50
+ /**
51
+ * The view whose coordinate space should be used when reporting event positions to JS.
52
+ *
53
+ * Handlers attached via the V3 NativeDetector are registered against the DetectorView wrapper,
54
+ * which never carries user-applied transforms — those live on its child. When the detector has
55
+ * exactly one child we descend into it so reported coordinates match the visible (transformed)
56
+ * view, the same coordinate space V2 and the V3 VirtualGestureDetector report in. With
57
+ * multiple children there is no JS-side way to disambiguate which child caught the pointer,
58
+ * so we keep the detector itself as the reference frame.
59
+ */
60
+ val coordinateView: View?
61
+ get() {
62
+ val v = view
63
+ return if (v is RNGestureHandlerDetectorView && v.childCount == 1) {
64
+ v.getChildAt(0)
65
+ } else {
66
+ v
67
+ }
68
+ }
69
+
51
70
  var state = STATE_UNDETERMINED
52
71
  private set
53
72
  var x = 0f
@@ -83,6 +102,7 @@ open class GestureHandler {
83
102
  var needsPointerData = false
84
103
  var dispatchesAnimatedEvents = false
85
104
  var dispatchesReanimatedEvents = false
105
+ var cancelsJSResponder = true
86
106
 
87
107
  private var hitSlop: FloatArray? = null
88
108
  var eventCoalescingKey: Short = 0
@@ -113,6 +133,11 @@ open class GestureHandler {
113
133
  var isAwaiting = false
114
134
  var shouldResetProgress = false
115
135
 
136
+ /**
137
+ * Whether the handler represents a continuous gesture rather than a discrete one.
138
+ */
139
+ open val isContinuous: Boolean = false
140
+
116
141
  open fun dispatchStateChange(newState: Int, prevState: Int) {
117
142
  onTouchEventListener?.onStateChange(this, newState, prevState)
118
143
  }
@@ -137,6 +162,7 @@ open class GestureHandler {
137
162
  mouseButton = DEFAULT_MOUSE_BUTTON
138
163
  dispatchesAnimatedEvents = DEFAULT_DISPATCHES_ANIMATED_EVENTS
139
164
  dispatchesReanimatedEvents = DEFAULT_DISPATCHES_REANIMATED_EVENTS
165
+ cancelsJSResponder = DEFAULT_CANCELS_JS_RESPONDER
140
166
  }
141
167
 
142
168
  fun hasCommonPointers(other: GestureHandler): Boolean {
@@ -387,42 +413,13 @@ open class GestureHandler {
387
413
 
388
414
  numberOfPointers = adaptedTransformedEvent.pointerCount
389
415
 
390
- // TODO: this is likely wrong, and the transformed event itself should be
391
- // in the coordinate system of the child view, but I'm not sure of the
392
- // consequences
393
- val detectorView = hostDetectorView
394
- if (detectorView != null && view == detectorView && detectorView.isNotEmpty()) {
395
- val outPoint = PointF()
396
- var foundChild = false
397
-
398
- for (i in 0 until detectorView.childCount) {
399
- val child = detectorView.getChildAt(i)
400
- GestureHandlerOrchestrator.transformPointToChildViewCoords(
401
- adaptedTransformedEvent.x,
402
- adaptedTransformedEvent.y,
403
- detectorView,
404
- child,
405
- outPoint,
406
- )
407
- if (isWithinBounds(child, outPoint.x, outPoint.y)) {
408
- x = outPoint.x
409
- y = outPoint.y
410
- isWithinBounds = true
411
- foundChild = true
412
- break
413
- }
414
- }
415
-
416
- if (!foundChild) {
417
- x = adaptedTransformedEvent.x
418
- y = adaptedTransformedEvent.y
419
- isWithinBounds = false
420
- }
421
- } else {
422
- x = adaptedTransformedEvent.x
423
- y = adaptedTransformedEvent.y
424
- isWithinBounds = isWithinBounds(view, x, y)
425
- }
416
+ x = adaptedTransformedEvent.x
417
+ y = adaptedTransformedEvent.y
418
+ // The orchestrator transforms incoming events into the coordinate space of the detector's
419
+ // child (when the handler is attached to a NativeDetector wrapper), so bounds-checking must
420
+ // also use that child rather than the wrapper, otherwise hit-testing would ignore the user's
421
+ // transforms applied to the visible view.
422
+ isWithinBounds = isWithinBounds(coordinateView, x, y)
426
423
 
427
424
  if (shouldCancelWhenOutside) {
428
425
  if (!isWithinBounds && (state == STATE_ACTIVE || state == STATE_BEGAN)) {
@@ -693,6 +690,8 @@ open class GestureHandler {
693
690
  return interactionController?.shouldHandlerBeCancelledBy(this, handler) ?: false
694
691
  }
695
692
 
693
+ open fun shouldBeginWithRecordedHandlers(recorded: List<GestureHandler>): Boolean = true
694
+
696
695
  fun isWithinBounds(view: View?, posX: Float, posY: Float): Boolean {
697
696
  if (RNSVGHitTester.isSvgElement(view!!)) {
698
697
  return RNSVGHitTester.hitTest(view, posX, posY)
@@ -870,7 +869,7 @@ open class GestureHandler {
870
869
  * This method modifies and transforms the received point.
871
870
  */
872
871
  protected fun transformPoint(point: PointF): PointF =
873
- orchestrator?.transformPointToViewCoords(this.view, point) ?: run {
872
+ orchestrator?.transformPointToViewCoords(coordinateView, point) ?: run {
874
873
  point.x = Float.NaN
875
874
  point.y = Float.NaN
876
875
  point
@@ -961,6 +960,9 @@ open class GestureHandler {
961
960
  if (config.hasKey(KEY_TEST_ID)) {
962
961
  handler.testID = config.getString(KEY_TEST_ID)
963
962
  }
963
+ if (config.hasKey(KEY_CANCELS_JS_RESPONDER)) {
964
+ handler.cancelsJSResponder = config.getBoolean(KEY_CANCELS_JS_RESPONDER)
965
+ }
964
966
  }
965
967
 
966
968
  abstract fun createEventBuilder(handler: T): GestureHandlerEventDataBuilder<T>
@@ -983,6 +985,7 @@ open class GestureHandler {
983
985
  private const val KEY_HIT_SLOP_WIDTH = "width"
984
986
  private const val KEY_HIT_SLOP_HEIGHT = "height"
985
987
  private const val KEY_TEST_ID = "testID"
988
+ private const val KEY_CANCELS_JS_RESPONDER = "cancelsJSResponder"
986
989
 
987
990
  private fun handleHitSlopProperty(handler: GestureHandler, config: ReadableMap) {
988
991
  if (config.getType(KEY_HIT_SLOP) == ReadableType.Number) {
@@ -1046,6 +1049,7 @@ open class GestureHandler {
1046
1049
  private const val DEFAULT_MOUSE_BUTTON = 0
1047
1050
  private const val DEFAULT_DISPATCHES_ANIMATED_EVENTS = false
1048
1051
  private const val DEFAULT_DISPATCHES_REANIMATED_EVENTS = false
1052
+ private const val DEFAULT_CANCELS_JS_RESPONDER = true
1049
1053
 
1050
1054
  const val STATE_UNDETERMINED = 0
1051
1055
  const val STATE_FAILED = 1
@@ -19,6 +19,7 @@ class GestureHandlerOrchestrator(
19
19
  private val handlerRegistry: GestureHandlerRegistry,
20
20
  private val viewConfigHelper: ViewConfigurationHelper,
21
21
  private val rootView: ViewGroup,
22
+ private val onJSResponderCancelListener: OnJSResponderCancelListener,
22
23
  ) {
23
24
  /**
24
25
  * Minimum alpha (value from 0 to 1) that should be set to a view so that it can be treated as a
@@ -143,6 +144,14 @@ class GestureHandlerOrchestrator(
143
144
  /*package*/
144
145
  fun onHandlerStateChange(handler: GestureHandler, newState: Int, prevState: Int) {
145
146
  handlingChangeSemaphore += 1
147
+
148
+ if (isFinished(newState) && handler.isActive && handler.cancelsJSResponder) {
149
+ // Check if there are any other active handlers that still request the JS responder to be cancelled.
150
+ if (gestureHandlers.none { it !== handler && it.isActive && it.cancelsJSResponder }) {
151
+ onJSResponderCancelListener?.onCancelJSResponderReleased(handler)
152
+ }
153
+ }
154
+
146
155
  if (isFinished(newState)) {
147
156
  // We have to loop through copy in order to avoid modifying collection
148
157
  // while iterating over its elements
@@ -241,6 +250,10 @@ class GestureHandlerOrchestrator(
241
250
  return
242
251
  }
243
252
 
253
+ if (handler.cancelsJSResponder) {
254
+ onJSResponderCancelListener?.onCancelJSResponderRequested(handler)
255
+ }
256
+
244
257
  handler.dispatchStateChange(GestureHandler.STATE_ACTIVE, GestureHandler.STATE_BEGAN)
245
258
 
246
259
  if (currentState != GestureHandler.STATE_ACTIVE) {
@@ -297,7 +310,7 @@ class GestureHandlerOrchestrator(
297
310
  }
298
311
 
299
312
  val action = sourceEvent.actionMasked
300
- val event = transformEventToViewCoords(handler.view, MotionEvent.obtain(sourceEvent))
313
+ val event = transformEventToViewCoords(handler.coordinateView, MotionEvent.obtain(sourceEvent))
301
314
 
302
315
  if (handler.needsPointerData) {
303
316
  handler.updatePointerData(event, sourceEvent)
@@ -349,11 +362,19 @@ class GestureHandlerOrchestrator(
349
362
  if (view === wrapperView) {
350
363
  return true
351
364
  }
352
- var parent = view.parent
353
- while (parent != null && parent !== wrapperView) {
354
- parent = parent.parent
365
+ var current: View = view
366
+ while (true) {
367
+ val parent = current.parent as? ViewGroup ?: return false
368
+
369
+ when {
370
+ // A disappearing child (kept drawable for an exit animation, e.g. RNScreens during a
371
+ // navigation transition) still has `parent` set but is gone from `mChildren`. Treat as
372
+ // detached - `cancelTouchTarget` already synthesized ACTION_CANCEL into this subtree.
373
+ parent.indexOfChild(current) < 0 -> return false
374
+ parent === wrapperView -> return true
375
+ else -> current = parent
376
+ }
355
377
  }
356
- return parent === wrapperView
357
378
  }
358
379
 
359
380
  fun isAnyHandlerActive() = gestureHandlers.any { it.state == GestureHandler.STATE_ACTIVE }
@@ -448,11 +469,16 @@ class GestureHandlerOrchestrator(
448
469
  return
449
470
  }
450
471
 
451
- gestureHandlers.add(handler)
452
472
  handler.isActive = false
453
473
  handler.isAwaiting = false
454
474
  handler.activationIndex = Int.MAX_VALUE
455
475
  handler.prepare(view, this)
476
+
477
+ if (!handler.shouldBeginWithRecordedHandlers(gestureHandlers)) {
478
+ handler.cancel()
479
+ }
480
+
481
+ gestureHandlers.add(handler)
456
482
  }
457
483
 
458
484
  private fun isViewOverflowingParent(view: View): Boolean {
@@ -606,7 +632,7 @@ class GestureHandlerOrchestrator(
606
632
 
607
633
  val childrenCount = viewGroup.childCount
608
634
  for (i in childrenCount - 1 downTo 0) {
609
- val child = viewConfigHelper.getChildInDrawingOrderAtIndex(viewGroup, i)
635
+ val child = viewGroup.getChildAt(i)
610
636
  if (canReceiveEvents(child)) {
611
637
  val childPoint = tempPoint
612
638
  transformPointToChildViewCoords(coords[0], coords[1], viewGroup, child, childPoint)
@@ -659,7 +685,7 @@ class GestureHandlerOrchestrator(
659
685
  is ViewGroup -> {
660
686
  extractGestureHandlers(view, coords, pointerId, event).also { found ->
661
687
  // A child view is handling touch, also extract handlers attached to this view
662
- if (found) {
688
+ if (found || view is RNGestureHandlerDetectorView) {
663
689
  recordViewHandlersForPointer(view, coords, pointerId, event)
664
690
  }
665
691
  }
@@ -7,10 +7,11 @@ import android.view.MotionEvent
7
7
  import android.view.View
8
8
  import android.view.ViewGroup
9
9
  import com.swmansion.gesturehandler.react.RNGestureHandlerRootHelper
10
- import com.swmansion.gesturehandler.react.RNViewConfigurationHelper
11
10
  import com.swmansion.gesturehandler.react.events.eventbuilders.HoverGestureHandlerEventDataBuilder
12
11
 
13
12
  class HoverGestureHandler : GestureHandler() {
13
+ override val isContinuous = true
14
+
14
15
  private var handler: Handler? = null
15
16
  private var finishRunnable = Runnable { finish() }
16
17
  var stylusData: StylusData = StylusData()
@@ -42,7 +43,7 @@ class HoverGestureHandler : GestureHandler() {
42
43
 
43
44
  if (rootView is ViewGroup) {
44
45
  for (i in 0 until rootView.childCount) {
45
- val child = viewConfigHelper.getChildInDrawingOrderAtIndex(rootView, i)
46
+ val child = rootView.getChildAt(i)
46
47
  return isViewDisplayedOverAnother(view, other, child) ?: continue
47
48
  }
48
49
  }
@@ -143,8 +144,4 @@ class HoverGestureHandler : GestureHandler() {
143
144
 
144
145
  override fun createEventBuilder(handler: HoverGestureHandler) = HoverGestureHandlerEventDataBuilder(handler)
145
146
  }
146
-
147
- companion object {
148
- private val viewConfigHelper = RNViewConfigurationHelper()
149
- }
150
147
  }
@@ -5,6 +5,8 @@ import android.view.MotionEvent
5
5
  import com.swmansion.gesturehandler.react.events.eventbuilders.ManualGestureHandlerEventDataBuilder
6
6
 
7
7
  class ManualGestureHandler : GestureHandler() {
8
+ override val isContinuous = true
9
+
8
10
  override fun onHandle(event: MotionEvent, sourceEvent: MotionEvent) {
9
11
  if (state == STATE_UNDETERMINED) {
10
12
  begin()
@@ -15,10 +15,13 @@ import com.facebook.react.views.text.ReactTextView
15
15
  import com.facebook.react.views.textinput.ReactEditText
16
16
  import com.facebook.react.views.view.ReactViewGroup
17
17
  import com.swmansion.gesturehandler.react.RNGestureHandlerButtonViewManager
18
+ import com.swmansion.gesturehandler.react.RNGestureHandlerRootHelper
18
19
  import com.swmansion.gesturehandler.react.events.eventbuilders.NativeGestureHandlerEventDataBuilder
19
20
  import com.swmansion.gesturehandler.react.isScreenReaderOn
20
21
 
21
22
  class NativeViewGestureHandler : GestureHandler() {
23
+ override val isContinuous = true
24
+
22
25
  private var shouldActivateOnStart = false
23
26
 
24
27
  /**
@@ -29,8 +32,19 @@ class NativeViewGestureHandler : GestureHandler() {
29
32
  var disallowInterruption = false
30
33
  private set
31
34
 
35
+ /**
36
+ * Composes with [disallowInterruption]. When both are `true`, the handler still resists
37
+ * discrete gesture peers but yields to continuous peers. No-op when [disallowInterruption] is `false`.
38
+ */
39
+ var yieldsToContinuousGestures = false
40
+ private set
41
+
32
42
  private var hook: NativeViewGestureHandlerHook = defaultHook
33
43
 
44
+ private data class ActiveUpdateSnapshot(val pointerInside: Boolean, val numberOfPointers: Int, val pointerType: Int)
45
+
46
+ private var lastActiveUpdate: ActiveUpdateSnapshot? = null
47
+
34
48
  init {
35
49
  shouldCancelWhenOutside = true
36
50
  }
@@ -39,6 +53,7 @@ class NativeViewGestureHandler : GestureHandler() {
39
53
  super.resetConfig()
40
54
  shouldActivateOnStart = DEFAULT_SHOULD_ACTIVATE_ON_START
41
55
  disallowInterruption = DEFAULT_DISALLOW_INTERRUPTION
56
+ yieldsToContinuousGestures = DEFAULT_YIELDS_TO_CONTINUOUS_GESTURES
42
57
  shouldCancelWhenOutside = DEFAULT_SHOULD_CANCEL_WHEN_OUTSIDE
43
58
  }
44
59
 
@@ -57,12 +72,15 @@ class NativeViewGestureHandler : GestureHandler() {
57
72
  // For the `disallowInterruption` to work correctly we need to check the property when
58
73
  // accessed as a peer, because simultaneous recognizers can be set on either side of the
59
74
  // connection.
60
- if (handler.state == STATE_ACTIVE && handler.disallowInterruption) {
75
+ if (handler.state == STATE_ACTIVE &&
76
+ handler.disallowInterruption &&
77
+ !handler.yieldsToContinuousGestures
78
+ ) {
61
79
  // other handler is active and it disallows interruption, we don't want to get into its way
62
80
  return false
63
81
  }
64
82
  }
65
- val canBeInterrupted = !disallowInterruption
83
+ val canBeInterrupted = canBeInterruptedBy(handler)
66
84
  val otherState = handler.state
67
85
  return if (state == STATE_ACTIVE && otherState == STATE_ACTIVE && canBeInterrupted) {
68
86
  // if both handlers are active and the current handler can be interrupted it we return `false`
@@ -77,7 +95,17 @@ class NativeViewGestureHandler : GestureHandler() {
77
95
  // otherwise we can only return `true` if already in an active state
78
96
  }
79
97
 
80
- override fun shouldBeCancelledBy(handler: GestureHandler): Boolean = !disallowInterruption
98
+ override fun shouldBeCancelledBy(handler: GestureHandler): Boolean = canBeInterruptedBy(handler)
99
+
100
+ /**
101
+ * Whether this handler permits [other] to take over the touch stream, given its
102
+ * `disallowInterruption` and `yieldsToContinuousGestures` configuration.
103
+ */
104
+ fun canBeInterruptedBy(other: GestureHandler): Boolean = !disallowInterruption ||
105
+ (yieldsToContinuousGestures && other.isContinuous)
106
+
107
+ override fun shouldBeginWithRecordedHandlers(recorded: List<GestureHandler>): Boolean =
108
+ hook.shouldBeginWithRecordedHandlers(recorded, this)
81
109
 
82
110
  override fun onPrepare() {
83
111
  when (val view = view) {
@@ -163,6 +191,21 @@ class NativeViewGestureHandler : GestureHandler() {
163
191
 
164
192
  override fun onReset() {
165
193
  this.hook = defaultHook
194
+ lastActiveUpdate = null
195
+ }
196
+
197
+ override fun dispatchHandlerUpdate(event: MotionEvent) {
198
+ val snapshot = ActiveUpdateSnapshot(isWithinBounds, numberOfPointers, pointerType)
199
+ if (snapshot == lastActiveUpdate) {
200
+ return
201
+ }
202
+ lastActiveUpdate = snapshot
203
+ super.dispatchHandlerUpdate(event)
204
+ }
205
+
206
+ override fun dispatchStateChange(newState: Int, prevState: Int) {
207
+ lastActiveUpdate = null
208
+ super.dispatchStateChange(newState, prevState)
166
209
  }
167
210
 
168
211
  override fun wantsToAttachDirectlyToView() = true
@@ -181,6 +224,9 @@ class NativeViewGestureHandler : GestureHandler() {
181
224
  if (config.hasKey(KEY_DISALLOW_INTERRUPTION)) {
182
225
  handler.disallowInterruption = config.getBoolean(KEY_DISALLOW_INTERRUPTION)
183
226
  }
227
+ if (config.hasKey(KEY_YIELDS_TO_CONTINUOUS_GESTURES)) {
228
+ handler.yieldsToContinuousGestures = config.getBoolean(KEY_YIELDS_TO_CONTINUOUS_GESTURES)
229
+ }
184
230
  }
185
231
 
186
232
  override fun createEventBuilder(handler: NativeViewGestureHandler) = NativeGestureHandlerEventDataBuilder(handler)
@@ -188,6 +234,7 @@ class NativeViewGestureHandler : GestureHandler() {
188
234
  companion object {
189
235
  private const val KEY_SHOULD_ACTIVATE_ON_START = "shouldActivateOnStart"
190
236
  private const val KEY_DISALLOW_INTERRUPTION = "disallowInterruption"
237
+ private const val KEY_YIELDS_TO_CONTINUOUS_GESTURES = "yieldsToContinuousGestures"
191
238
  }
192
239
  }
193
240
 
@@ -195,6 +242,7 @@ class NativeViewGestureHandler : GestureHandler() {
195
242
  private const val DEFAULT_SHOULD_CANCEL_WHEN_OUTSIDE = true
196
243
  private const val DEFAULT_SHOULD_ACTIVATE_ON_START = false
197
244
  private const val DEFAULT_DISALLOW_INTERRUPTION = false
245
+ private const val DEFAULT_YIELDS_TO_CONTINUOUS_GESTURES = false
198
246
 
199
247
  private fun tryIntercept(view: View, event: MotionEvent) = view is ViewGroup && view.onInterceptTouchEvent(event)
200
248
 
@@ -252,6 +300,16 @@ class NativeViewGestureHandler : GestureHandler() {
252
300
  */
253
301
  fun shouldCancelRootViewGestureHandlerIfNecessary() = false
254
302
 
303
+ /**
304
+ * Called when the handler is being recorded by the orchestrator, before any pointer events
305
+ * are delivered. Returning `false` cancels the handler immediately.
306
+ *
307
+ * @param recorded handlers already recorded for the current touch
308
+ * @param handler the handler being recorded
309
+ */
310
+ fun shouldBeginWithRecordedHandlers(recorded: List<GestureHandler>, handler: NativeViewGestureHandler): Boolean =
311
+ true
312
+
255
313
  /**
256
314
  * Passes the event down to the underlying view using the correct method.
257
315
  */
@@ -285,11 +343,14 @@ class NativeViewGestureHandler : GestureHandler() {
285
343
  }
286
344
  }
287
345
 
288
- // recognize alongside every handler besides RootViewGestureHandler, which is a private inner class
289
- // of RNGestureHandlerRootHelper so no explicit type checks, but its tag is always negative
346
+ // recognize alongside every handler besides RootViewGestureHandler;
290
347
  // also if other handler is NativeViewGestureHandler then don't override the default implementation
291
- override fun shouldRecognizeSimultaneously(handler: GestureHandler) =
292
- handler.tag > 0 && handler !is NativeViewGestureHandler
348
+ override fun shouldRecognizeSimultaneously(handler: GestureHandler): Boolean? =
349
+ if (handler is NativeViewGestureHandler) {
350
+ null
351
+ } else {
352
+ handler !is RNGestureHandlerRootHelper.RootViewGestureHandler
353
+ }
293
354
 
294
355
  override fun wantsToHandleEventBeforeActivation() = true
295
356
 
@@ -0,0 +1,6 @@
1
+ package com.swmansion.gesturehandler.core
2
+
3
+ interface OnJSResponderCancelListener {
4
+ fun onCancelJSResponderRequested(handler: GestureHandler)
5
+ fun onCancelJSResponderReleased(handler: GestureHandler)
6
+ }
@@ -13,6 +13,8 @@ import com.swmansion.gesturehandler.core.GestureUtils.getLastPointerY
13
13
  import com.swmansion.gesturehandler.react.events.eventbuilders.PanGestureHandlerEventDataBuilder
14
14
 
15
15
  class PanGestureHandler(context: Context?) : GestureHandler() {
16
+ override val isContinuous = true
17
+
16
18
  var velocityX = 0f
17
19
  private set
18
20
  var velocityY = 0f
@@ -8,6 +8,8 @@ import com.swmansion.gesturehandler.react.events.eventbuilders.PinchGestureHandl
8
8
  import kotlin.math.abs
9
9
 
10
10
  class PinchGestureHandler : GestureHandler() {
11
+ override val isContinuous = true
12
+
11
13
  var scale = 0.0
12
14
  private set
13
15
  var velocity = 0.0
@@ -68,9 +70,17 @@ class PinchGestureHandler : GestureHandler() {
68
70
  }
69
71
 
70
72
  if (state == STATE_UNDETERMINED) {
71
- initialize(event, sourceEvent)
72
- begin()
73
+ when (sourceEvent.actionMasked) {
74
+ MotionEvent.ACTION_DOWN -> {
75
+ initialize(event, sourceEvent)
76
+ }
77
+
78
+ MotionEvent.ACTION_POINTER_DOWN -> {
79
+ begin()
80
+ }
81
+ }
73
82
  }
83
+
74
84
  scaleGestureDetector?.onTouchEvent(sourceEvent)
75
85
  scaleGestureDetector?.let {
76
86
  val point = transformPoint(PointF(it.focusX, it.focusY))
@@ -79,10 +89,10 @@ class PinchGestureHandler : GestureHandler() {
79
89
  }
80
90
 
81
91
  if (sourceEvent.actionMasked == MotionEvent.ACTION_UP) {
82
- if (state == STATE_ACTIVE) {
83
- end()
84
- } else {
85
- fail()
92
+ when (state) {
93
+ STATE_UNDETERMINED -> cancel()
94
+ STATE_ACTIVE -> end()
95
+ else -> fail()
86
96
  }
87
97
  }
88
98
  }
@@ -8,6 +8,8 @@ import com.swmansion.gesturehandler.react.events.eventbuilders.RotationGestureHa
8
8
  import kotlin.math.abs
9
9
 
10
10
  class RotationGestureHandler : GestureHandler() {
11
+ override val isContinuous = true
12
+
11
13
  private var rotationGestureDetector: RotationGestureDetector? = null
12
14
  var rotation = 0.0
13
15
  private set
@@ -59,9 +61,17 @@ class RotationGestureHandler : GestureHandler() {
59
61
  }
60
62
 
61
63
  if (state == STATE_UNDETERMINED) {
62
- initialize(event, sourceEvent)
63
- begin()
64
+ when (sourceEvent.actionMasked) {
65
+ MotionEvent.ACTION_DOWN -> {
66
+ initialize(event, sourceEvent)
67
+ }
68
+
69
+ MotionEvent.ACTION_POINTER_DOWN -> {
70
+ begin()
71
+ }
72
+ }
64
73
  }
74
+
65
75
  rotationGestureDetector?.onTouchEvent(sourceEvent)
66
76
  rotationGestureDetector?.let {
67
77
  val point = transformPoint(PointF(it.anchorX, it.anchorY))
@@ -71,8 +81,11 @@ class RotationGestureHandler : GestureHandler() {
71
81
 
72
82
  // ACTION_UP is already handled in rotationGestureDetector.onTouchEvent (and effectively in onRotationEnd)
73
83
  // if more than one pointer was used
74
- if (sourceEvent.actionMasked == MotionEvent.ACTION_UP && state == STATE_BEGAN) {
75
- fail()
84
+ if (sourceEvent.actionMasked == MotionEvent.ACTION_UP) {
85
+ when (state) {
86
+ STATE_UNDETERMINED -> cancel()
87
+ STATE_BEGAN -> fail()
88
+ }
76
89
  }
77
90
  }
78
91
 
@@ -5,6 +5,5 @@ import android.view.ViewGroup
5
5
 
6
6
  interface ViewConfigurationHelper {
7
7
  fun getPointerEventsConfigForView(view: View): PointerEventsConfig
8
- fun getChildInDrawingOrderAtIndex(parent: ViewGroup, index: Int): View
9
8
  fun isViewClippingChildren(view: ViewGroup): Boolean
10
9
  }
@@ -1,6 +1,7 @@
1
1
  package com.swmansion.gesturehandler.react
2
2
 
3
3
  import android.content.Context
4
+ import android.view.Display
4
5
  import android.view.MotionEvent
5
6
  import android.view.accessibility.AccessibilityManager
6
7
  import com.facebook.react.bridge.ReactContext
@@ -15,3 +16,23 @@ fun Context.isScreenReaderOn() =
15
16
  fun MotionEvent.isHoverAction(): Boolean = action == MotionEvent.ACTION_HOVER_MOVE ||
16
17
  action == MotionEvent.ACTION_HOVER_ENTER ||
17
18
  action == MotionEvent.ACTION_HOVER_EXIT
19
+
20
+ val Display.minimumFrameTime: Float
21
+ get() {
22
+ val supportedModes = this.supportedModes
23
+ var maxRefreshRate = 0f
24
+
25
+ supportedModes.forEach { mode ->
26
+ if (mode.refreshRate > maxRefreshRate) {
27
+ maxRefreshRate = mode.refreshRate
28
+ }
29
+ }
30
+
31
+ val effectiveRefreshRate = when {
32
+ maxRefreshRate > 0f -> maxRefreshRate
33
+ refreshRate > 0f -> refreshRate
34
+ else -> 60f
35
+ }
36
+
37
+ return 1000.0f / effectiveRefreshRate
38
+ }