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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (419) hide show
  1. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt +42 -38
  2. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +34 -8
  3. package/android/src/main/java/com/swmansion/gesturehandler/core/HoverGestureHandler.kt +3 -6
  4. package/android/src/main/java/com/swmansion/gesturehandler/core/ManualGestureHandler.kt +2 -0
  5. package/android/src/main/java/com/swmansion/gesturehandler/core/NativeViewGestureHandler.kt +68 -7
  6. package/android/src/main/java/com/swmansion/gesturehandler/core/OnJSResponderCancelListener.kt +6 -0
  7. package/android/src/main/java/com/swmansion/gesturehandler/core/PanGestureHandler.kt +2 -0
  8. package/android/src/main/java/com/swmansion/gesturehandler/core/PinchGestureHandler.kt +16 -6
  9. package/android/src/main/java/com/swmansion/gesturehandler/core/RotationGestureHandler.kt +17 -4
  10. package/android/src/main/java/com/swmansion/gesturehandler/core/ViewConfigurationHelper.kt +0 -1
  11. package/android/src/main/java/com/swmansion/gesturehandler/react/Extensions.kt +21 -0
  12. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +160 -55
  13. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerDetectorView.kt +75 -98
  14. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.kt +1 -1
  15. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +7 -10
  16. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRegistry.kt +64 -2
  17. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +18 -8
  18. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt +15 -4
  19. package/android/src/main/java/com/swmansion/gesturehandler/react/RNViewConfigurationHelper.kt +0 -6
  20. package/apple/Handlers/RNForceTouchHandler.m +1 -1
  21. package/apple/Handlers/RNHoverHandler.m +11 -11
  22. package/apple/Handlers/RNLongPressHandler.m +2 -2
  23. package/apple/Handlers/RNManualHandler.m +5 -0
  24. package/apple/Handlers/RNNativeViewHandler.mm +114 -53
  25. package/apple/Handlers/RNPanHandler.m +7 -3
  26. package/apple/Handlers/RNPinchHandler.m +9 -3
  27. package/apple/Handlers/RNRotationHandler.m +7 -2
  28. package/apple/Handlers/RNTapHandler.m +1 -1
  29. package/apple/RNGestureHandler.h +18 -0
  30. package/apple/RNGestureHandler.mm +82 -33
  31. package/apple/RNGestureHandlerButton.h +12 -2
  32. package/apple/RNGestureHandlerButton.mm +208 -38
  33. package/apple/RNGestureHandlerButtonComponentView.mm +102 -6
  34. package/apple/RNGestureHandlerDetector.mm +99 -75
  35. package/apple/RNGestureHandlerModule.mm +11 -14
  36. package/apple/RNGestureHandlerRegistry.h +14 -1
  37. package/apple/RNGestureHandlerRegistry.m +56 -0
  38. package/apple/RNRootViewGestureRecognizer.m +4 -15
  39. package/lib/module/RNGestureHandlerModule.web.js +5 -1
  40. package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
  41. package/lib/module/components/GestureButtons.js +23 -12
  42. package/lib/module/components/GestureButtons.js.map +1 -1
  43. package/lib/module/components/GestureHandlerButton.js.map +1 -1
  44. package/lib/module/components/GestureHandlerButton.web.js +113 -31
  45. package/lib/module/components/GestureHandlerButton.web.js.map +1 -1
  46. package/lib/module/components/Pressable/Pressable.js +2 -1
  47. package/lib/module/components/Pressable/Pressable.js.map +1 -1
  48. package/lib/module/components/Pressable/stateDefinitions.js +2 -0
  49. package/lib/module/components/Pressable/stateDefinitions.js.map +1 -1
  50. package/lib/module/components/ReanimatedDrawerLayout.js.map +1 -1
  51. package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeable.js +38 -5
  52. package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeable.js.map +1 -1
  53. package/lib/module/components/touchables/GenericTouchable.js +2 -6
  54. package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
  55. package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js +1 -2
  56. package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js.map +1 -1
  57. package/lib/module/handlers/gestures/GestureDetector/utils.js +11 -48
  58. package/lib/module/handlers/gestures/GestureDetector/utils.js.map +1 -1
  59. package/lib/module/handlers/gestures/flingGesture.js +8 -0
  60. package/lib/module/handlers/gestures/flingGesture.js.map +1 -1
  61. package/lib/module/handlers/gestures/forceTouchGesture.js +3 -3
  62. package/lib/module/handlers/gestures/gesture.js +8 -0
  63. package/lib/module/handlers/gestures/gesture.js.map +1 -1
  64. package/lib/module/handlers/gestures/gestureComposition.js +28 -0
  65. package/lib/module/handlers/gestures/gestureComposition.js.map +1 -1
  66. package/lib/module/handlers/gestures/gestureObjects.js +27 -1
  67. package/lib/module/handlers/gestures/gestureObjects.js.map +1 -1
  68. package/lib/module/handlers/gestures/gestureStateManager.js +9 -0
  69. package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -1
  70. package/lib/module/handlers/gestures/hoverGesture.js +8 -0
  71. package/lib/module/handlers/gestures/hoverGesture.js.map +1 -1
  72. package/lib/module/handlers/gestures/longPressGesture.js +8 -0
  73. package/lib/module/handlers/gestures/longPressGesture.js.map +1 -1
  74. package/lib/module/handlers/gestures/manualGesture.js +8 -0
  75. package/lib/module/handlers/gestures/manualGesture.js.map +1 -1
  76. package/lib/module/handlers/gestures/nativeGesture.js +8 -0
  77. package/lib/module/handlers/gestures/nativeGesture.js.map +1 -1
  78. package/lib/module/handlers/gestures/panGesture.js +13 -0
  79. package/lib/module/handlers/gestures/panGesture.js.map +1 -1
  80. package/lib/module/handlers/gestures/pinchGesture.js +13 -0
  81. package/lib/module/handlers/gestures/pinchGesture.js.map +1 -1
  82. package/lib/module/handlers/gestures/reanimatedWrapper.js +14 -2
  83. package/lib/module/handlers/gestures/reanimatedWrapper.js.map +1 -1
  84. package/lib/module/handlers/gestures/rotationGesture.js +8 -0
  85. package/lib/module/handlers/gestures/rotationGesture.js.map +1 -1
  86. package/lib/module/handlers/gestures/tapGesture.js +8 -0
  87. package/lib/module/handlers/gestures/tapGesture.js.map +1 -1
  88. package/lib/module/mocks/module.js +3 -2
  89. package/lib/module/mocks/module.js.map +1 -1
  90. package/lib/module/specs/NativeRNGestureHandlerModule.js.map +1 -1
  91. package/lib/module/specs/RNGestureHandlerButtonNativeComponent.ts +28 -13
  92. package/lib/module/v3/NativeProxy.js +5 -3
  93. package/lib/module/v3/NativeProxy.js.map +1 -1
  94. package/lib/module/v3/NativeProxy.web.js +2 -2
  95. package/lib/module/v3/NativeProxy.web.js.map +1 -1
  96. package/lib/module/v3/components/GestureButtons.js +11 -6
  97. package/lib/module/v3/components/GestureButtons.js.map +1 -1
  98. package/lib/module/v3/components/Pressable.js +3 -2
  99. package/lib/module/v3/components/Pressable.js.map +1 -1
  100. package/lib/module/v3/components/Touchable/Touchable.js +119 -32
  101. package/lib/module/v3/components/Touchable/Touchable.js.map +1 -1
  102. package/lib/module/v3/detectors/HostGestureDetector.web.js +180 -59
  103. package/lib/module/v3/detectors/HostGestureDetector.web.js.map +1 -1
  104. package/lib/module/v3/detectors/NativeDetector.js +3 -2
  105. package/lib/module/v3/detectors/NativeDetector.js.map +1 -1
  106. package/lib/module/v3/detectors/VirtualDetector/InterceptingGestureDetector.js +3 -4
  107. package/lib/module/v3/detectors/VirtualDetector/InterceptingGestureDetector.js.map +1 -1
  108. package/lib/module/v3/detectors/VirtualDetector/VirtualDetector.js +4 -2
  109. package/lib/module/v3/detectors/VirtualDetector/VirtualDetector.js.map +1 -1
  110. package/lib/module/v3/detectors/useGestureRelationsUpdater.js +23 -0
  111. package/lib/module/v3/detectors/useGestureRelationsUpdater.js.map +1 -0
  112. package/lib/module/v3/detectors/useNativeGestureRole.js +6 -0
  113. package/lib/module/v3/detectors/useNativeGestureRole.js.map +1 -0
  114. package/lib/module/v3/detectors/useNativeGestureRole.web.js +27 -0
  115. package/lib/module/v3/detectors/useNativeGestureRole.web.js.map +1 -0
  116. package/lib/module/v3/detectors/utils.js +10 -8
  117. package/lib/module/v3/detectors/utils.js.map +1 -1
  118. package/lib/module/v3/hooks/callbacks/useReanimatedEventHandler.js +17 -2
  119. package/lib/module/v3/hooks/callbacks/useReanimatedEventHandler.js.map +1 -1
  120. package/lib/module/v3/hooks/gestures/fling/useFlingGesture.js +2 -1
  121. package/lib/module/v3/hooks/gestures/fling/useFlingGesture.js.map +1 -1
  122. package/lib/module/v3/hooks/gestures/hover/useHoverGesture.js +2 -1
  123. package/lib/module/v3/hooks/gestures/hover/useHoverGesture.js.map +1 -1
  124. package/lib/module/v3/hooks/gestures/longPress/useLongPressGesture.js +2 -1
  125. package/lib/module/v3/hooks/gestures/longPress/useLongPressGesture.js.map +1 -1
  126. package/lib/module/v3/hooks/gestures/manual/useManualGesture.js +2 -1
  127. package/lib/module/v3/hooks/gestures/manual/useManualGesture.js.map +1 -1
  128. package/lib/module/v3/hooks/gestures/native/NativeTypes.js +1 -1
  129. package/lib/module/v3/hooks/gestures/native/NativeTypes.js.map +1 -1
  130. package/lib/module/v3/hooks/gestures/native/useNativeGesture.js +2 -1
  131. package/lib/module/v3/hooks/gestures/native/useNativeGesture.js.map +1 -1
  132. package/lib/module/v3/hooks/gestures/pan/usePanGesture.js +2 -1
  133. package/lib/module/v3/hooks/gestures/pan/usePanGesture.js.map +1 -1
  134. package/lib/module/v3/hooks/gestures/pinch/usePinchGesture.js +2 -1
  135. package/lib/module/v3/hooks/gestures/pinch/usePinchGesture.js.map +1 -1
  136. package/lib/module/v3/hooks/gestures/rotation/useRotationGesture.js +2 -1
  137. package/lib/module/v3/hooks/gestures/rotation/useRotationGesture.js.map +1 -1
  138. package/lib/module/v3/hooks/gestures/tap/useTapGesture.js +2 -1
  139. package/lib/module/v3/hooks/gestures/tap/useTapGesture.js.map +1 -1
  140. package/lib/module/v3/hooks/useGesture.js +4 -22
  141. package/lib/module/v3/hooks/useGesture.js.map +1 -1
  142. package/lib/module/v3/hooks/utils/configUtils.js +8 -6
  143. package/lib/module/v3/hooks/utils/configUtils.js.map +1 -1
  144. package/lib/module/v3/hooks/utils/eventHandlersUtils.js +31 -29
  145. package/lib/module/v3/hooks/utils/eventHandlersUtils.js.map +1 -1
  146. package/lib/module/v3/hooks/utils/index.js +1 -1
  147. package/lib/module/v3/hooks/utils/index.js.map +1 -1
  148. package/lib/module/v3/hooks/utils/propsWhiteList.js +1 -1
  149. package/lib/module/v3/hooks/utils/propsWhiteList.js.map +1 -1
  150. package/lib/module/v3/hooks/utils/reanimatedUtils.js +8 -2
  151. package/lib/module/v3/hooks/utils/reanimatedUtils.js.map +1 -1
  152. package/lib/module/web/constants.js +1 -0
  153. package/lib/module/web/constants.js.map +1 -1
  154. package/lib/module/web/detectors/RotationGestureDetector.js +18 -5
  155. package/lib/module/web/detectors/RotationGestureDetector.js.map +1 -1
  156. package/lib/module/web/detectors/ScaleGestureDetector.js +9 -1
  157. package/lib/module/web/detectors/ScaleGestureDetector.js.map +1 -1
  158. package/lib/module/web/handlers/GestureHandler.js +25 -5
  159. package/lib/module/web/handlers/GestureHandler.js.map +1 -1
  160. package/lib/module/web/handlers/HoverGestureHandler.js +1 -4
  161. package/lib/module/web/handlers/HoverGestureHandler.js.map +1 -1
  162. package/lib/module/web/handlers/ManualGestureHandler.js +1 -0
  163. package/lib/module/web/handlers/ManualGestureHandler.js.map +1 -1
  164. package/lib/module/web/handlers/NativeViewGestureHandler.js +65 -17
  165. package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
  166. package/lib/module/web/handlers/PanGestureHandler.js +1 -0
  167. package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
  168. package/lib/module/web/handlers/PinchGestureHandler.js +4 -6
  169. package/lib/module/web/handlers/PinchGestureHandler.js.map +1 -1
  170. package/lib/module/web/handlers/RotationGestureHandler.js +4 -3
  171. package/lib/module/web/handlers/RotationGestureHandler.js.map +1 -1
  172. package/lib/module/web/interfaces.js +6 -0
  173. package/lib/module/web/interfaces.js.map +1 -1
  174. package/lib/module/web/tools/GestureHandlerOrchestrator.js +8 -2
  175. package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
  176. package/lib/module/web/tools/GestureLifecycleEvents.js +10 -0
  177. package/lib/module/web/tools/GestureLifecycleEvents.js.map +1 -0
  178. package/lib/module/web/tools/NodeManager.js +44 -0
  179. package/lib/module/web/tools/NodeManager.js.map +1 -1
  180. package/lib/module/web/tools/PointerEventManager.js +9 -0
  181. package/lib/module/web/tools/PointerEventManager.js.map +1 -1
  182. package/lib/typescript/RNGestureHandlerModule.web.d.ts +1 -1
  183. package/lib/typescript/RNGestureHandlerModule.web.d.ts.map +1 -1
  184. package/lib/typescript/components/GestureButtons.d.ts +14 -6
  185. package/lib/typescript/components/GestureButtons.d.ts.map +1 -1
  186. package/lib/typescript/components/GestureHandlerButton.d.ts +62 -8
  187. package/lib/typescript/components/GestureHandlerButton.d.ts.map +1 -1
  188. package/lib/typescript/components/GestureHandlerButton.web.d.ts +14 -3
  189. package/lib/typescript/components/GestureHandlerButton.web.d.ts.map +1 -1
  190. package/lib/typescript/components/Pressable/Pressable.d.ts.map +1 -1
  191. package/lib/typescript/components/Pressable/PressableProps.d.ts +1 -1
  192. package/lib/typescript/components/Pressable/PressableProps.d.ts.map +1 -1
  193. package/lib/typescript/components/Pressable/stateDefinitions.d.ts.map +1 -1
  194. package/lib/typescript/components/ReanimatedDrawerLayout.d.ts +16 -14
  195. package/lib/typescript/components/ReanimatedDrawerLayout.d.ts.map +1 -1
  196. package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeable.d.ts +2 -1
  197. package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeable.d.ts.map +1 -1
  198. package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeableProps.d.ts +30 -34
  199. package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeableProps.d.ts.map +1 -1
  200. package/lib/typescript/components/touchables/GenericTouchable.d.ts.map +1 -1
  201. package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.d.ts.map +1 -1
  202. package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts +0 -1
  203. package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts.map +1 -1
  204. package/lib/typescript/handlers/gestures/flingGesture.d.ts +6 -0
  205. package/lib/typescript/handlers/gestures/flingGesture.d.ts.map +1 -1
  206. package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +3 -3
  207. package/lib/typescript/handlers/gestures/gesture.d.ts +6 -0
  208. package/lib/typescript/handlers/gestures/gesture.d.ts.map +1 -1
  209. package/lib/typescript/handlers/gestures/gestureComposition.d.ts +21 -0
  210. package/lib/typescript/handlers/gestures/gestureComposition.d.ts.map +1 -1
  211. package/lib/typescript/handlers/gestures/gestureObjects.d.ts +27 -1
  212. package/lib/typescript/handlers/gestures/gestureObjects.d.ts.map +1 -1
  213. package/lib/typescript/handlers/gestures/gestureStateManager.d.ts +6 -0
  214. package/lib/typescript/handlers/gestures/gestureStateManager.d.ts.map +1 -1
  215. package/lib/typescript/handlers/gestures/hoverGesture.d.ts +6 -0
  216. package/lib/typescript/handlers/gestures/hoverGesture.d.ts.map +1 -1
  217. package/lib/typescript/handlers/gestures/longPressGesture.d.ts +6 -0
  218. package/lib/typescript/handlers/gestures/longPressGesture.d.ts.map +1 -1
  219. package/lib/typescript/handlers/gestures/manualGesture.d.ts +6 -0
  220. package/lib/typescript/handlers/gestures/manualGesture.d.ts.map +1 -1
  221. package/lib/typescript/handlers/gestures/nativeGesture.d.ts +6 -0
  222. package/lib/typescript/handlers/gestures/nativeGesture.d.ts.map +1 -1
  223. package/lib/typescript/handlers/gestures/panGesture.d.ts +9 -0
  224. package/lib/typescript/handlers/gestures/panGesture.d.ts.map +1 -1
  225. package/lib/typescript/handlers/gestures/pinchGesture.d.ts +9 -0
  226. package/lib/typescript/handlers/gestures/pinchGesture.d.ts.map +1 -1
  227. package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts.map +1 -1
  228. package/lib/typescript/handlers/gestures/rotationGesture.d.ts +6 -0
  229. package/lib/typescript/handlers/gestures/rotationGesture.d.ts.map +1 -1
  230. package/lib/typescript/handlers/gestures/tapGesture.d.ts +6 -0
  231. package/lib/typescript/handlers/gestures/tapGesture.d.ts.map +1 -1
  232. package/lib/typescript/mocks/module.d.ts +1 -1
  233. package/lib/typescript/mocks/module.d.ts.map +1 -1
  234. package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts +2 -2
  235. package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts.map +1 -1
  236. package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts +19 -11
  237. package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts.map +1 -1
  238. package/lib/typescript/v3/NativeProxy.d.ts +1 -1
  239. package/lib/typescript/v3/NativeProxy.d.ts.map +1 -1
  240. package/lib/typescript/v3/NativeProxy.web.d.ts +1 -1
  241. package/lib/typescript/v3/NativeProxy.web.d.ts.map +1 -1
  242. package/lib/typescript/v3/components/GestureButtons.d.ts +1 -37
  243. package/lib/typescript/v3/components/GestureButtons.d.ts.map +1 -1
  244. package/lib/typescript/v3/components/GestureButtonsProps.d.ts +1 -1
  245. package/lib/typescript/v3/components/GestureButtonsProps.d.ts.map +1 -1
  246. package/lib/typescript/v3/components/GestureComponents.d.ts +3 -0
  247. package/lib/typescript/v3/components/GestureComponents.d.ts.map +1 -1
  248. package/lib/typescript/v3/components/GestureComponents.web.d.ts +4 -0
  249. package/lib/typescript/v3/components/GestureComponents.web.d.ts.map +1 -1
  250. package/lib/typescript/v3/components/Pressable.d.ts.map +1 -1
  251. package/lib/typescript/v3/components/Touchable/Touchable.d.ts.map +1 -1
  252. package/lib/typescript/v3/components/Touchable/TouchableProps.d.ts +48 -1
  253. package/lib/typescript/v3/components/Touchable/TouchableProps.d.ts.map +1 -1
  254. package/lib/typescript/v3/detectors/HostGestureDetector.web.d.ts +1 -1
  255. package/lib/typescript/v3/detectors/HostGestureDetector.web.d.ts.map +1 -1
  256. package/lib/typescript/v3/detectors/NativeDetector.d.ts.map +1 -1
  257. package/lib/typescript/v3/detectors/VirtualDetector/InterceptingGestureDetector.d.ts.map +1 -1
  258. package/lib/typescript/v3/detectors/VirtualDetector/VirtualDetector.d.ts.map +1 -1
  259. package/lib/typescript/v3/detectors/useGestureRelationsUpdater.d.ts +3 -0
  260. package/lib/typescript/v3/detectors/useGestureRelationsUpdater.d.ts.map +1 -0
  261. package/lib/typescript/v3/detectors/useNativeGestureRole.d.ts +3 -0
  262. package/lib/typescript/v3/detectors/useNativeGestureRole.d.ts.map +1 -0
  263. package/lib/typescript/v3/detectors/useNativeGestureRole.web.d.ts +3 -0
  264. package/lib/typescript/v3/detectors/useNativeGestureRole.web.d.ts.map +1 -0
  265. package/lib/typescript/v3/detectors/utils.d.ts +3 -3
  266. package/lib/typescript/v3/detectors/utils.d.ts.map +1 -1
  267. package/lib/typescript/v3/hooks/callbacks/useReanimatedEventHandler.d.ts.map +1 -1
  268. package/lib/typescript/v3/hooks/gestures/fling/useFlingGesture.d.ts +1 -1
  269. package/lib/typescript/v3/hooks/gestures/fling/useFlingGesture.d.ts.map +1 -1
  270. package/lib/typescript/v3/hooks/gestures/hover/useHoverGesture.d.ts +1 -1
  271. package/lib/typescript/v3/hooks/gestures/hover/useHoverGesture.d.ts.map +1 -1
  272. package/lib/typescript/v3/hooks/gestures/longPress/useLongPressGesture.d.ts +1 -1
  273. package/lib/typescript/v3/hooks/gestures/longPress/useLongPressGesture.d.ts.map +1 -1
  274. package/lib/typescript/v3/hooks/gestures/manual/useManualGesture.d.ts +1 -1
  275. package/lib/typescript/v3/hooks/gestures/manual/useManualGesture.d.ts.map +1 -1
  276. package/lib/typescript/v3/hooks/gestures/native/NativeTypes.d.ts +7 -0
  277. package/lib/typescript/v3/hooks/gestures/native/NativeTypes.d.ts.map +1 -1
  278. package/lib/typescript/v3/hooks/gestures/native/useNativeGesture.d.ts +1 -1
  279. package/lib/typescript/v3/hooks/gestures/native/useNativeGesture.d.ts.map +1 -1
  280. package/lib/typescript/v3/hooks/gestures/pan/usePanGesture.d.ts +1 -1
  281. package/lib/typescript/v3/hooks/gestures/pan/usePanGesture.d.ts.map +1 -1
  282. package/lib/typescript/v3/hooks/gestures/pinch/usePinchGesture.d.ts +1 -1
  283. package/lib/typescript/v3/hooks/gestures/pinch/usePinchGesture.d.ts.map +1 -1
  284. package/lib/typescript/v3/hooks/gestures/rotation/useRotationGesture.d.ts +1 -1
  285. package/lib/typescript/v3/hooks/gestures/rotation/useRotationGesture.d.ts.map +1 -1
  286. package/lib/typescript/v3/hooks/gestures/tap/useTapGesture.d.ts +1 -1
  287. package/lib/typescript/v3/hooks/gestures/tap/useTapGesture.d.ts.map +1 -1
  288. package/lib/typescript/v3/hooks/useGesture.d.ts.map +1 -1
  289. package/lib/typescript/v3/hooks/utils/configUtils.d.ts +2 -2
  290. package/lib/typescript/v3/hooks/utils/configUtils.d.ts.map +1 -1
  291. package/lib/typescript/v3/hooks/utils/eventHandlersUtils.d.ts.map +1 -1
  292. package/lib/typescript/v3/hooks/utils/index.d.ts +1 -1
  293. package/lib/typescript/v3/hooks/utils/index.d.ts.map +1 -1
  294. package/lib/typescript/v3/hooks/utils/propsWhiteList.d.ts +2 -2
  295. package/lib/typescript/v3/hooks/utils/propsWhiteList.d.ts.map +1 -1
  296. package/lib/typescript/v3/hooks/utils/reanimatedUtils.d.ts +1 -0
  297. package/lib/typescript/v3/hooks/utils/reanimatedUtils.d.ts.map +1 -1
  298. package/lib/typescript/v3/types/ConfigTypes.d.ts +1 -0
  299. package/lib/typescript/v3/types/ConfigTypes.d.ts.map +1 -1
  300. package/lib/typescript/web/constants.d.ts +1 -0
  301. package/lib/typescript/web/constants.d.ts.map +1 -1
  302. package/lib/typescript/web/detectors/RotationGestureDetector.d.ts.map +1 -1
  303. package/lib/typescript/web/detectors/ScaleGestureDetector.d.ts.map +1 -1
  304. package/lib/typescript/web/handlers/GestureHandler.d.ts +8 -2
  305. package/lib/typescript/web/handlers/GestureHandler.d.ts.map +1 -1
  306. package/lib/typescript/web/handlers/HoverGestureHandler.d.ts +1 -1
  307. package/lib/typescript/web/handlers/HoverGestureHandler.d.ts.map +1 -1
  308. package/lib/typescript/web/handlers/IGestureHandler.d.ts +2 -0
  309. package/lib/typescript/web/handlers/IGestureHandler.d.ts.map +1 -1
  310. package/lib/typescript/web/handlers/ManualGestureHandler.d.ts +1 -0
  311. package/lib/typescript/web/handlers/ManualGestureHandler.d.ts.map +1 -1
  312. package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +13 -3
  313. package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts.map +1 -1
  314. package/lib/typescript/web/handlers/PanGestureHandler.d.ts +1 -0
  315. package/lib/typescript/web/handlers/PanGestureHandler.d.ts.map +1 -1
  316. package/lib/typescript/web/handlers/PinchGestureHandler.d.ts +1 -0
  317. package/lib/typescript/web/handlers/PinchGestureHandler.d.ts.map +1 -1
  318. package/lib/typescript/web/handlers/RotationGestureHandler.d.ts +1 -0
  319. package/lib/typescript/web/handlers/RotationGestureHandler.d.ts.map +1 -1
  320. package/lib/typescript/web/interfaces.d.ts +6 -0
  321. package/lib/typescript/web/interfaces.d.ts.map +1 -1
  322. package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts +1 -0
  323. package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts.map +1 -1
  324. package/lib/typescript/web/tools/GestureLifecycleEvents.d.ts +7 -0
  325. package/lib/typescript/web/tools/GestureLifecycleEvents.d.ts.map +1 -0
  326. package/lib/typescript/web/tools/NodeManager.d.ts +7 -0
  327. package/lib/typescript/web/tools/NodeManager.d.ts.map +1 -1
  328. package/lib/typescript/web/tools/PointerEventManager.d.ts.map +1 -1
  329. package/package.json +3 -3
  330. package/src/RNGestureHandlerModule.web.ts +5 -1
  331. package/src/components/GestureButtons.tsx +33 -16
  332. package/src/components/GestureHandlerButton.tsx +70 -8
  333. package/src/components/GestureHandlerButton.web.tsx +184 -48
  334. package/src/components/Pressable/Pressable.tsx +3 -1
  335. package/src/components/Pressable/PressableProps.tsx +2 -1
  336. package/src/components/Pressable/stateDefinitions.ts +3 -0
  337. package/src/components/ReanimatedDrawerLayout.tsx +27 -23
  338. package/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx +51 -5
  339. package/src/components/ReanimatedSwipeable/ReanimatedSwipeableProps.ts +31 -39
  340. package/src/components/touchables/GenericTouchable.tsx +2 -5
  341. package/src/handlers/gestures/GestureDetector/useDetectorUpdater.ts +1 -2
  342. package/src/handlers/gestures/GestureDetector/utils.ts +11 -53
  343. package/src/handlers/gestures/flingGesture.ts +6 -0
  344. package/src/handlers/gestures/forceTouchGesture.ts +3 -3
  345. package/src/handlers/gestures/gesture.ts +6 -0
  346. package/src/handlers/gestures/gestureComposition.ts +21 -0
  347. package/src/handlers/gestures/gestureObjects.ts +27 -1
  348. package/src/handlers/gestures/gestureStateManager.ts +6 -0
  349. package/src/handlers/gestures/hoverGesture.ts +6 -0
  350. package/src/handlers/gestures/longPressGesture.ts +6 -0
  351. package/src/handlers/gestures/manualGesture.ts +6 -0
  352. package/src/handlers/gestures/nativeGesture.ts +6 -0
  353. package/src/handlers/gestures/panGesture.ts +9 -0
  354. package/src/handlers/gestures/pinchGesture.ts +9 -0
  355. package/src/handlers/gestures/reanimatedWrapper.ts +20 -2
  356. package/src/handlers/gestures/rotationGesture.ts +6 -0
  357. package/src/handlers/gestures/tapGesture.ts +6 -0
  358. package/src/mocks/module.tsx +4 -2
  359. package/src/specs/NativeRNGestureHandlerModule.ts +2 -4
  360. package/src/specs/RNGestureHandlerButtonNativeComponent.ts +28 -13
  361. package/src/v3/NativeProxy.ts +9 -7
  362. package/src/v3/NativeProxy.web.ts +2 -2
  363. package/src/v3/components/GestureButtons.tsx +18 -10
  364. package/src/v3/components/GestureButtonsProps.ts +1 -0
  365. package/src/v3/components/Pressable.tsx +2 -1
  366. package/src/v3/components/Touchable/Touchable.tsx +144 -50
  367. package/src/v3/components/Touchable/TouchableProps.ts +64 -2
  368. package/src/v3/detectors/HostGestureDetector.web.tsx +268 -108
  369. package/src/v3/detectors/NativeDetector.tsx +3 -2
  370. package/src/v3/detectors/VirtualDetector/InterceptingGestureDetector.tsx +3 -4
  371. package/src/v3/detectors/VirtualDetector/VirtualDetector.tsx +5 -2
  372. package/src/v3/detectors/useGestureRelationsUpdater.ts +30 -0
  373. package/src/v3/detectors/useNativeGestureRole.ts +8 -0
  374. package/src/v3/detectors/useNativeGestureRole.web.ts +42 -0
  375. package/src/v3/detectors/utils.ts +28 -12
  376. package/src/v3/hooks/callbacks/useReanimatedEventHandler.ts +23 -7
  377. package/src/v3/hooks/gestures/fling/useFlingGesture.ts +5 -1
  378. package/src/v3/hooks/gestures/hover/useHoverGesture.ts +5 -1
  379. package/src/v3/hooks/gestures/longPress/useLongPressGesture.ts +3 -1
  380. package/src/v3/hooks/gestures/manual/useManualGesture.ts +5 -1
  381. package/src/v3/hooks/gestures/native/NativeTypes.ts +13 -1
  382. package/src/v3/hooks/gestures/native/useNativeGesture.ts +5 -1
  383. package/src/v3/hooks/gestures/pan/usePanGesture.ts +5 -1
  384. package/src/v3/hooks/gestures/pinch/usePinchGesture.ts +5 -1
  385. package/src/v3/hooks/gestures/rotation/useRotationGesture.ts +3 -1
  386. package/src/v3/hooks/gestures/tap/useTapGesture.ts +5 -1
  387. package/src/v3/hooks/useGesture.ts +4 -18
  388. package/src/v3/hooks/utils/configUtils.ts +18 -8
  389. package/src/v3/hooks/utils/eventHandlersUtils.ts +43 -32
  390. package/src/v3/hooks/utils/index.ts +0 -1
  391. package/src/v3/hooks/utils/propsWhiteList.ts +1 -0
  392. package/src/v3/hooks/utils/reanimatedUtils.ts +10 -10
  393. package/src/v3/types/ConfigTypes.ts +1 -0
  394. package/src/web/constants.ts +1 -0
  395. package/src/web/detectors/RotationGestureDetector.ts +19 -5
  396. package/src/web/detectors/ScaleGestureDetector.ts +9 -3
  397. package/src/web/handlers/GestureHandler.ts +36 -6
  398. package/src/web/handlers/HoverGestureHandler.ts +2 -5
  399. package/src/web/handlers/IGestureHandler.ts +2 -0
  400. package/src/web/handlers/ManualGestureHandler.ts +2 -0
  401. package/src/web/handlers/NativeViewGestureHandler.ts +122 -19
  402. package/src/web/handlers/PanGestureHandler.ts +2 -0
  403. package/src/web/handlers/PinchGestureHandler.ts +5 -7
  404. package/src/web/handlers/RotationGestureHandler.ts +5 -5
  405. package/src/web/interfaces.ts +7 -0
  406. package/src/web/tools/GestureHandlerOrchestrator.ts +11 -3
  407. package/src/web/tools/GestureLifecycleEvents.ts +14 -0
  408. package/src/web/tools/NodeManager.ts +57 -0
  409. package/src/web/tools/PointerEventManager.ts +12 -0
  410. package/lib/module/RNRenderer.js +0 -6
  411. package/lib/module/RNRenderer.js.map +0 -1
  412. package/lib/module/RNRenderer.web.js +0 -6
  413. package/lib/module/RNRenderer.web.js.map +0 -1
  414. package/lib/typescript/RNRenderer.d.ts +0 -2
  415. package/lib/typescript/RNRenderer.d.ts.map +0 -1
  416. package/lib/typescript/RNRenderer.web.d.ts +0 -4
  417. package/lib/typescript/RNRenderer.web.d.ts.map +0 -1
  418. package/src/RNRenderer.ts +0 -3
  419. package/src/RNRenderer.web.ts +0 -3
@@ -9,25 +9,26 @@ import {
9
9
  isComposedGesture,
10
10
  prepareRelations,
11
11
  } from '../hooks/utils/relationUtils';
12
- import { NativeProxy } from '../NativeProxy';
13
- import type { Gesture } from '../types';
12
+ import type { Gesture, GestureRelations } from '../types';
14
13
  import { ComposedGestureName } from '../types';
15
14
 
16
15
  // The tree consists of ComposedGestures and NativeGestures. NativeGestures are always leaf nodes.
17
16
  export const traverseAndConfigureRelations = (
18
17
  node: Gesture,
18
+ relationsByTag: Map<number, GestureRelations>,
19
19
  simultaneousHandlers: Set<number>,
20
20
  waitFor: number[] = []
21
21
  ) => {
22
22
  // If we are in the leaf node, we want to fill gesture relations arrays with current
23
- // waitFor and simultaneousHandlers. We also want to configure relations on the native side.
23
+ // waitFor and simultaneousHandlers. We also want to record the resulting relations for
24
+ // this handler so the caller can push them to the native side.
24
25
  if (!isComposedGesture(node)) {
25
26
  node.gestureRelations = prepareRelations(node.config, node.handlerTag);
26
27
 
27
28
  node.gestureRelations.simultaneousHandlers.push(...simultaneousHandlers);
28
29
  node.gestureRelations.waitFor.push(...waitFor);
29
30
 
30
- NativeProxy.configureRelations(node.handlerTag, {
31
+ relationsByTag.set(node.handlerTag, {
31
32
  waitFor: node.gestureRelations.waitFor,
32
33
  simultaneousHandlers: node.gestureRelations.simultaneousHandlers,
33
34
  blocksHandlers: node.gestureRelations.blocksHandlers,
@@ -73,7 +74,12 @@ export const traverseAndConfigureRelations = (
73
74
  const length = waitFor.length;
74
75
 
75
76
  // We traverse the child, passing the current `waitFor` and `simultaneousHandlers`.
76
- traverseAndConfigureRelations(child, simultaneousHandlers, waitFor);
77
+ traverseAndConfigureRelations(
78
+ child,
79
+ relationsByTag,
80
+ simultaneousHandlers,
81
+ waitFor
82
+ );
77
83
 
78
84
  // After traversing the child, we need to update `waitFor` and `simultaneousHandlers`
79
85
 
@@ -122,7 +128,12 @@ export const traverseAndConfigureRelations = (
122
128
  // We don't want to mark gesture as simultaneous with itself, so we remove its tag from the set.
123
129
  const hasRemovedTag = simultaneousHandlers.delete(child.handlerTag);
124
130
 
125
- traverseAndConfigureRelations(child, simultaneousHandlers, waitFor);
131
+ traverseAndConfigureRelations(
132
+ child,
133
+ relationsByTag,
134
+ simultaneousHandlers,
135
+ waitFor
136
+ );
126
137
 
127
138
  if (hasRemovedTag) {
128
139
  simultaneousHandlers.add(child.handlerTag);
@@ -138,7 +149,9 @@ export const traverseAndConfigureRelations = (
138
149
 
139
150
  export function configureRelations<TConfig, THandlerData>(
140
151
  gesture: Gesture<TConfig, THandlerData>
141
- ) {
152
+ ): Map<number, GestureRelations> {
153
+ const relationsByTag = new Map<number, GestureRelations>();
154
+
142
155
  if (isComposedGesture(gesture)) {
143
156
  const simultaneousHandlers = new Set<number>(
144
157
  gesture.externalSimultaneousHandlers
@@ -151,13 +164,16 @@ export function configureRelations<TConfig, THandlerData>(
151
164
  );
152
165
  }
153
166
 
154
- traverseAndConfigureRelations(gesture, simultaneousHandlers);
155
- } else {
156
- NativeProxy.configureRelations(
157
- gesture.handlerTag,
158
- gesture.gestureRelations
167
+ traverseAndConfigureRelations(
168
+ gesture,
169
+ relationsByTag,
170
+ simultaneousHandlers
159
171
  );
172
+ } else {
173
+ relationsByTag.set(gesture.handlerTag, gesture.gestureRelations);
160
174
  }
175
+
176
+ return relationsByTag;
161
177
  }
162
178
 
163
179
  export function ensureNativeDetectorComponent(
@@ -1,4 +1,4 @@
1
- import { useMemo } from 'react';
1
+ import { useEffect, useMemo, useRef } from 'react';
2
2
 
3
3
  import type { ReanimatedHandler } from '../../../handlers/gestures/reanimatedWrapper';
4
4
  import { Reanimated } from '../../../handlers/gestures/reanimatedWrapper';
@@ -10,6 +10,12 @@ import type {
10
10
  } from '../../types';
11
11
  import { eventHandler } from './eventHandler';
12
12
 
13
+ const REANIMATED_EVENT_NAMES = [
14
+ 'onGestureHandlerReanimatedEvent',
15
+ 'onGestureHandlerReanimatedStateChange',
16
+ 'onGestureHandlerReanimatedTouchEvent',
17
+ ];
18
+
13
19
  const workletNOOP = () => {
14
20
  'worklet';
15
21
  // no-op
@@ -59,14 +65,24 @@ export function useReanimatedEventHandler<
59
65
  );
60
66
  };
61
67
 
68
+ // Fast Refresh invalidates `useMemo` caches but preserves `useRef`, so the
69
+ // `handlerTag` computed with `useMemo([])` in `useGesture` can regenerate
70
+ // on FR. Without forcing a rebuild, the registered worklet keeps the old
71
+ // `handlerTag` in its closure and `isEventForHandlerWithTag` rejects every
72
+ // event emitted by the freshly-created native handler.
73
+ const prevHandlerTagRef = useRef(handlerTag);
74
+ const handlerTagChanged = prevHandlerTagRef.current !== handlerTag;
75
+
76
+ // Write after commit so interrupted or re-invoked renders don't desync the
77
+ // ref from what was actually committed.
78
+ useEffect(() => {
79
+ prevHandlerTagRef.current = handlerTag;
80
+ }, [handlerTag]);
81
+
62
82
  const reanimatedEvent = Reanimated?.useEvent(
63
83
  callback,
64
- [
65
- 'onGestureHandlerReanimatedEvent',
66
- 'onGestureHandlerReanimatedStateChange',
67
- 'onGestureHandlerReanimatedTouchEvent',
68
- ],
69
- !!reanimatedHandler?.doDependenciesDiffer
84
+ REANIMATED_EVENT_NAMES,
85
+ handlerTagChanged || !!reanimatedHandler?.doDependenciesDiffer
70
86
  );
71
87
 
72
88
  return reanimatedEvent;
@@ -8,7 +8,11 @@ import type {
8
8
  FlingHandlerData,
9
9
  } from './FlingTypes';
10
10
 
11
- export function useFlingGesture(config: FlingGestureConfig): FlingGesture {
11
+ const EMPTY_FLING_CONFIG: FlingGestureConfig = {};
12
+
13
+ export function useFlingGesture(
14
+ config: FlingGestureConfig = EMPTY_FLING_CONFIG
15
+ ): FlingGesture {
12
16
  const flingConfig = useClonedAndRemappedConfig<
13
17
  FlingGestureProperties,
14
18
  FlingHandlerData
@@ -44,7 +44,11 @@ function transformHoverProps(
44
44
 
45
45
  const HoverPropsMapping = new Map<string, string>([['effect', 'hoverEffect']]);
46
46
 
47
- export function useHoverGesture(config: HoverGestureConfig): HoverGesture {
47
+ const EMPTY_HOVER_CONFIG: HoverGestureConfig = {};
48
+
49
+ export function useHoverGesture(
50
+ config: HoverGestureConfig = EMPTY_HOVER_CONFIG
51
+ ): HoverGesture {
48
52
  const hoverConfig = useClonedAndRemappedConfig<
49
53
  HoverGestureProperties,
50
54
  HoverHandlerData,
@@ -28,8 +28,10 @@ function transformLongPressProps(
28
28
  return config;
29
29
  }
30
30
 
31
+ const EMPTY_LONG_PRESS_CONFIG: LongPressGestureConfig = {};
32
+
31
33
  export function useLongPressGesture(
32
- config: LongPressGestureConfig
34
+ config: LongPressGestureConfig = EMPTY_LONG_PRESS_CONFIG
33
35
  ): LongPressGesture {
34
36
  const longPressConfig = useClonedAndRemappedConfig<
35
37
  LongPressGestureProperties,
@@ -8,7 +8,11 @@ import type {
8
8
  ManualHandlerData,
9
9
  } from './ManualTypes';
10
10
 
11
- export function useManualGesture(config: ManualGestureConfig): ManualGesture {
11
+ const EMPTY_MANUAL_CONFIG: ManualGestureConfig = {};
12
+
13
+ export function useManualGesture(
14
+ config: ManualGestureConfig = EMPTY_MANUAL_CONFIG
15
+ ): ManualGesture {
12
16
  const manualConfig = useClonedAndRemappedConfig<
13
17
  ManualGestureProperties,
14
18
  ManualHandlerData
@@ -20,11 +20,23 @@ export type NativeGestureNativeProperties = {
20
20
  * `NativeViewGestureHandler` receives an `ACTIVE` state event.
21
21
  */
22
22
  disallowInterruption?: boolean;
23
+
24
+ /**
25
+ * Composes with `disallowInterruption`. When both are `true`, the handler still
26
+ * resists discrete gestures but yields to continuous gestures, so a wrapping
27
+ * gesture can take over the touch stream. No-op when `disallowInterruption` is
28
+ * `false`.
29
+ */
30
+ yieldsToContinuousGestures?: boolean;
23
31
  };
24
32
 
25
33
  export const NativeHandlerNativeProperties = new Set<
26
34
  keyof NativeGestureNativeProperties
27
- >(['shouldActivateOnStart', 'disallowInterruption']);
35
+ >([
36
+ 'shouldActivateOnStart',
37
+ 'disallowInterruption',
38
+ 'yieldsToContinuousGestures',
39
+ ]);
28
40
 
29
41
  export type NativeHandlerData = {
30
42
  pointerInside: boolean;
@@ -8,7 +8,11 @@ import type {
8
8
  NativeHandlerData,
9
9
  } from './NativeTypes';
10
10
 
11
- export function useNativeGesture(config: NativeGestureConfig): NativeGesture {
11
+ const EMPTY_NATIVE_CONFIG: NativeGestureConfig = {};
12
+
13
+ export function useNativeGesture(
14
+ config: NativeGestureConfig = EMPTY_NATIVE_CONFIG
15
+ ): NativeGesture {
12
16
  const nativeConfig = useClonedAndRemappedConfig<
13
17
  NativeGestureProperties,
14
18
  NativeHandlerData
@@ -139,7 +139,11 @@ function transformPanProps(
139
139
  return config;
140
140
  }
141
141
 
142
- export function usePanGesture(config: PanGestureConfig): PanGesture {
142
+ const EMPTY_PAN_CONFIG: PanGestureConfig = {};
143
+
144
+ export function usePanGesture(
145
+ config: PanGestureConfig = EMPTY_PAN_CONFIG
146
+ ): PanGesture {
143
147
  if (__DEV__) {
144
148
  validatePanConfig(config);
145
149
  }
@@ -40,7 +40,11 @@ function transformPinchProps(
40
40
 
41
41
  const PinchPropsMapping = new Map<string, string>();
42
42
 
43
- export function usePinchGesture(config: PinchGestureConfig): PinchGesture {
43
+ const EMPTY_PINCH_CONFIG: PinchGestureConfig = {};
44
+
45
+ export function usePinchGesture(
46
+ config: PinchGestureConfig = EMPTY_PINCH_CONFIG
47
+ ): PinchGesture {
44
48
  const pinchConfig = useClonedAndRemappedConfig<
45
49
  PinchGestureProperties,
46
50
  PinchHandlerData,
@@ -42,8 +42,10 @@ function transformRotationProps(
42
42
 
43
43
  const RotationPropsMapping = new Map<string, string>();
44
44
 
45
+ const EMPTY_ROTATION_CONFIG: RotationGestureConfig = {};
46
+
45
47
  export function useRotationGesture(
46
- config: RotationGestureConfig
48
+ config: RotationGestureConfig = EMPTY_ROTATION_CONFIG
47
49
  ): RotationGesture {
48
50
  const rotationConfig = useClonedAndRemappedConfig<
49
51
  RotationGestureProperties,
@@ -18,7 +18,11 @@ const TapPropsMapping = new Map<
18
18
  ['maxDelay', 'maxDelayMs'],
19
19
  ]);
20
20
 
21
- export function useTapGesture(config: TapGestureConfig): TapGesture {
21
+ const EMPTY_TAP_CONFIG: TapGestureConfig = {};
22
+
23
+ export function useTapGesture(
24
+ config: TapGestureConfig = EMPTY_TAP_CONFIG
25
+ ): TapGesture {
22
26
  const tapConfig = useClonedAndRemappedConfig<
23
27
  TapGestureProperties,
24
28
  TapHandlerData,
@@ -1,4 +1,4 @@
1
- import { useEffect, useMemo, useRef } from 'react';
1
+ import { useEffect, useMemo } from 'react';
2
2
 
3
3
  import { getNextHandlerTag } from '../../handlers/getNextHandlerTag';
4
4
  import {
@@ -16,7 +16,6 @@ import type {
16
16
  import { useGestureCallbacks } from './useGestureCallbacks';
17
17
  import {
18
18
  bindSharedValues,
19
- prepareConfig,
20
19
  prepareConfigForNativeSide,
21
20
  prepareRelations,
22
21
  unbindSharedValues,
@@ -41,9 +40,6 @@ export function useGesture<
41
40
  );
42
41
  }
43
42
 
44
- // This has to be done ASAP as other hooks depend `shouldUseReanimatedDetector`.
45
- prepareConfig(config);
46
-
47
43
  // TODO: Call only necessary hooks depending on which callbacks are defined (?)
48
44
  const { jsEventHandler, reanimatedEventHandler, animatedEventHandler } =
49
45
  useGestureCallbacks(handlerTag, config);
@@ -65,15 +61,6 @@ export function useGesture<
65
61
  [handlerTag, config.simultaneousWith, config.requireToFail, config.block]
66
62
  );
67
63
 
68
- const currentGestureRef = useRef({ type: '', handlerTag: -1 });
69
- if (
70
- currentGestureRef.current.handlerTag !== handlerTag ||
71
- currentGestureRef.current.type !== (type as string)
72
- ) {
73
- currentGestureRef.current = { type, handlerTag };
74
- NativeProxy.createGestureHandler(type, handlerTag, {});
75
- }
76
-
77
64
  const gesture = useMemo(
78
65
  () => ({
79
66
  handlerTag,
@@ -98,11 +85,10 @@ export function useGesture<
98
85
  );
99
86
 
100
87
  useEffect(() => {
101
- return () => {
102
- if (currentGestureRef.current.handlerTag === handlerTag) {
103
- currentGestureRef.current = { type: '', handlerTag: -1 };
104
- }
88
+ NativeProxy.createGestureHandler(type, handlerTag, {});
89
+ scheduleFlushOperations();
105
90
 
91
+ return () => {
106
92
  NativeProxy.dropGestureHandler(handlerTag);
107
93
  scheduleFlushOperations();
108
94
  };
@@ -16,7 +16,7 @@ import {
16
16
  } from './propsWhiteList';
17
17
  import { hasWorkletEventHandlers, maybeUnpackValue } from './reanimatedUtils';
18
18
 
19
- export function prepareConfig<
19
+ export function resolveInternalConfigProps<
20
20
  TConfig extends object,
21
21
  THandlerData,
22
22
  TExtendedHandlerData extends THandlerData,
@@ -87,9 +87,8 @@ export function prepareConfigForNativeSide<
87
87
  for (const [key, value] of Object.entries(config)) {
88
88
  // @ts-ignore That's the point, we want to see if key exists in the whitelists
89
89
  if (allowedNativeProps.has(key) || handlerPropsWhiteList.has(key)) {
90
- Object.assign(filteredConfig, {
91
- [key]: Reanimated?.isSharedValue(value) ? value.value : value,
92
- });
90
+ (filteredConfig as Record<string, unknown>)[key] =
91
+ Reanimated?.isSharedValue(value) ? value.value : value;
93
92
  } else if (PropsToFilter.has(key)) {
94
93
  continue;
95
94
  } else {
@@ -125,7 +124,7 @@ function remapProps<
125
124
  TInternalConfig extends Record<string, unknown>,
126
125
  >(
127
126
  config: TConfig & TInternalConfig,
128
- propsMapping: Map<string, string>
127
+ propsMapping: ReadonlyMap<string, string>
129
128
  ): TInternalConfig {
130
129
  type MergedConfig = TConfig & TInternalConfig;
131
130
 
@@ -142,6 +141,11 @@ function remapProps<
142
141
  return config;
143
142
  }
144
143
 
144
+ const DEFAULT_PROPS_MAPPING = new Map<string, string>();
145
+ const DEFAULT_PROPS_TRANSFORMER = <TConfig extends object>(
146
+ config: TConfig
147
+ ): TConfig => config;
148
+
145
149
  export function useClonedAndRemappedConfig<
146
150
  TConfig extends Record<string, unknown>,
147
151
  THandlerData,
@@ -151,8 +155,10 @@ export function useClonedAndRemappedConfig<
151
155
  config: ExcludeInternalConfigProps<
152
156
  BaseGestureConfig<TConfig, THandlerData, TExtendedHandlerData>
153
157
  >,
154
- propsMapping: Map<string, string> = new Map(),
155
- propsTransformer: (config: TInternalConfig) => TInternalConfig = (cfg) => cfg
158
+ propsMapping: ReadonlyMap<string, string> = DEFAULT_PROPS_MAPPING,
159
+ propsTransformer: (
160
+ config: TInternalConfig
161
+ ) => TInternalConfig = DEFAULT_PROPS_TRANSFORMER
156
162
  ): BaseGestureConfig<TInternalConfig, THandlerData, TExtendedHandlerData> {
157
163
  return useMemo(() => {
158
164
  const clonedConfig = cloneConfig<
@@ -161,11 +167,15 @@ export function useClonedAndRemappedConfig<
161
167
  TExtendedHandlerData
162
168
  >(config);
163
169
 
164
- return propsTransformer(
170
+ const transformedConfig = propsTransformer(
165
171
  remapProps<TConfig, TInternalConfig>(
166
172
  clonedConfig as TConfig & TInternalConfig,
167
173
  propsMapping
168
174
  )
169
175
  );
176
+
177
+ resolveInternalConfigProps(transformedConfig);
178
+
179
+ return transformedConfig;
170
180
  }, [config, propsMapping, propsTransformer]);
171
181
  }
@@ -16,38 +16,49 @@ export function useMemoizedGestureCallbacks<
16
16
  >(
17
17
  callbacks: GestureCallbacks<THandlerData, TExtendedHandlerData>
18
18
  ): GestureCallbacks<THandlerData, TExtendedHandlerData> {
19
- return useMemo(
20
- () => ({
21
- ...(callbacks.onBegin ? { onBegin: callbacks.onBegin } : {}),
22
- ...(callbacks.onActivate ? { onActivate: callbacks.onActivate } : {}),
23
- ...(callbacks.onDeactivate
24
- ? { onDeactivate: callbacks.onDeactivate }
25
- : {}),
26
- ...(callbacks.onFinalize ? { onFinalize: callbacks.onFinalize } : {}),
27
- ...(callbacks.onUpdate ? { onUpdate: callbacks.onUpdate } : {}),
28
- ...(callbacks.onTouchesDown
29
- ? { onTouchesDown: callbacks.onTouchesDown }
30
- : {}),
31
- ...(callbacks.onTouchesMove
32
- ? { onTouchesMove: callbacks.onTouchesMove }
33
- : {}),
34
- ...(callbacks.onTouchesUp ? { onTouchesUp: callbacks.onTouchesUp } : {}),
35
- ...(callbacks.onTouchesCancel
36
- ? { onTouchesCancel: callbacks.onTouchesCancel }
37
- : {}),
38
- }),
39
- [
40
- callbacks.onActivate,
41
- callbacks.onBegin,
42
- callbacks.onDeactivate,
43
- callbacks.onFinalize,
44
- callbacks.onTouchesCancel,
45
- callbacks.onTouchesDown,
46
- callbacks.onTouchesMove,
47
- callbacks.onTouchesUp,
48
- callbacks.onUpdate,
49
- ]
50
- );
19
+ return useMemo(() => {
20
+ const memoized: GestureCallbacks<THandlerData, TExtendedHandlerData> = {};
21
+
22
+ if (callbacks.onBegin) {
23
+ memoized.onBegin = callbacks.onBegin;
24
+ }
25
+ if (callbacks.onActivate) {
26
+ memoized.onActivate = callbacks.onActivate;
27
+ }
28
+ if (callbacks.onDeactivate) {
29
+ memoized.onDeactivate = callbacks.onDeactivate;
30
+ }
31
+ if (callbacks.onFinalize) {
32
+ memoized.onFinalize = callbacks.onFinalize;
33
+ }
34
+ if (callbacks.onUpdate) {
35
+ memoized.onUpdate = callbacks.onUpdate;
36
+ }
37
+ if (callbacks.onTouchesDown) {
38
+ memoized.onTouchesDown = callbacks.onTouchesDown;
39
+ }
40
+ if (callbacks.onTouchesMove) {
41
+ memoized.onTouchesMove = callbacks.onTouchesMove;
42
+ }
43
+ if (callbacks.onTouchesUp) {
44
+ memoized.onTouchesUp = callbacks.onTouchesUp;
45
+ }
46
+ if (callbacks.onTouchesCancel) {
47
+ memoized.onTouchesCancel = callbacks.onTouchesCancel;
48
+ }
49
+
50
+ return memoized;
51
+ }, [
52
+ callbacks.onActivate,
53
+ callbacks.onBegin,
54
+ callbacks.onDeactivate,
55
+ callbacks.onFinalize,
56
+ callbacks.onTouchesCancel,
57
+ callbacks.onTouchesDown,
58
+ callbacks.onTouchesMove,
59
+ callbacks.onTouchesUp,
60
+ callbacks.onUpdate,
61
+ ]);
51
62
  }
52
63
 
53
64
  function getHandler<THandlerData, TExtendedHandlerData extends THandlerData>(
@@ -1,5 +1,4 @@
1
1
  export {
2
- prepareConfig,
3
2
  prepareConfigForNativeSide,
4
3
  useClonedAndRemappedConfig,
5
4
  } from './configUtils';
@@ -23,6 +23,7 @@ const CommonConfig = new Set<keyof CommonGestureConfig>([
23
23
  'mouseButton',
24
24
  'testID',
25
25
  'cancelsTouchesInView',
26
+ 'cancelsJSResponder',
26
27
  'manualActivation',
27
28
  ]);
28
29
 
@@ -2,7 +2,6 @@ import { Reanimated } from '../../../handlers/gestures/reanimatedWrapper';
2
2
  import { NativeProxy } from '../../NativeProxy';
3
3
  import type {
4
4
  BaseGestureConfig,
5
- GestureCallbacks,
6
5
  SharedValue,
7
6
  SharedValueOrT,
8
7
  } from '../../types';
@@ -21,7 +20,7 @@ function hash(str: string) {
21
20
  return h >>> 0;
22
21
  }
23
22
 
24
- const SHARED_VALUE_OFFSET = 1.618;
23
+ export const SHARED_VALUE_OFFSET = 1.618;
25
24
 
26
25
  // Don't transfer entire NativeProxy to the UI thread
27
26
  const { updateGestureHandlerConfig } = NativeProxy;
@@ -101,14 +100,15 @@ export function hasWorkletEventHandlers<
101
100
  THandlerData,
102
101
  TExtendedHandlerData extends THandlerData,
103
102
  >(config: BaseGestureConfig<TConfig, THandlerData, TExtendedHandlerData>) {
104
- return Object.entries(config).some(
105
- ([key, value]) =>
106
- HandlerCallbacks.has(
107
- key as keyof GestureCallbacks<THandlerData, TExtendedHandlerData>
108
- ) &&
109
- typeof value === 'function' &&
110
- '__workletHash' in value
111
- );
103
+ for (const key of HandlerCallbacks) {
104
+ const value = config[key];
105
+
106
+ if (typeof value === 'function' && '__workletHash' in value) {
107
+ return true;
108
+ }
109
+ }
110
+
111
+ return false;
112
112
  }
113
113
 
114
114
  export function maybeUnpackValue<T>(
@@ -77,6 +77,7 @@ export type CommonGestureConfig = {
77
77
  activeCursor?: ActiveCursor | undefined;
78
78
  mouseButton?: MouseButton | undefined;
79
79
  cancelsTouchesInView?: boolean | undefined;
80
+ cancelsJSResponder?: boolean | undefined;
80
81
  manualActivation?: boolean | undefined;
81
82
  },
82
83
  ActiveCursor | MouseButton
@@ -1,2 +1,3 @@
1
1
  export const DEFAULT_TOUCH_SLOP = 15;
2
2
  export const MINIMAL_RECOGNIZABLE_MAGNITUDE = 0.1;
3
+ export const NATIVE_GESTURE_ROLE_ATTRIBUTE = 'rngh-role';
@@ -84,15 +84,23 @@ export default class RotationGestureDetector
84
84
  this.onRotationEnd(this);
85
85
  }
86
86
 
87
- private setKeyPointers(tracker: PointerTracker): void {
87
+ private setKeyPointers(tracker: PointerTracker, excludeId?: number): void {
88
88
  if (this.keyPointers[0] && this.keyPointers[1]) {
89
89
  return;
90
90
  }
91
91
 
92
- const pointerIDs: IterableIterator<number> = tracker.trackedPointers.keys();
92
+ let assigned = 0;
93
93
 
94
- this.keyPointers[0] = pointerIDs.next().value as number;
95
- this.keyPointers[1] = pointerIDs.next().value as number;
94
+ for (const id of tracker.trackedPointers.keys()) {
95
+ if (id === excludeId) {
96
+ continue;
97
+ }
98
+
99
+ this.keyPointers[assigned++] = id;
100
+ if (assigned === 2) {
101
+ break;
102
+ }
103
+ }
96
104
  }
97
105
 
98
106
  public onTouchEvent(event: AdaptedEvent, tracker: PointerTracker): boolean {
@@ -132,7 +140,13 @@ export default class RotationGestureDetector
132
140
  }
133
141
 
134
142
  if (this.keyPointers.indexOf(event.pointerId) >= 0) {
135
- this.finish();
143
+ if (tracker.trackedPointersCount <= 2) {
144
+ this.reset();
145
+ } else {
146
+ this.keyPointers = [NaN, NaN];
147
+ this.setKeyPointers(tracker, event.pointerId);
148
+ this.previousAngle = NaN;
149
+ }
136
150
  }
137
151
 
138
152
  break;
@@ -44,10 +44,16 @@ export default class ScaleGestureDetector implements ScaleGestureListener {
44
44
  const action: EventTypes = event.eventType;
45
45
  const numOfPointers = tracker.trackedPointersCount;
46
46
 
47
+ // When the last second pointer lifts (going down to 1), pause without
48
+ // touching span/time state so the gesture resumes cleanly on re-add.
49
+ // When 3+ → 2+ pointers, fall through so configChanged resets the span
50
+ // baseline to the remaining pointer set and avoids a scale jump.
51
+ if (action === EventTypes.ADDITIONAL_POINTER_UP && numOfPointers <= 2) {
52
+ return true;
53
+ }
54
+
47
55
  const streamComplete: boolean =
48
- action === EventTypes.UP ||
49
- action === EventTypes.ADDITIONAL_POINTER_UP ||
50
- action === EventTypes.CANCEL;
56
+ action === EventTypes.UP || action === EventTypes.CANCEL;
51
57
 
52
58
  if (action === EventTypes.DOWN || streamComplete) {
53
59
  if (this.inProgress) {