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

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 (310) 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 +22 -4
  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 +63 -6
  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/RNGestureHandlerButtonViewManager.kt +47 -6
  12. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.kt +1 -1
  13. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +18 -8
  14. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt +15 -4
  15. package/android/src/main/java/com/swmansion/gesturehandler/react/RNViewConfigurationHelper.kt +0 -6
  16. package/apple/Handlers/RNForceTouchHandler.m +1 -1
  17. package/apple/Handlers/RNHoverHandler.m +11 -11
  18. package/apple/Handlers/RNLongPressHandler.m +2 -2
  19. package/apple/Handlers/RNManualHandler.m +5 -0
  20. package/apple/Handlers/RNNativeViewHandler.mm +114 -53
  21. package/apple/Handlers/RNPanHandler.m +7 -3
  22. package/apple/Handlers/RNPinchHandler.m +9 -3
  23. package/apple/Handlers/RNRotationHandler.m +7 -2
  24. package/apple/Handlers/RNTapHandler.m +1 -1
  25. package/apple/RNGestureHandler.h +18 -0
  26. package/apple/RNGestureHandler.mm +32 -6
  27. package/apple/RNGestureHandlerButton.h +8 -0
  28. package/apple/RNGestureHandlerButton.mm +102 -11
  29. package/apple/RNGestureHandlerButtonComponentView.mm +85 -4
  30. package/apple/RNGestureHandlerRegistry.h +0 -1
  31. package/apple/RNRootViewGestureRecognizer.m +4 -15
  32. package/lib/module/components/GestureButtons.js +8 -8
  33. package/lib/module/components/GestureButtons.js.map +1 -1
  34. package/lib/module/components/GestureHandlerButton.web.js +51 -9
  35. package/lib/module/components/GestureHandlerButton.web.js.map +1 -1
  36. package/lib/module/components/Pressable/Pressable.js +1 -1
  37. package/lib/module/components/Pressable/Pressable.js.map +1 -1
  38. package/lib/module/components/Pressable/stateDefinitions.js +2 -0
  39. package/lib/module/components/Pressable/stateDefinitions.js.map +1 -1
  40. package/lib/module/components/touchables/GenericTouchable.js +2 -6
  41. package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
  42. package/lib/module/handlers/gestures/GestureDetector/utils.js +11 -1
  43. package/lib/module/handlers/gestures/GestureDetector/utils.js.map +1 -1
  44. package/lib/module/handlers/gestures/flingGesture.js +8 -0
  45. package/lib/module/handlers/gestures/flingGesture.js.map +1 -1
  46. package/lib/module/handlers/gestures/forceTouchGesture.js +3 -3
  47. package/lib/module/handlers/gestures/gesture.js +8 -0
  48. package/lib/module/handlers/gestures/gesture.js.map +1 -1
  49. package/lib/module/handlers/gestures/gestureComposition.js +28 -0
  50. package/lib/module/handlers/gestures/gestureComposition.js.map +1 -1
  51. package/lib/module/handlers/gestures/gestureObjects.js +27 -1
  52. package/lib/module/handlers/gestures/gestureObjects.js.map +1 -1
  53. package/lib/module/handlers/gestures/gestureStateManager.js +9 -0
  54. package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -1
  55. package/lib/module/handlers/gestures/hoverGesture.js +8 -0
  56. package/lib/module/handlers/gestures/hoverGesture.js.map +1 -1
  57. package/lib/module/handlers/gestures/longPressGesture.js +8 -0
  58. package/lib/module/handlers/gestures/longPressGesture.js.map +1 -1
  59. package/lib/module/handlers/gestures/manualGesture.js +8 -0
  60. package/lib/module/handlers/gestures/manualGesture.js.map +1 -1
  61. package/lib/module/handlers/gestures/nativeGesture.js +8 -0
  62. package/lib/module/handlers/gestures/nativeGesture.js.map +1 -1
  63. package/lib/module/handlers/gestures/panGesture.js +13 -0
  64. package/lib/module/handlers/gestures/panGesture.js.map +1 -1
  65. package/lib/module/handlers/gestures/pinchGesture.js +13 -0
  66. package/lib/module/handlers/gestures/pinchGesture.js.map +1 -1
  67. package/lib/module/handlers/gestures/rotationGesture.js +8 -0
  68. package/lib/module/handlers/gestures/rotationGesture.js.map +1 -1
  69. package/lib/module/handlers/gestures/tapGesture.js +8 -0
  70. package/lib/module/handlers/gestures/tapGesture.js.map +1 -1
  71. package/lib/module/v3/components/GestureButtons.js +4 -4
  72. package/lib/module/v3/components/GestureButtons.js.map +1 -1
  73. package/lib/module/v3/components/Pressable.js +3 -2
  74. package/lib/module/v3/components/Pressable.js.map +1 -1
  75. package/lib/module/v3/components/Touchable/Touchable.js +67 -29
  76. package/lib/module/v3/components/Touchable/Touchable.js.map +1 -1
  77. package/lib/module/v3/detectors/HostGestureDetector.web.js +2 -0
  78. package/lib/module/v3/detectors/HostGestureDetector.web.js.map +1 -1
  79. package/lib/module/v3/detectors/VirtualDetector/VirtualDetector.js +2 -0
  80. package/lib/module/v3/detectors/VirtualDetector/VirtualDetector.js.map +1 -1
  81. package/lib/module/v3/detectors/useNativeGestureRole.js +6 -0
  82. package/lib/module/v3/detectors/useNativeGestureRole.js.map +1 -0
  83. package/lib/module/v3/detectors/useNativeGestureRole.web.js +27 -0
  84. package/lib/module/v3/detectors/useNativeGestureRole.web.js.map +1 -0
  85. package/lib/module/v3/hooks/callbacks/useReanimatedEventHandler.js +17 -2
  86. package/lib/module/v3/hooks/callbacks/useReanimatedEventHandler.js.map +1 -1
  87. package/lib/module/v3/hooks/gestures/fling/useFlingGesture.js +2 -1
  88. package/lib/module/v3/hooks/gestures/fling/useFlingGesture.js.map +1 -1
  89. package/lib/module/v3/hooks/gestures/hover/useHoverGesture.js +2 -1
  90. package/lib/module/v3/hooks/gestures/hover/useHoverGesture.js.map +1 -1
  91. package/lib/module/v3/hooks/gestures/longPress/useLongPressGesture.js +2 -1
  92. package/lib/module/v3/hooks/gestures/longPress/useLongPressGesture.js.map +1 -1
  93. package/lib/module/v3/hooks/gestures/manual/useManualGesture.js +2 -1
  94. package/lib/module/v3/hooks/gestures/manual/useManualGesture.js.map +1 -1
  95. package/lib/module/v3/hooks/gestures/native/NativeTypes.js +1 -1
  96. package/lib/module/v3/hooks/gestures/native/NativeTypes.js.map +1 -1
  97. package/lib/module/v3/hooks/gestures/native/useNativeGesture.js +2 -1
  98. package/lib/module/v3/hooks/gestures/native/useNativeGesture.js.map +1 -1
  99. package/lib/module/v3/hooks/gestures/pan/usePanGesture.js +2 -1
  100. package/lib/module/v3/hooks/gestures/pan/usePanGesture.js.map +1 -1
  101. package/lib/module/v3/hooks/gestures/pinch/usePinchGesture.js +2 -1
  102. package/lib/module/v3/hooks/gestures/pinch/usePinchGesture.js.map +1 -1
  103. package/lib/module/v3/hooks/gestures/rotation/useRotationGesture.js +2 -1
  104. package/lib/module/v3/hooks/gestures/rotation/useRotationGesture.js.map +1 -1
  105. package/lib/module/v3/hooks/gestures/tap/useTapGesture.js +2 -1
  106. package/lib/module/v3/hooks/gestures/tap/useTapGesture.js.map +1 -1
  107. package/lib/module/v3/hooks/useGesture.js +1 -4
  108. package/lib/module/v3/hooks/useGesture.js.map +1 -1
  109. package/lib/module/v3/hooks/utils/configUtils.js +7 -3
  110. package/lib/module/v3/hooks/utils/configUtils.js.map +1 -1
  111. package/lib/module/v3/hooks/utils/index.js +1 -1
  112. package/lib/module/v3/hooks/utils/index.js.map +1 -1
  113. package/lib/module/v3/hooks/utils/propsWhiteList.js +1 -1
  114. package/lib/module/v3/hooks/utils/propsWhiteList.js.map +1 -1
  115. package/lib/module/web/constants.js +1 -0
  116. package/lib/module/web/constants.js.map +1 -1
  117. package/lib/module/web/detectors/RotationGestureDetector.js +18 -5
  118. package/lib/module/web/detectors/RotationGestureDetector.js.map +1 -1
  119. package/lib/module/web/detectors/ScaleGestureDetector.js +9 -1
  120. package/lib/module/web/detectors/ScaleGestureDetector.js.map +1 -1
  121. package/lib/module/web/handlers/GestureHandler.js +25 -5
  122. package/lib/module/web/handlers/GestureHandler.js.map +1 -1
  123. package/lib/module/web/handlers/HoverGestureHandler.js +1 -4
  124. package/lib/module/web/handlers/HoverGestureHandler.js.map +1 -1
  125. package/lib/module/web/handlers/ManualGestureHandler.js +1 -0
  126. package/lib/module/web/handlers/ManualGestureHandler.js.map +1 -1
  127. package/lib/module/web/handlers/NativeViewGestureHandler.js +65 -17
  128. package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
  129. package/lib/module/web/handlers/PanGestureHandler.js +1 -0
  130. package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
  131. package/lib/module/web/handlers/PinchGestureHandler.js +4 -6
  132. package/lib/module/web/handlers/PinchGestureHandler.js.map +1 -1
  133. package/lib/module/web/handlers/RotationGestureHandler.js +4 -3
  134. package/lib/module/web/handlers/RotationGestureHandler.js.map +1 -1
  135. package/lib/module/web/interfaces.js +6 -0
  136. package/lib/module/web/interfaces.js.map +1 -1
  137. package/lib/module/web/tools/GestureHandlerOrchestrator.js +8 -2
  138. package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
  139. package/lib/module/web/tools/GestureLifecycleEvents.js +10 -0
  140. package/lib/module/web/tools/GestureLifecycleEvents.js.map +1 -0
  141. package/lib/module/web/tools/PointerEventManager.js +9 -0
  142. package/lib/module/web/tools/PointerEventManager.js.map +1 -1
  143. package/lib/typescript/components/GestureButtons.d.ts.map +1 -1
  144. package/lib/typescript/components/GestureHandlerButton.web.d.ts +5 -1
  145. package/lib/typescript/components/GestureHandlerButton.web.d.ts.map +1 -1
  146. package/lib/typescript/components/Pressable/Pressable.d.ts.map +1 -1
  147. package/lib/typescript/components/Pressable/stateDefinitions.d.ts.map +1 -1
  148. package/lib/typescript/components/touchables/GenericTouchable.d.ts.map +1 -1
  149. package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts.map +1 -1
  150. package/lib/typescript/handlers/gestures/flingGesture.d.ts +6 -0
  151. package/lib/typescript/handlers/gestures/flingGesture.d.ts.map +1 -1
  152. package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +3 -3
  153. package/lib/typescript/handlers/gestures/gesture.d.ts +6 -0
  154. package/lib/typescript/handlers/gestures/gesture.d.ts.map +1 -1
  155. package/lib/typescript/handlers/gestures/gestureComposition.d.ts +21 -0
  156. package/lib/typescript/handlers/gestures/gestureComposition.d.ts.map +1 -1
  157. package/lib/typescript/handlers/gestures/gestureObjects.d.ts +27 -1
  158. package/lib/typescript/handlers/gestures/gestureObjects.d.ts.map +1 -1
  159. package/lib/typescript/handlers/gestures/gestureStateManager.d.ts +6 -0
  160. package/lib/typescript/handlers/gestures/gestureStateManager.d.ts.map +1 -1
  161. package/lib/typescript/handlers/gestures/hoverGesture.d.ts +6 -0
  162. package/lib/typescript/handlers/gestures/hoverGesture.d.ts.map +1 -1
  163. package/lib/typescript/handlers/gestures/longPressGesture.d.ts +6 -0
  164. package/lib/typescript/handlers/gestures/longPressGesture.d.ts.map +1 -1
  165. package/lib/typescript/handlers/gestures/manualGesture.d.ts +6 -0
  166. package/lib/typescript/handlers/gestures/manualGesture.d.ts.map +1 -1
  167. package/lib/typescript/handlers/gestures/nativeGesture.d.ts +6 -0
  168. package/lib/typescript/handlers/gestures/nativeGesture.d.ts.map +1 -1
  169. package/lib/typescript/handlers/gestures/panGesture.d.ts +9 -0
  170. package/lib/typescript/handlers/gestures/panGesture.d.ts.map +1 -1
  171. package/lib/typescript/handlers/gestures/pinchGesture.d.ts +9 -0
  172. package/lib/typescript/handlers/gestures/pinchGesture.d.ts.map +1 -1
  173. package/lib/typescript/handlers/gestures/rotationGesture.d.ts +6 -0
  174. package/lib/typescript/handlers/gestures/rotationGesture.d.ts.map +1 -1
  175. package/lib/typescript/handlers/gestures/tapGesture.d.ts +6 -0
  176. package/lib/typescript/handlers/gestures/tapGesture.d.ts.map +1 -1
  177. package/lib/typescript/v3/components/GestureButtons.d.ts +1 -0
  178. package/lib/typescript/v3/components/GestureButtons.d.ts.map +1 -1
  179. package/lib/typescript/v3/components/GestureComponents.d.ts +3 -0
  180. package/lib/typescript/v3/components/GestureComponents.d.ts.map +1 -1
  181. package/lib/typescript/v3/components/GestureComponents.web.d.ts +4 -0
  182. package/lib/typescript/v3/components/GestureComponents.web.d.ts.map +1 -1
  183. package/lib/typescript/v3/components/Pressable.d.ts.map +1 -1
  184. package/lib/typescript/v3/components/Touchable/Touchable.d.ts.map +1 -1
  185. package/lib/typescript/v3/components/Touchable/TouchableProps.d.ts +10 -1
  186. package/lib/typescript/v3/components/Touchable/TouchableProps.d.ts.map +1 -1
  187. package/lib/typescript/v3/detectors/HostGestureDetector.web.d.ts +1 -1
  188. package/lib/typescript/v3/detectors/HostGestureDetector.web.d.ts.map +1 -1
  189. package/lib/typescript/v3/detectors/VirtualDetector/VirtualDetector.d.ts.map +1 -1
  190. package/lib/typescript/v3/detectors/useNativeGestureRole.d.ts +3 -0
  191. package/lib/typescript/v3/detectors/useNativeGestureRole.d.ts.map +1 -0
  192. package/lib/typescript/v3/detectors/useNativeGestureRole.web.d.ts +3 -0
  193. package/lib/typescript/v3/detectors/useNativeGestureRole.web.d.ts.map +1 -0
  194. package/lib/typescript/v3/hooks/callbacks/useReanimatedEventHandler.d.ts.map +1 -1
  195. package/lib/typescript/v3/hooks/gestures/fling/useFlingGesture.d.ts +1 -1
  196. package/lib/typescript/v3/hooks/gestures/fling/useFlingGesture.d.ts.map +1 -1
  197. package/lib/typescript/v3/hooks/gestures/hover/useHoverGesture.d.ts +1 -1
  198. package/lib/typescript/v3/hooks/gestures/hover/useHoverGesture.d.ts.map +1 -1
  199. package/lib/typescript/v3/hooks/gestures/longPress/useLongPressGesture.d.ts +1 -1
  200. package/lib/typescript/v3/hooks/gestures/longPress/useLongPressGesture.d.ts.map +1 -1
  201. package/lib/typescript/v3/hooks/gestures/manual/useManualGesture.d.ts +1 -1
  202. package/lib/typescript/v3/hooks/gestures/manual/useManualGesture.d.ts.map +1 -1
  203. package/lib/typescript/v3/hooks/gestures/native/NativeTypes.d.ts +7 -0
  204. package/lib/typescript/v3/hooks/gestures/native/NativeTypes.d.ts.map +1 -1
  205. package/lib/typescript/v3/hooks/gestures/native/useNativeGesture.d.ts +1 -1
  206. package/lib/typescript/v3/hooks/gestures/native/useNativeGesture.d.ts.map +1 -1
  207. package/lib/typescript/v3/hooks/gestures/pan/usePanGesture.d.ts +1 -1
  208. package/lib/typescript/v3/hooks/gestures/pan/usePanGesture.d.ts.map +1 -1
  209. package/lib/typescript/v3/hooks/gestures/pinch/usePinchGesture.d.ts +1 -1
  210. package/lib/typescript/v3/hooks/gestures/pinch/usePinchGesture.d.ts.map +1 -1
  211. package/lib/typescript/v3/hooks/gestures/rotation/useRotationGesture.d.ts +1 -1
  212. package/lib/typescript/v3/hooks/gestures/rotation/useRotationGesture.d.ts.map +1 -1
  213. package/lib/typescript/v3/hooks/gestures/tap/useTapGesture.d.ts +1 -1
  214. package/lib/typescript/v3/hooks/gestures/tap/useTapGesture.d.ts.map +1 -1
  215. package/lib/typescript/v3/hooks/useGesture.d.ts.map +1 -1
  216. package/lib/typescript/v3/hooks/utils/configUtils.d.ts +2 -2
  217. package/lib/typescript/v3/hooks/utils/configUtils.d.ts.map +1 -1
  218. package/lib/typescript/v3/hooks/utils/index.d.ts +1 -1
  219. package/lib/typescript/v3/hooks/utils/index.d.ts.map +1 -1
  220. package/lib/typescript/v3/hooks/utils/propsWhiteList.d.ts +2 -2
  221. package/lib/typescript/v3/hooks/utils/propsWhiteList.d.ts.map +1 -1
  222. package/lib/typescript/v3/types/ConfigTypes.d.ts +1 -0
  223. package/lib/typescript/v3/types/ConfigTypes.d.ts.map +1 -1
  224. package/lib/typescript/web/constants.d.ts +1 -0
  225. package/lib/typescript/web/constants.d.ts.map +1 -1
  226. package/lib/typescript/web/detectors/RotationGestureDetector.d.ts.map +1 -1
  227. package/lib/typescript/web/detectors/ScaleGestureDetector.d.ts.map +1 -1
  228. package/lib/typescript/web/handlers/GestureHandler.d.ts +8 -2
  229. package/lib/typescript/web/handlers/GestureHandler.d.ts.map +1 -1
  230. package/lib/typescript/web/handlers/HoverGestureHandler.d.ts +1 -1
  231. package/lib/typescript/web/handlers/HoverGestureHandler.d.ts.map +1 -1
  232. package/lib/typescript/web/handlers/IGestureHandler.d.ts +2 -0
  233. package/lib/typescript/web/handlers/IGestureHandler.d.ts.map +1 -1
  234. package/lib/typescript/web/handlers/ManualGestureHandler.d.ts +1 -0
  235. package/lib/typescript/web/handlers/ManualGestureHandler.d.ts.map +1 -1
  236. package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +13 -3
  237. package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts.map +1 -1
  238. package/lib/typescript/web/handlers/PanGestureHandler.d.ts +1 -0
  239. package/lib/typescript/web/handlers/PanGestureHandler.d.ts.map +1 -1
  240. package/lib/typescript/web/handlers/PinchGestureHandler.d.ts +1 -0
  241. package/lib/typescript/web/handlers/PinchGestureHandler.d.ts.map +1 -1
  242. package/lib/typescript/web/handlers/RotationGestureHandler.d.ts +1 -0
  243. package/lib/typescript/web/handlers/RotationGestureHandler.d.ts.map +1 -1
  244. package/lib/typescript/web/interfaces.d.ts +6 -0
  245. package/lib/typescript/web/interfaces.d.ts.map +1 -1
  246. package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts +1 -0
  247. package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts.map +1 -1
  248. package/lib/typescript/web/tools/GestureLifecycleEvents.d.ts +7 -0
  249. package/lib/typescript/web/tools/GestureLifecycleEvents.d.ts.map +1 -0
  250. package/lib/typescript/web/tools/PointerEventManager.d.ts.map +1 -1
  251. package/package.json +1 -1
  252. package/src/components/GestureButtons.tsx +10 -9
  253. package/src/components/GestureHandlerButton.web.tsx +94 -26
  254. package/src/components/Pressable/Pressable.tsx +2 -1
  255. package/src/components/Pressable/stateDefinitions.ts +3 -0
  256. package/src/components/touchables/GenericTouchable.tsx +2 -5
  257. package/src/handlers/gestures/GestureDetector/utils.ts +11 -1
  258. package/src/handlers/gestures/flingGesture.ts +6 -0
  259. package/src/handlers/gestures/forceTouchGesture.ts +3 -3
  260. package/src/handlers/gestures/gesture.ts +6 -0
  261. package/src/handlers/gestures/gestureComposition.ts +21 -0
  262. package/src/handlers/gestures/gestureObjects.ts +27 -1
  263. package/src/handlers/gestures/gestureStateManager.ts +6 -0
  264. package/src/handlers/gestures/hoverGesture.ts +6 -0
  265. package/src/handlers/gestures/longPressGesture.ts +6 -0
  266. package/src/handlers/gestures/manualGesture.ts +6 -0
  267. package/src/handlers/gestures/nativeGesture.ts +6 -0
  268. package/src/handlers/gestures/panGesture.ts +9 -0
  269. package/src/handlers/gestures/pinchGesture.ts +9 -0
  270. package/src/handlers/gestures/rotationGesture.ts +6 -0
  271. package/src/handlers/gestures/tapGesture.ts +6 -0
  272. package/src/v3/components/GestureButtons.tsx +5 -5
  273. package/src/v3/components/Pressable.tsx +2 -1
  274. package/src/v3/components/Touchable/Touchable.tsx +80 -47
  275. package/src/v3/components/Touchable/TouchableProps.ts +15 -1
  276. package/src/v3/detectors/HostGestureDetector.web.tsx +4 -1
  277. package/src/v3/detectors/VirtualDetector/VirtualDetector.tsx +3 -0
  278. package/src/v3/detectors/useNativeGestureRole.ts +8 -0
  279. package/src/v3/detectors/useNativeGestureRole.web.ts +42 -0
  280. package/src/v3/hooks/callbacks/useReanimatedEventHandler.ts +23 -7
  281. package/src/v3/hooks/gestures/fling/useFlingGesture.ts +5 -1
  282. package/src/v3/hooks/gestures/hover/useHoverGesture.ts +5 -1
  283. package/src/v3/hooks/gestures/longPress/useLongPressGesture.ts +3 -1
  284. package/src/v3/hooks/gestures/manual/useManualGesture.ts +5 -1
  285. package/src/v3/hooks/gestures/native/NativeTypes.ts +13 -1
  286. package/src/v3/hooks/gestures/native/useNativeGesture.ts +5 -1
  287. package/src/v3/hooks/gestures/pan/usePanGesture.ts +5 -1
  288. package/src/v3/hooks/gestures/pinch/usePinchGesture.ts +5 -1
  289. package/src/v3/hooks/gestures/rotation/useRotationGesture.ts +3 -1
  290. package/src/v3/hooks/gestures/tap/useTapGesture.ts +5 -1
  291. package/src/v3/hooks/useGesture.ts +0 -4
  292. package/src/v3/hooks/utils/configUtils.ts +16 -5
  293. package/src/v3/hooks/utils/index.ts +0 -1
  294. package/src/v3/hooks/utils/propsWhiteList.ts +1 -0
  295. package/src/v3/types/ConfigTypes.ts +1 -0
  296. package/src/web/constants.ts +1 -0
  297. package/src/web/detectors/RotationGestureDetector.ts +19 -5
  298. package/src/web/detectors/ScaleGestureDetector.ts +9 -3
  299. package/src/web/handlers/GestureHandler.ts +36 -6
  300. package/src/web/handlers/HoverGestureHandler.ts +2 -5
  301. package/src/web/handlers/IGestureHandler.ts +2 -0
  302. package/src/web/handlers/ManualGestureHandler.ts +2 -0
  303. package/src/web/handlers/NativeViewGestureHandler.ts +122 -19
  304. package/src/web/handlers/PanGestureHandler.ts +2 -0
  305. package/src/web/handlers/PinchGestureHandler.ts +5 -7
  306. package/src/web/handlers/RotationGestureHandler.ts +5 -5
  307. package/src/web/interfaces.ts +7 -0
  308. package/src/web/tools/GestureHandlerOrchestrator.ts +11 -3
  309. package/src/web/tools/GestureLifecycleEvents.ts +14 -0
  310. package/src/web/tools/PointerEventManager.ts +12 -0
@@ -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)
@@ -448,11 +461,16 @@ class GestureHandlerOrchestrator(
448
461
  return
449
462
  }
450
463
 
451
- gestureHandlers.add(handler)
452
464
  handler.isActive = false
453
465
  handler.isAwaiting = false
454
466
  handler.activationIndex = Int.MAX_VALUE
455
467
  handler.prepare(view, this)
468
+
469
+ if (!handler.shouldBeginWithRecordedHandlers(gestureHandlers)) {
470
+ handler.cancel()
471
+ }
472
+
473
+ gestureHandlers.add(handler)
456
474
  }
457
475
 
458
476
  private fun isViewOverflowingParent(view: View): Boolean {
@@ -606,7 +624,7 @@ class GestureHandlerOrchestrator(
606
624
 
607
625
  val childrenCount = viewGroup.childCount
608
626
  for (i in childrenCount - 1 downTo 0) {
609
- val child = viewConfigHelper.getChildInDrawingOrderAtIndex(viewGroup, i)
627
+ val child = viewGroup.getChildAt(i)
610
628
  if (canReceiveEvents(child)) {
611
629
  val childPoint = tempPoint
612
630
  transformPointToChildViewCoords(coords[0], coords[1], viewGroup, child, childPoint)
@@ -659,7 +677,7 @@ class GestureHandlerOrchestrator(
659
677
  is ViewGroup -> {
660
678
  extractGestureHandlers(view, coords, pointerId, event).also { found ->
661
679
  // A child view is handling touch, also extract handlers attached to this view
662
- if (found) {
680
+ if (found || view is RNGestureHandlerDetectorView) {
663
681
  recordViewHandlersForPointer(view, coords, pointerId, event)
664
682
  }
665
683
  }
@@ -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,10 @@ 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
348
  override fun shouldRecognizeSimultaneously(handler: GestureHandler) =
292
- handler.tag > 0 && handler !is NativeViewGestureHandler
349
+ handler !is RNGestureHandlerRootHelper.RootViewGestureHandler && handler !is NativeViewGestureHandler
293
350
 
294
351
  override fun wantsToHandleEventBeforeActivation() = true
295
352
 
@@ -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
  }
@@ -42,6 +42,8 @@ import com.facebook.react.uimanager.style.BorderStyle
42
42
  import com.facebook.react.uimanager.style.LogicalEdge
43
43
  import com.facebook.react.viewmanagers.RNGestureHandlerButtonManagerDelegate
44
44
  import com.facebook.react.viewmanagers.RNGestureHandlerButtonManagerInterface
45
+ import com.swmansion.gesturehandler.core.GestureHandler
46
+ import com.swmansion.gesturehandler.core.HoverGestureHandler
45
47
  import com.swmansion.gesturehandler.core.NativeViewGestureHandler
46
48
  import com.swmansion.gesturehandler.react.RNGestureHandlerButtonViewManager.ButtonViewGroup
47
49
 
@@ -379,6 +381,7 @@ class RNGestureHandlerButtonViewManager :
379
381
  private var underlayDrawable: PaintDrawable? = null
380
382
  private var pressInTimestamp = 0L
381
383
  private var pendingPressOut: Runnable? = null
384
+ private var isPointerInsideBounds = false
382
385
 
383
386
  // When non-null the ripple is drawn in dispatchDraw (above background, below children).
384
387
  // When null the ripple lives on the foreground drawable instead.
@@ -481,7 +484,32 @@ class RNGestureHandlerButtonViewManager :
481
484
  if (lastEventTime != eventTime || lastAction != action || action == MotionEvent.ACTION_CANCEL) {
482
485
  lastEventTime = eventTime
483
486
  lastAction = action
484
- return super.onTouchEvent(event)
487
+ val handled = super.onTouchEvent(event)
488
+
489
+ // Replay press-in / press-out animations across drag transitions.
490
+ if (handled && canRespondToTouches()) {
491
+ when (event.actionMasked) {
492
+ MotionEvent.ACTION_DOWN, MotionEvent.ACTION_POINTER_DOWN -> isPointerInsideBounds = true
493
+ MotionEvent.ACTION_MOVE -> {
494
+ val inside = event.x >= 0 && event.y >= 0 && event.x < width && event.y < height
495
+ if (inside != isPointerInsideBounds) {
496
+ isPointerInsideBounds = inside
497
+ if (inside) {
498
+ // Re-establish View's pressed flag to restore ripple and the
499
+ // UP handler runs its normal release cleanup.
500
+ setPressed(true)
501
+ } else {
502
+ animatePressOut()
503
+ }
504
+ }
505
+ }
506
+ MotionEvent.ACTION_UP, MotionEvent.ACTION_POINTER_UP, MotionEvent.ACTION_CANCEL ->
507
+ isPointerInsideBounds =
508
+ false
509
+ }
510
+ }
511
+
512
+ return handled
485
513
  }
486
514
  return false
487
515
  }
@@ -712,6 +740,16 @@ class RNGestureHandlerButtonViewManager :
712
740
  isTouched = false
713
741
  }
714
742
 
743
+ override fun shouldBeginWithRecordedHandlers(
744
+ recorded: List<GestureHandler>,
745
+ handler: NativeViewGestureHandler,
746
+ ): Boolean = recorded.all {
747
+ it.shouldRecognizeSimultaneously(handler) ||
748
+ handler.shouldRecognizeSimultaneously(it) ||
749
+ it.view == this ||
750
+ it is HoverGestureHandler
751
+ }
752
+
715
753
  private fun tryFreeingResponder() {
716
754
  if (touchResponder === this) {
717
755
  touchResponder = null
@@ -719,6 +757,12 @@ class RNGestureHandlerButtonViewManager :
719
757
  }
720
758
  }
721
759
 
760
+ private fun canRespondToTouches(): Boolean = if (exclusive) {
761
+ touchResponder === this
762
+ } else {
763
+ !(touchResponder?.exclusive ?: false)
764
+ }
765
+
722
766
  private fun tryGrabbingResponder(): Boolean {
723
767
  if (isChildTouched()) {
724
768
  return false
@@ -728,11 +772,8 @@ class RNGestureHandlerButtonViewManager :
728
772
  touchResponder = this
729
773
  return true
730
774
  }
731
- return if (exclusive) {
732
- touchResponder === this
733
- } else {
734
- !(touchResponder?.exclusive ?: false)
735
- }
775
+
776
+ return canRespondToTouches()
736
777
  }
737
778
 
738
779
  private fun isChildTouched(children: Sequence<View> = this.children): Boolean {
@@ -50,7 +50,7 @@ class RNGestureHandlerInteractionManager : GestureHandlerInteractionController {
50
50
 
51
51
  override fun shouldHandlerBeCancelledBy(handler: GestureHandler, otherHandler: GestureHandler): Boolean {
52
52
  if (otherHandler is NativeViewGestureHandler) {
53
- return otherHandler.disallowInterruption
53
+ return !otherHandler.canBeInterruptedBy(handler)
54
54
  }
55
55
 
56
56
  if (otherHandler is RNGestureHandlerRootHelper.RootViewGestureHandler) {