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
@@ -12,6 +12,9 @@ function extendRelation(
12
12
  }
13
13
  }
14
14
 
15
+ /**
16
+ * @deprecated `ComposedGesture` is deprecated and will be removed in the future. Please use `useCompetingGestures` instead.
17
+ */
15
18
  export class ComposedGesture extends Gesture {
16
19
  protected gestures: Gesture[] = [];
17
20
  protected simultaneousGestures: GestureType[] = [];
@@ -70,6 +73,9 @@ export class ComposedGesture extends Gesture {
70
73
  }
71
74
  }
72
75
 
76
+ /**
77
+ * @deprecated `SimultaneousGesture` is deprecated and will be removed in the future. Please use `useSimultaneousGestures` instead.
78
+ */
73
79
  export class SimultaneousGesture extends ComposedGesture {
74
80
  override prepare() {
75
81
  // This piece of magic works something like this:
@@ -96,6 +102,9 @@ export class SimultaneousGesture extends ComposedGesture {
96
102
  }
97
103
  }
98
104
 
105
+ /**
106
+ * @deprecated `ExclusiveGesture` is deprecated and will be removed in the future. Please use `useExclusiveGestures` instead.
107
+ */
99
108
  export class ExclusiveGesture extends ComposedGesture {
100
109
  override prepare() {
101
110
  // Transforms the array of gestures into array of grouped raw (not composed) gestures
@@ -119,7 +128,19 @@ export class ExclusiveGesture extends ComposedGesture {
119
128
  }
120
129
  }
121
130
 
131
+ /**
132
+ * @deprecated `ComposedGestureType` is deprecated and will be removed in the future. Please use `ComposedGesture` instead.
133
+ */
122
134
  export type ComposedGestureType = InstanceType<typeof ComposedGesture>;
135
+ /**
136
+ * @deprecated `RaceGestureType` is deprecated and will be removed in the future. Please use `ComposedGesture` instead.
137
+ */
123
138
  export type RaceGestureType = ComposedGestureType;
139
+ /**
140
+ * @deprecated `SimultaneousGestureType` is deprecated and will be removed in the future. Please use `ComposedGesture` instead.
141
+ */
124
142
  export type SimultaneousGestureType = InstanceType<typeof SimultaneousGesture>;
143
+ /**
144
+ * @deprecated `ExclusiveGestureType` is deprecated and will be removed in the future. Please use `ComposedGesture` instead.
145
+ */
125
146
  export type ExclusiveGestureType = InstanceType<typeof ExclusiveGesture>;
@@ -16,6 +16,8 @@ import { RotationGesture } from './rotationGesture';
16
16
  import { TapGesture } from './tapGesture';
17
17
 
18
18
  /**
19
+ * @deprecated `Gesture` builder API is deprecated and will be removed in a future version of Gesture Handler. Please migrate to the new, hook-based API.
20
+ *
19
21
  * `Gesture` is the object that allows you to create and compose gestures.
20
22
  *
21
23
  * ### Remarks
@@ -25,6 +27,8 @@ import { TapGesture } from './tapGesture';
25
27
  */
26
28
  export const GestureObjects = {
27
29
  /**
30
+ * @deprecated `Gesture.Tap()` is deprecated and will be removed in the future. Please use `useTapGesture` instead.
31
+ *
28
32
  * A discrete gesture that recognizes one or many taps.
29
33
  * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/tap-gesture
30
34
  */
@@ -33,6 +37,8 @@ export const GestureObjects = {
33
37
  },
34
38
 
35
39
  /**
40
+ * @deprecated `Gesture.Pan()` is deprecated and will be removed in the future. Please use `usePanGesture` instead.
41
+ *
36
42
  * A continuous gesture that can recognize a panning (dragging) gesture and track its movement.
37
43
  * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture
38
44
  */
@@ -41,6 +47,8 @@ export const GestureObjects = {
41
47
  },
42
48
 
43
49
  /**
50
+ * @deprecated `Gesture.Pinch()` is deprecated and will be removed in the future. Please use `usePinchGesture` instead.
51
+ *
44
52
  * A continuous gesture that recognizes pinch gesture. It allows for tracking the distance between two fingers and use that information to scale or zoom your content.
45
53
  * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pinch-gesture
46
54
  */
@@ -49,6 +57,8 @@ export const GestureObjects = {
49
57
  },
50
58
 
51
59
  /**
60
+ * @deprecated `Gesture.Rotation()` is deprecated and will be removed in the future. Please use `useRotationGesture` instead.
61
+ *
52
62
  * A continuous gesture that can recognize rotation and track its movement.
53
63
  * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/rotation-gesture
54
64
  */
@@ -57,6 +67,8 @@ export const GestureObjects = {
57
67
  },
58
68
 
59
69
  /**
70
+ * @deprecated `Gesture.Fling()` is deprecated and will be removed in the future. Please use `useFlingGesture` instead.
71
+ *
60
72
  * A discrete gesture that activates when the movement is sufficiently fast.
61
73
  * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/fling-gesture
62
74
  */
@@ -65,6 +77,8 @@ export const GestureObjects = {
65
77
  },
66
78
 
67
79
  /**
80
+ * @deprecated `Gesture.LongPress()` is deprecated and will be removed in the future. Please use `useLongPressGesture` instead.
81
+ *
68
82
  * A discrete gesture that activates when the corresponding view is pressed for a sufficiently long time.
69
83
  * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/long-press-gesture
70
84
  */
@@ -73,7 +87,7 @@ export const GestureObjects = {
73
87
  },
74
88
 
75
89
  /**
76
- * @deprecated ForceTouch gesture is deprecated and will be removed in the future.
90
+ * @deprecated `Gesture.ForceTouch()` is deprecated and will be removed in the future.
77
91
  *
78
92
  * #### iOS only
79
93
  * A continuous gesture that recognizes force of a touch. It allows for tracking pressure of touch on some iOS devices.
@@ -84,6 +98,8 @@ export const GestureObjects = {
84
98
  },
85
99
 
86
100
  /**
101
+ * @deprecated `Gesture.Native()` is deprecated and will be removed in the future. Please use `useNativeGesture` instead.
102
+ *
87
103
  * A gesture that allows other touch handling components to participate in RNGH's gesture system.
88
104
  * When used, the other component should be the direct child of a `GestureDetector`.
89
105
  * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/native-gesture
@@ -93,6 +109,8 @@ export const GestureObjects = {
93
109
  },
94
110
 
95
111
  /**
112
+ * @deprecated `Gesture.Manual()` is deprecated and will be removed in the future. Please use `useManualGesture` instead.
113
+ *
96
114
  * A plain gesture that has no specific activation criteria nor event data set.
97
115
  * Its state has to be controlled manually using a state manager.
98
116
  * It will not fail when all the pointers are lifted from the screen.
@@ -103,6 +121,8 @@ export const GestureObjects = {
103
121
  },
104
122
 
105
123
  /**
124
+ * @deprecated `Gesture.Hover()` is deprecated and will be removed in the future. Please use `useHoverGesture` instead.
125
+ *
106
126
  * A continuous gesture that can recognize hovering above the view it's attached to.
107
127
  * The hover effect may be activated by moving a mouse or a stylus over the view.
108
128
  *
@@ -113,6 +133,8 @@ export const GestureObjects = {
113
133
  },
114
134
 
115
135
  /**
136
+ * @deprecated `Gesture.Race()` is deprecated and will be removed in the future. Please use `useCompetingGestures` instead.
137
+ *
116
138
  * Builds a composed gesture consisting of gestures provided as parameters.
117
139
  * The first one that becomes active cancels the rest of gestures.
118
140
  * @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#race
@@ -122,6 +144,8 @@ export const GestureObjects = {
122
144
  },
123
145
 
124
146
  /**
147
+ * @deprecated `Gesture.Simultaneous()` is deprecated and will be removed in the future. Please use `useSimultaneousGestures` instead.
148
+ *
125
149
  * Builds a composed gesture that allows all base gestures to run simultaneously.
126
150
  * @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#simultaneous
127
151
  */
@@ -130,6 +154,8 @@ export const GestureObjects = {
130
154
  },
131
155
 
132
156
  /**
157
+ * @deprecated `Gesture.Exclusive()` is deprecated and will be removed in the future. Please use `useExclusiveGestures` instead.
158
+ *
133
159
  * Builds a composed gesture where only one of the provided gestures can become active.
134
160
  * Priority is decided through the order of gestures: the first one has higher priority
135
161
  * than the second one, second one has higher priority than the third one, and so on.
@@ -1,6 +1,9 @@
1
1
  import { State } from '../../State';
2
2
  import { tagMessage } from '../../utils';
3
3
 
4
+ /**
5
+ * @deprecated `LegacyGestureStateManagerType` is deprecated and will be removed in the future. Please use the new, hook-based API instead.
6
+ */
4
7
  export interface GestureStateManagerType {
5
8
  begin: () => void;
6
9
  activate: () => void;
@@ -49,6 +52,9 @@ function create(handlerTag: number): GestureStateManagerType {
49
52
  };
50
53
  }
51
54
 
55
+ /**
56
+ * @deprecated `LegacyGestureStateManager` is deprecated and will be removed in the future. Please use the new, hook-based API instead.
57
+ */
52
58
  export const GestureStateManager = {
53
59
  create,
54
60
  };
@@ -41,6 +41,9 @@ function changeEventCalculator(
41
41
  return { ...current, ...changePayload };
42
42
  }
43
43
 
44
+ /**
45
+ * @deprecated `HoverGesture` is deprecated and will be removed in the future. Please use `useHoverGesture` instead.
46
+ */
44
47
  export class HoverGesture extends ContinousBaseGesture<
45
48
  HoverGestureHandlerEventPayload,
46
49
  HoverGestureChangeEventPayload
@@ -75,4 +78,7 @@ export class HoverGesture extends ContinousBaseGesture<
75
78
  }
76
79
  }
77
80
 
81
+ /**
82
+ * @deprecated `HoverGestureType` is deprecated and will be removed in the future. Please use `HoverGesture` instead.
83
+ */
78
84
  export type HoverGestureType = InstanceType<typeof HoverGesture>;
@@ -3,6 +3,9 @@ import type { LongPressGestureConfig } from '../LongPressGestureHandler';
3
3
  import type { BaseGestureConfig } from './gesture';
4
4
  import { BaseGesture } from './gesture';
5
5
 
6
+ /**
7
+ * @deprecated `LongPressGesture` is deprecated and will be removed in the future. Please use `useLongPressGesture` instead.
8
+ */
6
9
  export class LongPressGesture extends BaseGesture<LongPressGestureHandlerEventPayload> {
7
10
  public override config: BaseGestureConfig & LongPressGestureConfig = {};
8
11
 
@@ -43,4 +46,7 @@ export class LongPressGesture extends BaseGesture<LongPressGestureHandlerEventPa
43
46
  }
44
47
  }
45
48
 
49
+ /**
50
+ * @deprecated `LongPressGestureType` is deprecated and will be removed in the future. Please use `LongPressGesture` instead.
51
+ */
46
52
  export type LongPressGestureType = InstanceType<typeof LongPressGesture>;
@@ -9,6 +9,9 @@ function changeEventCalculator(
9
9
  return current;
10
10
  }
11
11
 
12
+ /**
13
+ * @deprecated `ManualGesture` is deprecated and will be removed in the future. Please use `useManualGesture` instead.
14
+ */
12
15
  export class ManualGesture extends ContinousBaseGesture<
13
16
  Record<string, never>,
14
17
  Record<string, never>
@@ -28,4 +31,7 @@ export class ManualGesture extends ContinousBaseGesture<
28
31
  }
29
32
  }
30
33
 
34
+ /**
35
+ * @deprecated `ManualGestureType` is deprecated and will be removed in the future. Please use `ManualGesture` instead.
36
+ */
31
37
  export type ManualGestureType = InstanceType<typeof ManualGesture>;
@@ -3,6 +3,9 @@ import type { NativeViewGestureConfig } from '../NativeViewGestureHandler';
3
3
  import type { BaseGestureConfig } from './gesture';
4
4
  import { BaseGesture } from './gesture';
5
5
 
6
+ /**
7
+ * @deprecated `NativeGesture` is deprecated and will be removed in the future. Please use `useNativeGesture` instead.
8
+ */
6
9
  export class NativeGesture extends BaseGesture<NativeViewGestureHandlerPayload> {
7
10
  public override config: BaseGestureConfig & NativeViewGestureConfig = {};
8
11
 
@@ -31,4 +34,7 @@ export class NativeGesture extends BaseGesture<NativeViewGestureHandlerPayload>
31
34
  }
32
35
  }
33
36
 
37
+ /**
38
+ * @deprecated `NativeGestureType` is deprecated and will be removed in the future. Please use `NativeGesture` instead.
39
+ */
34
40
  export type NativeGestureType = InstanceType<typeof NativeGesture>;
@@ -4,6 +4,9 @@ import type { PanGestureConfig } from '../PanGestureHandler';
4
4
  import type { BaseGestureConfig } from './gesture';
5
5
  import { ContinousBaseGesture } from './gesture';
6
6
 
7
+ /**
8
+ * @deprecated `PanGestureChangeEventPayload` is deprecated and will be removed in the future. Please use `PanGestureActiveEvent` instead.
9
+ */
7
10
  export type PanGestureChangeEventPayload = {
8
11
  changeX: number;
9
12
  changeY: number;
@@ -30,6 +33,9 @@ function changeEventCalculator(
30
33
  return { ...current, ...changePayload };
31
34
  }
32
35
 
36
+ /**
37
+ * @deprecated `PanGesture` is deprecated and will be removed in the future. Please use `usePanGesture` instead.
38
+ */
33
39
  export class PanGesture extends ContinousBaseGesture<
34
40
  PanGestureHandlerEventPayload,
35
41
  PanGestureChangeEventPayload
@@ -219,4 +225,7 @@ export class PanGesture extends ContinousBaseGesture<
219
225
  }
220
226
  }
221
227
 
228
+ /**
229
+ * @deprecated `PanGestureType` is deprecated and will be removed in the future. Please use `PanGesture` instead.
230
+ */
222
231
  export type PanGestureType = InstanceType<typeof PanGesture>;
@@ -2,6 +2,9 @@ import type { GestureUpdateEvent } from '../gestureHandlerCommon';
2
2
  import type { PinchGestureHandlerEventPayload } from '../GestureHandlerEventPayload';
3
3
  import { ContinousBaseGesture } from './gesture';
4
4
 
5
+ /**
6
+ * @deprecated `PinchGestureChangeEventPayload` is deprecated and will be removed in the future. Please use `PinchGestureActiveEvent` instead.
7
+ */
5
8
  export type PinchGestureChangeEventPayload = {
6
9
  scaleChange: number;
7
10
  };
@@ -25,6 +28,9 @@ function changeEventCalculator(
25
28
  return { ...current, ...changePayload };
26
29
  }
27
30
 
31
+ /**
32
+ * @deprecated `PinchGesture` is deprecated and will be removed in the future. Please use `usePinchGesture` instead.
33
+ */
28
34
  export class PinchGesture extends ContinousBaseGesture<
29
35
  PinchGestureHandlerEventPayload,
30
36
  PinchGestureChangeEventPayload
@@ -48,4 +54,7 @@ export class PinchGesture extends ContinousBaseGesture<
48
54
  }
49
55
  }
50
56
 
57
+ /**
58
+ * @deprecated `PinchGestureType` is deprecated and will be removed in the future. Please use `PinchGesture` instead.
59
+ */
51
60
  export type PinchGestureType = InstanceType<typeof PinchGesture>;
@@ -25,6 +25,9 @@ function changeEventCalculator(
25
25
  return { ...current, ...changePayload };
26
26
  }
27
27
 
28
+ /**
29
+ * @deprecated `RotationGesture` is deprecated and will be removed in the future. Please use `useRotationGesture` instead.
30
+ */
28
31
  export class RotationGesture extends ContinousBaseGesture<
29
32
  RotationGestureHandlerEventPayload,
30
33
  RotationGestureChangeEventPayload
@@ -48,4 +51,7 @@ export class RotationGesture extends ContinousBaseGesture<
48
51
  }
49
52
  }
50
53
 
54
+ /**
55
+ * @deprecated `RotationGestureType` is deprecated and will be removed in the future. Please use `RotationGesture` instead.
56
+ */
51
57
  export type RotationGestureType = InstanceType<typeof RotationGesture>;
@@ -3,6 +3,9 @@ import type { TapGestureConfig } from '../TapGestureHandler';
3
3
  import type { BaseGestureConfig } from './gesture';
4
4
  import { BaseGesture } from './gesture';
5
5
 
6
+ /**
7
+ * @deprecated `TapGesture` is deprecated and will be removed in the future. Please use `useTapGesture` instead.
8
+ */
6
9
  export class TapGesture extends BaseGesture<TapGestureHandlerEventPayload> {
7
10
  public override config: BaseGestureConfig & TapGestureConfig = {};
8
11
 
@@ -84,4 +87,7 @@ export class TapGesture extends BaseGesture<TapGestureHandlerEventPayload> {
84
87
  }
85
88
  }
86
89
 
90
+ /**
91
+ * @deprecated `TapGestureType` is deprecated and will be removed in the future. Please use `TapGesture` instead.
92
+ */
87
93
  export type TapGestureType = InstanceType<typeof TapGesture>;
@@ -23,7 +23,7 @@ export const RawButton = createNativeWrapper<
23
23
  RawButtonProps
24
24
  >(GestureHandlerButton, {
25
25
  shouldCancelWhenOutside: false,
26
- shouldActivateOnStart: true,
26
+ shouldActivateOnStart: false,
27
27
  });
28
28
 
29
29
  /**
@@ -69,16 +69,16 @@ export const BaseButton = (props: BaseButtonProps) => {
69
69
  };
70
70
 
71
71
  const onDeactivate = (e: EndCallbackEventType) => {
72
+ props.onDeactivate?.(e);
73
+ };
74
+
75
+ const onFinalize = (e: EndCallbackEventType) => {
72
76
  onActiveStateChange?.(false);
73
77
 
74
78
  if (!e.canceled && !longPressDetected.current) {
75
79
  onPress?.(e.pointerInside);
76
80
  }
77
81
 
78
- props.onDeactivate?.(e);
79
- };
80
-
81
- const onFinalize = (e: EndCallbackEventType) => {
82
82
  if (longPressTimeout.current !== undefined) {
83
83
  clearTimeout(longPressTimeout.current);
84
84
  longPressTimeout.current = undefined;
@@ -308,7 +308,7 @@ const Pressable = (props: PressableProps) => {
308
308
  stateMachine.handleEvent(StateMachineEvent.NATIVE_BEGIN);
309
309
  },
310
310
  onActivate: () => {
311
- if (Platform.OS !== 'android' && Platform.OS !== 'ios') {
311
+ if (Platform.OS !== 'android') {
312
312
  // Native.onActivate is broken with Android + hitSlop
313
313
  stateMachine.handleEvent(StateMachineEvent.NATIVE_START);
314
314
  }
@@ -331,6 +331,7 @@ const Pressable = (props: PressableProps) => {
331
331
  block,
332
332
  requireToFail,
333
333
  hitSlop: appliedHitSlop,
334
+ shouldActivateOnStart: Platform.OS === 'web',
334
335
  });
335
336
 
336
337
  const gesture = useSimultaneousGestures(
@@ -1,26 +1,24 @@
1
1
  import React, { useCallback, useRef } from 'react';
2
2
  import { Platform } from 'react-native';
3
3
 
4
- import type { ButtonProps } from '../../../components/GestureHandlerButton';
5
4
  import GestureHandlerButton from '../../../components/GestureHandlerButton';
6
- import createNativeWrapper from '../../createNativeWrapper';
5
+ import { NativeDetector } from '../../detectors/NativeDetector';
6
+ import { useNativeGesture } from '../../hooks';
7
7
  import type {
8
8
  CallbackEventType,
9
9
  EndCallbackEventType,
10
10
  TouchableProps,
11
11
  } from './TouchableProps';
12
12
 
13
- const TouchableButton = createNativeWrapper<
14
- React.ComponentRef<typeof GestureHandlerButton>,
15
- ButtonProps
16
- >(GestureHandlerButton, {
17
- shouldCancelWhenOutside: true,
18
- shouldActivateOnStart: false,
19
- });
20
-
21
13
  const isAndroid = Platform.OS === 'android';
22
14
  const TRANSPARENT_RIPPLE = { rippleColor: 'transparent' as const };
23
15
 
16
+ enum PointerState {
17
+ UNKNOWN,
18
+ INSIDE,
19
+ OUTSIDE,
20
+ }
21
+
24
22
  export const Touchable = (props: TouchableProps) => {
25
23
  const {
26
24
  underlayColor = 'black',
@@ -32,15 +30,16 @@ export const Touchable = (props: TouchableProps) => {
32
30
  onPress,
33
31
  onPressIn,
34
32
  onPressOut,
35
- onActiveStateChange,
36
33
  children,
37
34
  disabled = false,
35
+ cancelOnLeave = true,
38
36
  ref,
39
37
  ...rest
40
38
  } = props;
41
39
 
42
40
  const shouldUseNativeRipple = isAndroid && androidRipple !== undefined;
43
41
 
42
+ const pointerState = useRef<PointerState>(PointerState.UNKNOWN);
44
43
  const longPressDetected = useRef(false);
45
44
  const longPressTimeout = useRef<ReturnType<typeof setTimeout> | undefined>(
46
45
  undefined
@@ -62,50 +61,86 @@ export const Touchable = (props: TouchableProps) => {
62
61
  const onBegin = useCallback(
63
62
  (e: CallbackEventType) => {
64
63
  if (!e.pointerInside) {
64
+ pointerState.current = PointerState.OUTSIDE;
65
65
  return;
66
66
  }
67
67
 
68
68
  onPressIn?.(e);
69
69
  startLongPressTimer();
70
+
71
+ pointerState.current = PointerState.INSIDE;
70
72
  },
71
73
  [startLongPressTimer, onPressIn]
72
74
  );
73
75
 
74
- const onActivate = useCallback(
75
- (e: CallbackEventType) => {
76
- onActiveStateChange?.(true);
77
-
78
- if (!e.pointerInside && longPressTimeout.current !== undefined) {
79
- clearTimeout(longPressTimeout.current);
80
- longPressTimeout.current = undefined;
81
- }
82
- },
83
- [onActiveStateChange]
84
- );
76
+ const onActivate = useCallback((e: CallbackEventType) => {
77
+ if (!e.pointerInside && longPressTimeout.current !== undefined) {
78
+ clearTimeout(longPressTimeout.current);
79
+ longPressTimeout.current = undefined;
80
+ }
81
+ }, []);
85
82
 
86
- const onDeactivate = useCallback(
83
+ const onFinalize = useCallback(
87
84
  (e: EndCallbackEventType) => {
88
- onActiveStateChange?.(false);
85
+ if (pointerState.current === PointerState.INSIDE) {
86
+ onPressOut?.(e);
87
+ }
89
88
 
90
- if (!e.canceled && !longPressDetected.current) {
91
- onPress?.(e.pointerInside);
89
+ if (!e.canceled && !longPressDetected.current && e.pointerInside) {
90
+ onPress?.(e);
92
91
  }
93
- },
94
- [onActiveStateChange, onPress]
95
- );
96
92
 
97
- const onFinalize = useCallback(
98
- (e: EndCallbackEventType) => {
99
- onPressOut?.(e);
93
+ pointerState.current = PointerState.UNKNOWN;
100
94
 
101
95
  if (longPressTimeout.current !== undefined) {
102
96
  clearTimeout(longPressTimeout.current);
103
97
  longPressTimeout.current = undefined;
104
98
  }
105
99
  },
106
- [onPressOut]
100
+ [onPressOut, onPress]
107
101
  );
108
102
 
103
+ const onUpdate = useCallback(
104
+ (e: CallbackEventType) => {
105
+ if (pointerState.current === PointerState.UNKNOWN) {
106
+ return;
107
+ }
108
+
109
+ if (e.pointerInside) {
110
+ if (pointerState.current === PointerState.OUTSIDE) {
111
+ onPressIn?.(e);
112
+ }
113
+ pointerState.current = PointerState.INSIDE;
114
+ } else {
115
+ if (pointerState.current === PointerState.INSIDE) {
116
+ onPressOut?.(e);
117
+
118
+ if (longPressTimeout.current !== undefined) {
119
+ clearTimeout(longPressTimeout.current);
120
+ longPressTimeout.current = undefined;
121
+ }
122
+ }
123
+ pointerState.current = PointerState.OUTSIDE;
124
+ }
125
+ },
126
+ [onPressIn, onPressOut]
127
+ );
128
+
129
+ const nativeGesture = useNativeGesture({
130
+ onBegin,
131
+ onActivate,
132
+ onFinalize,
133
+ onUpdate,
134
+ hitSlop: props.hitSlop,
135
+ testID: props.testID,
136
+ enabled: !disabled,
137
+ shouldCancelWhenOutside: cancelOnLeave,
138
+ disableReanimated: true,
139
+ shouldActivateOnStart: false,
140
+ disallowInterruption: true,
141
+ yieldsToContinuousGestures: true,
142
+ });
143
+
109
144
  const rippleProps = shouldUseNativeRipple
110
145
  ? {
111
146
  rippleColor: androidRipple?.color,
@@ -116,19 +151,17 @@ export const Touchable = (props: TouchableProps) => {
116
151
  : TRANSPARENT_RIPPLE;
117
152
 
118
153
  return (
119
- <TouchableButton
120
- {...rest}
121
- {...rippleProps}
122
- ref={ref ?? null}
123
- enabled={!disabled}
124
- onBegin={onBegin}
125
- onActivate={onActivate}
126
- onDeactivate={onDeactivate}
127
- onFinalize={onFinalize}
128
- defaultOpacity={defaultOpacity}
129
- defaultUnderlayOpacity={defaultUnderlayOpacity}
130
- underlayColor={underlayColor}>
131
- {children}
132
- </TouchableButton>
154
+ <NativeDetector gesture={nativeGesture}>
155
+ <GestureHandlerButton
156
+ {...rest}
157
+ {...rippleProps}
158
+ ref={ref ?? null}
159
+ enabled={!disabled}
160
+ defaultOpacity={defaultOpacity}
161
+ defaultUnderlayOpacity={defaultUnderlayOpacity}
162
+ underlayColor={underlayColor}>
163
+ {children}
164
+ </GestureHandlerButton>
165
+ </NativeDetector>
133
166
  );
134
167
  };
@@ -18,12 +18,20 @@ type PressableAndroidRippleConfig = {
18
18
  type RippleProps = 'rippleColor' | 'rippleRadius' | 'borderless' | 'foreground';
19
19
 
20
20
  export type TouchableProps = Omit<ButtonProps, RippleProps | 'enabled'> &
21
- Omit<BaseButtonProps, keyof RawButtonProps> & {
21
+ Omit<
22
+ BaseButtonProps,
23
+ keyof RawButtonProps | 'onActiveStateChange' | 'onPress'
24
+ > & {
22
25
  /**
23
26
  * Configuration for the ripple effect on Android.
24
27
  */
25
28
  androidRipple?: PressableAndroidRippleConfig | undefined;
26
29
 
30
+ /**
31
+ * Called when the component gets pressed.
32
+ */
33
+ onPress?: ((event: CallbackEventType) => void) | undefined;
34
+
27
35
  /**
28
36
  * Called when pointer touches the component.
29
37
  */
@@ -38,4 +46,10 @@ export type TouchableProps = Omit<ButtonProps, RippleProps | 'enabled'> &
38
46
  * Whether the component should ignore touches. By default set to false.
39
47
  */
40
48
  disabled?: boolean | undefined;
49
+
50
+ /**
51
+ * Whether the touch should be canceled when pointer leaves the component. By default set to true.
52
+ * On web this prop doesn't have any effect and behaves as if `true` was set.
53
+ */
54
+ cancelOnLeave?: boolean | undefined;
41
55
  };
@@ -9,7 +9,8 @@ import type {
9
9
  } from '../../handlers/gestureHandlerCommon';
10
10
  import RNGestureHandlerModule from '../../RNGestureHandlerModule.web';
11
11
  import { tagMessage } from '../../utils';
12
- import type { PropsRef } from '../../web/interfaces';
12
+ import { type PropsRef } from '../../web/interfaces';
13
+ import { useNativeGestureRole } from './useNativeGestureRole';
13
14
 
14
15
  export interface GestureHandlerDetectorProps extends PropsRef {
15
16
  handlerTags: number[];
@@ -103,6 +104,8 @@ const HostGestureDetector = (props: GestureHandlerDetectorProps) => {
103
104
  });
104
105
  };
105
106
 
107
+ useNativeGestureRole(viewRef, children);
108
+
106
109
  useEffect(() => {
107
110
  const shouldUpdateDOMProps =
108
111
  propsRef.current.userSelect !== props.userSelect ||
@@ -6,6 +6,7 @@ import { tagMessage } from '../../../utils';
6
6
  import { isComposedGesture } from '../../hooks/utils/relationUtils';
7
7
  import type { DetectorCallbacks, VirtualChild } from '../../types';
8
8
  import type { VirtualDetectorProps } from '../common';
9
+ import { useNativeGestureRole } from '../useNativeGestureRole';
9
10
  import { configureRelations } from '../utils';
10
11
  import {
11
12
  InterceptingDetectorMode,
@@ -54,6 +55,8 @@ export function VirtualDetector<
54
55
  [props.children]
55
56
  );
56
57
 
58
+ useNativeGestureRole(viewRef, props.children);
59
+
57
60
  useEffect(() => {
58
61
  if (viewTag === -1) {
59
62
  return;
@@ -0,0 +1,8 @@
1
+ import type { ReactNode, RefObject } from 'react';
2
+
3
+ export function useNativeGestureRole(
4
+ _viewRef: RefObject<unknown>,
5
+ _children: ReactNode
6
+ ): void {
7
+ // No-op on native; the web implementation lives in `useNativeGestureRole.web.ts`.
8
+ }