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
@@ -18,31 +18,42 @@ import type {
18
18
  LegacyRectButtonProps,
19
19
  RectButtonWithRefProps,
20
20
  } from './GestureButtonsProps';
21
- import GestureHandlerButton from './GestureHandlerButton';
21
+ import GestureHandlerButton, { type ButtonProps } from './GestureHandlerButton';
22
22
 
23
- /**
24
- * @deprecated use `RawButton` instead
25
- */
26
- export const LegacyRawButton = createNativeWrapper<LegacyRawButtonProps>(
27
- GestureHandlerButton as unknown as HostComponent<LegacyRawButtonProps>,
23
+ type LegacyRawButtonInnerProps = LegacyRawButtonProps & {
24
+ needsOffscreenAlphaCompositing?: boolean;
25
+ };
26
+
27
+ const LegacyRawButtonInner = createNativeWrapper<LegacyRawButtonInnerProps>(
28
+ GestureHandlerButton as unknown as HostComponent<LegacyRawButtonInnerProps>,
28
29
  {
29
30
  shouldCancelWhenOutside: false,
30
- shouldActivateOnStart: false,
31
+ shouldActivateOnStart: Platform.OS === 'web',
31
32
  }
32
33
  );
33
34
 
35
+ /**
36
+ * @deprecated use `RawButton` instead
37
+ */
38
+ export const LegacyRawButton = (
39
+ props: Omit<
40
+ React.ComponentProps<typeof LegacyRawButtonInner>,
41
+ 'needsOffscreenAlphaCompositing'
42
+ >
43
+ ) => <LegacyRawButtonInner {...props} needsOffscreenAlphaCompositing />;
44
+
34
45
  class InnerBaseButton extends React.Component<BaseButtonWithRefProps> {
35
46
  static defaultProps = {
36
47
  delayLongPress: 600,
37
48
  };
38
49
 
39
- private lastActive: boolean;
50
+ private lastIsPressed: boolean;
40
51
  private longPressTimeout: ReturnType<typeof setTimeout> | undefined;
41
52
  private longPressDetected: boolean;
42
53
 
43
54
  constructor(props: BaseButtonWithRefProps) {
44
55
  super(props);
45
- this.lastActive = false;
56
+ this.lastIsPressed = false;
46
57
  this.longPressDetected = false;
47
58
  }
48
59
 
@@ -50,23 +61,24 @@ class InnerBaseButton extends React.Component<BaseButtonWithRefProps> {
50
61
  nativeEvent,
51
62
  }: HandlerStateChangeEvent<NativeViewGestureHandlerPayload>) => {
52
63
  const { state, oldState, pointerInside } = nativeEvent;
53
- const active = pointerInside && state === State.ACTIVE;
64
+ const isPressed =
65
+ pointerInside && (state === State.BEGAN || state === State.ACTIVE);
54
66
 
55
- if (active !== this.lastActive && this.props.onActiveStateChange) {
56
- this.props.onActiveStateChange(active);
67
+ if (isPressed !== this.lastIsPressed && this.props.onActiveStateChange) {
68
+ this.props.onActiveStateChange(isPressed);
57
69
  }
58
70
 
59
71
  if (
60
72
  !this.longPressDetected &&
61
73
  oldState === State.ACTIVE &&
62
74
  state !== State.CANCELLED &&
63
- this.lastActive &&
75
+ this.lastIsPressed &&
64
76
  this.props.onPress
65
77
  ) {
66
78
  this.props.onPress(pointerInside);
67
79
  }
68
80
 
69
- if (!this.lastActive && state === State.BEGAN && pointerInside) {
81
+ if (!this.lastIsPressed && state === State.BEGAN && pointerInside) {
70
82
  this.longPressDetected = false;
71
83
  if (this.props.onLongPress) {
72
84
  this.longPressTimeout = setTimeout(
@@ -93,7 +105,7 @@ class InnerBaseButton extends React.Component<BaseButtonWithRefProps> {
93
105
  this.longPressTimeout = undefined;
94
106
  }
95
107
 
96
- this.lastActive = active;
108
+ this.lastIsPressed = isPressed;
97
109
  };
98
110
 
99
111
  private onLongPress = () => {
@@ -279,4 +291,9 @@ export const LegacyBorderlessButton = ({
279
291
  ref?: React.Ref<React.ComponentType<any>> | undefined;
280
292
  }) => <InnerBorderlessButton innerRef={ref} {...props} />;
281
293
 
282
- export { default as LegacyPureNativeButton } from './GestureHandlerButton';
294
+ /**
295
+ * @deprecated use `PureNativeButton` instead
296
+ */
297
+ export const LegacyPureNativeButton = (
298
+ props: Omit<ButtonProps, 'needsOffscreenAlphaCompositing'>
299
+ ) => <GestureHandlerButton {...props} needsOffscreenAlphaCompositing />;
@@ -60,18 +60,31 @@ export interface ButtonProps extends ViewProps, AccessibilityProps {
60
60
  touchSoundDisabled?: boolean | undefined;
61
61
 
62
62
  /**
63
- * Duration of the press-in animation when the button is held down, in
64
- * milliseconds. Defaults to `tapAnimationDuration` when not set (or set
65
- * to any negative value).
63
+ * Minimum duration (in milliseconds) of the press-in animation on a
64
+ * quick tap. Defaults to 50ms.
66
65
  */
67
- pressAndHoldAnimationDuration?: number | undefined;
66
+ tapAnimationInDuration?: number | undefined;
68
67
 
69
68
  /**
70
- * Minimum duration (in milliseconds) that the press animation must run
71
- * before the press-out animation is allowed to start. Ensures the pressed
72
- * state is visible on quick taps. Defaults to 100ms.
69
+ * Minimum duration (in milliseconds) of the press-out animation on a
70
+ * quick tap. Defaults to 100ms.
73
71
  */
74
- tapAnimationDuration?: number | undefined;
72
+ tapAnimationOutDuration?: number | undefined;
73
+
74
+ /**
75
+ * Threshold (in milliseconds) at which the press-out animation
76
+ * switches from the tap-out timing to `longPressAnimationOutDuration`.
77
+ * Set to any negative value to disable the switch.
78
+ */
79
+ longPressDuration?: number | undefined;
80
+
81
+ /**
82
+ * Duration of the press-out animation, in milliseconds, when the
83
+ * button is released after being held past `longPressDuration`.
84
+ * Defaults to `tapAnimationOutDuration` when not set (or set to any
85
+ * negative value).
86
+ */
87
+ longPressAnimationOutDuration?: number | undefined;
75
88
 
76
89
  /**
77
90
  * Opacity applied to the button when it is pressed.
@@ -88,6 +101,44 @@ export interface ButtonProps extends ViewProps, AccessibilityProps {
88
101
  */
89
102
  activeUnderlayOpacity?: number | undefined;
90
103
 
104
+ /**
105
+ * Web only.
106
+ *
107
+ * Opacity applied to the button when it is hovered. Defaults to
108
+ * `defaultOpacity` when not set.
109
+ */
110
+ hoverOpacity?: number | undefined;
111
+
112
+ /**
113
+ * Web only.
114
+ *
115
+ * Scale applied to the button when it is hovered. Defaults to
116
+ * `defaultScale` when not set.
117
+ */
118
+ hoverScale?: number | undefined;
119
+
120
+ /**
121
+ * Web only.
122
+ *
123
+ * Opacity applied to the underlay when the button is hovered. Defaults
124
+ * to `defaultUnderlayOpacity` when not set.
125
+ */
126
+ hoverUnderlayOpacity?: number | undefined;
127
+
128
+ /**
129
+ * Web only.
130
+ *
131
+ * Duration of the hover-in animation, in milliseconds. Defaults to 50ms.
132
+ */
133
+ hoverAnimationInDuration?: number | undefined;
134
+
135
+ /**
136
+ * Web only.
137
+ *
138
+ * Duration of the hover-out animation, in milliseconds. Defaults to 100ms.
139
+ */
140
+ hoverAnimationOutDuration?: number | undefined;
141
+
91
142
  /**
92
143
  * Opacity applied to the button when it is not pressed.
93
144
  */
@@ -108,6 +159,17 @@ export interface ButtonProps extends ViewProps, AccessibilityProps {
108
159
  */
109
160
  underlayColor?: ColorValue | undefined;
110
161
 
162
+ /**
163
+ * Android only.
164
+ *
165
+ * Whether the view should render with an offscreen alpha-compositing buffer
166
+ * when its `opacity` is less than 1. Defaults to `false` — without the
167
+ * offscreen buffer, children that draw past the view's bounds (e.g. anti-
168
+ * aliased border edges) are not clipped by the layer when `opacity < 1`.
169
+ * Set to `true` to opt back into the standard Android behavior.
170
+ */
171
+ needsOffscreenAlphaCompositing?: boolean | undefined;
172
+
111
173
  /**
112
174
  * Style object, use it to set additional styles.
113
175
  */
@@ -1,15 +1,25 @@
1
1
  import * as React from 'react';
2
- import type { ColorValue, ViewProps } from 'react-native';
2
+ import type { ColorValue, NativeSyntheticEvent, ViewProps } from 'react-native';
3
3
  import { View } from 'react-native';
4
4
 
5
+ import { NativeGestureRole } from '../web/interfaces';
6
+ import { GestureLifecycleEvent } from '../web/tools/GestureLifecycleEvents';
7
+
5
8
  type ButtonProps = ViewProps & {
6
9
  ref?: React.Ref<React.ComponentRef<typeof View>>;
7
10
  enabled?: boolean;
8
- pressAndHoldAnimationDuration?: number;
9
- tapAnimationDuration?: number;
11
+ tapAnimationInDuration?: number;
12
+ tapAnimationOutDuration?: number;
13
+ longPressDuration?: number;
14
+ longPressAnimationOutDuration?: number;
15
+ hoverAnimationInDuration?: number;
16
+ hoverAnimationOutDuration?: number;
10
17
  activeOpacity?: number;
11
18
  activeScale?: number;
12
19
  activeUnderlayOpacity?: number;
20
+ hoverOpacity?: number;
21
+ hoverScale?: number;
22
+ hoverUnderlayOpacity?: number;
13
23
  defaultOpacity?: number;
14
24
  defaultScale?: number;
15
25
  defaultUnderlayOpacity?: number;
@@ -17,12 +27,20 @@ type ButtonProps = ViewProps & {
17
27
  };
18
28
 
19
29
  export const ButtonComponent = ({
30
+ ref: externalRef,
20
31
  enabled = true,
21
- pressAndHoldAnimationDuration: pressAndHoldAnimationDurationProp = -1,
22
- tapAnimationDuration: tapAnimationDurationProp = 100,
32
+ tapAnimationInDuration = 50,
33
+ tapAnimationOutDuration = 100,
34
+ longPressDuration = -1,
35
+ longPressAnimationOutDuration = 100,
36
+ hoverAnimationInDuration = 50,
37
+ hoverAnimationOutDuration = 100,
23
38
  activeOpacity = 1,
24
39
  activeScale = 1,
25
40
  activeUnderlayOpacity = 0,
41
+ hoverOpacity: hoverOpacityProp,
42
+ hoverScale: hoverScaleProp,
43
+ hoverUnderlayOpacity: hoverUnderlayOpacityProp,
26
44
  defaultOpacity = 1,
27
45
  defaultScale = 1,
28
46
  defaultUnderlayOpacity = 0,
@@ -31,75 +49,189 @@ export const ButtonComponent = ({
31
49
  children,
32
50
  ...rest
33
51
  }: ButtonProps) => {
34
- const tapAnimationDuration =
35
- tapAnimationDurationProp < 0 ? 0 : tapAnimationDurationProp;
36
- const pressAndHoldAnimationDuration =
37
- pressAndHoldAnimationDurationProp < 0
38
- ? tapAnimationDuration
39
- : pressAndHoldAnimationDurationProp;
52
+ const hoverOpacity = hoverOpacityProp ?? defaultOpacity;
53
+ const hoverScale = hoverScaleProp ?? defaultScale;
54
+ const hoverUnderlayOpacity =
55
+ hoverUnderlayOpacityProp ?? defaultUnderlayOpacity;
40
56
 
41
57
  const [pressed, setPressed] = React.useState(false);
58
+ const [hovered, setHovered] = React.useState(false);
42
59
  const [currentDuration, setCurrentDuration] = React.useState(
43
- pressAndHoldAnimationDuration
60
+ tapAnimationInDuration
44
61
  );
45
62
  const pressInTimestamp = React.useRef(0);
46
63
  const pressOutTimer = React.useRef<ReturnType<typeof setTimeout> | null>(
47
64
  null
48
65
  );
66
+ const gestureEnabledRef = React.useRef(true);
67
+ const viewRef = React.useRef<HTMLElement | null>(null);
68
+
69
+ const setRef = React.useCallback(
70
+ (node: React.ComponentRef<typeof View> | null) => {
71
+ viewRef.current = node as unknown as HTMLElement | null;
72
+ if (typeof externalRef === 'function') {
73
+ externalRef(node);
74
+ } else if (externalRef != null) {
75
+ externalRef.current = node;
76
+ }
77
+ },
78
+ [externalRef]
79
+ );
49
80
 
50
81
  React.useEffect(() => {
82
+ const node = viewRef.current;
83
+
84
+ const handleGestureBegan = () => {
85
+ gestureEnabledRef.current = true;
86
+ };
87
+ const handleGestureCanceled = () => {
88
+ gestureEnabledRef.current = false;
89
+ if (pressOutTimer.current != null) {
90
+ clearTimeout(pressOutTimer.current);
91
+ pressOutTimer.current = null;
92
+ }
93
+ pressInTimestamp.current = 0;
94
+ setPressed(false);
95
+ };
96
+
97
+ node?.addEventListener(GestureLifecycleEvent.Began, handleGestureBegan);
98
+ node?.addEventListener(
99
+ GestureLifecycleEvent.Canceled,
100
+ handleGestureCanceled
101
+ );
102
+
51
103
  return () => {
104
+ node?.removeEventListener(
105
+ GestureLifecycleEvent.Began,
106
+ handleGestureBegan
107
+ );
108
+ node?.removeEventListener(
109
+ GestureLifecycleEvent.Canceled,
110
+ handleGestureCanceled
111
+ );
52
112
  if (pressOutTimer.current != null) {
53
113
  clearTimeout(pressOutTimer.current);
54
114
  }
55
115
  };
56
116
  }, []);
57
117
 
58
- const pressIn = React.useCallback(() => {
59
- if (enabled) {
118
+ const pressIn = React.useCallback(
119
+ (event: NativeSyntheticEvent<unknown>) => {
120
+ if (!enabled || !gestureEnabledRef.current) {
121
+ return;
122
+ }
123
+
124
+ event.stopPropagation();
60
125
  if (pressOutTimer.current != null) {
61
126
  clearTimeout(pressOutTimer.current);
62
127
  pressOutTimer.current = null;
63
128
  }
64
129
  pressInTimestamp.current = performance.now();
65
- setCurrentDuration(pressAndHoldAnimationDuration);
130
+ setCurrentDuration(tapAnimationInDuration);
66
131
  setPressed(true);
67
- }
68
- }, [enabled, pressAndHoldAnimationDuration]);
69
-
70
- const pressOut = React.useCallback(() => {
71
- if (pressOutTimer.current != null) {
72
- clearTimeout(pressOutTimer.current);
73
- pressOutTimer.current = null;
74
- }
75
- const elapsed = performance.now() - pressInTimestamp.current;
76
-
77
- if (elapsed >= pressAndHoldAnimationDuration) {
78
- setCurrentDuration(pressAndHoldAnimationDuration);
79
- setPressed(false);
80
- // elapsed * 2 to ensure there is at least half of the tapAnimationDuration left for the animation to play
81
- } else if (elapsed * 2 >= tapAnimationDuration) {
82
- setCurrentDuration(elapsed);
83
- setPressed(false);
84
- } else {
85
- // Let the in-progress CSS press-in transition continue; schedule press-out after remaining time
86
- const remaining = tapAnimationDuration - elapsed;
87
- pressOutTimer.current = setTimeout(() => {
132
+ },
133
+ [enabled, tapAnimationInDuration]
134
+ );
135
+
136
+ const pressOut = React.useCallback(
137
+ (event: NativeSyntheticEvent<unknown>) => {
138
+ // Only release if a press-in was actually recorded — guards against
139
+ // stray pointer events and lets us complete the release cycle even if
140
+ // `enabled` flipped to false between press-in and press-out.
141
+ if (pressInTimestamp.current === 0 || !gestureEnabledRef.current) {
142
+ return;
143
+ }
144
+
145
+ event.stopPropagation();
146
+ if (pressOutTimer.current != null) {
147
+ clearTimeout(pressOutTimer.current);
88
148
  pressOutTimer.current = null;
89
- setCurrentDuration(tapAnimationDuration);
149
+ }
150
+ const elapsed = performance.now() - pressInTimestamp.current;
151
+ pressInTimestamp.current = 0;
152
+
153
+ if (longPressDuration >= 0 && elapsed >= longPressDuration) {
154
+ // Long-press release — use the configured long-press out duration.
155
+ setCurrentDuration(longPressAnimationOutDuration);
156
+ setPressed(false);
157
+ } else if (elapsed >= tapAnimationInDuration) {
158
+ // Press-in animation fully finished - release with the configured out duration.
159
+ setCurrentDuration(tapAnimationOutDuration);
160
+ setPressed(false);
161
+ // elapsed * 2 to ensure there is at least half of the tapAnimationOutDuration left for the animation to play
162
+ } else if (elapsed * 2 >= tapAnimationOutDuration) {
163
+ setCurrentDuration(elapsed);
90
164
  setPressed(false);
91
- }, remaining);
92
- }
93
- }, [pressAndHoldAnimationDuration, tapAnimationDuration]);
165
+ } else {
166
+ // Let the in-progress CSS press-in transition continue; schedule press-out after remaining time.
167
+ const remaining = tapAnimationInDuration - elapsed;
168
+ pressOutTimer.current = setTimeout(() => {
169
+ pressOutTimer.current = null;
170
+ setCurrentDuration(tapAnimationOutDuration);
171
+ setPressed(false);
172
+ }, remaining);
173
+ }
174
+ },
175
+ [
176
+ longPressDuration,
177
+ longPressAnimationOutDuration,
178
+ tapAnimationInDuration,
179
+ tapAnimationOutDuration,
180
+ ]
181
+ );
182
+
183
+ const handlePointerEnter = React.useCallback(
184
+ (event: NativeSyntheticEvent<{ pointerType?: string }>) => {
185
+ if (!enabled || event.nativeEvent.pointerType === 'touch') {
186
+ return;
187
+ }
188
+ // Skip duration update while pressed so the press transition owns it.
189
+ if (!pressed) {
190
+ setCurrentDuration(hoverAnimationInDuration);
191
+ }
192
+ setHovered(true);
193
+ },
194
+ [enabled, pressed, hoverAnimationInDuration]
195
+ );
196
+
197
+ const handlePointerLeave = React.useCallback(
198
+ (event: NativeSyntheticEvent<{ pointerType?: string }>) => {
199
+ pressOut(event);
200
+ if (event.nativeEvent.pointerType === 'touch') {
201
+ return;
202
+ }
203
+ if (!pressed) {
204
+ setCurrentDuration(hoverAnimationOutDuration);
205
+ }
206
+ setHovered(false);
207
+ },
208
+ [pressOut, pressed, hoverAnimationOutDuration]
209
+ );
210
+
211
+ // Mask hover at render rather than clearing the state. Avoids a state
212
+ // write inside an effect, and lets hover resume naturally when `enabled`
213
+ // flips back to true while the pointer is still inside.
214
+ const effectiveHovered = hovered && enabled;
94
215
 
95
216
  const currentUnderlayOpacity = pressed
96
217
  ? activeUnderlayOpacity
97
- : defaultUnderlayOpacity;
98
- const hasUnderlay = underlayColor != null;
99
- const hasOpacity = activeOpacity !== 1 || defaultOpacity !== 1;
100
- const currentOpacity = pressed ? activeOpacity : defaultOpacity;
101
- const hasScale = activeScale !== 1 || defaultScale !== 1;
102
- const currentScale = pressed ? activeScale : defaultScale;
218
+ : effectiveHovered
219
+ ? hoverUnderlayOpacity
220
+ : defaultUnderlayOpacity;
221
+ const hasUnderlay = underlayColor != null && underlayColor !== 'transparent';
222
+ const hasOpacity =
223
+ activeOpacity !== 1 || hoverOpacity !== 1 || defaultOpacity !== 1;
224
+ const currentOpacity = pressed
225
+ ? activeOpacity
226
+ : effectiveHovered
227
+ ? hoverOpacity
228
+ : defaultOpacity;
229
+ const hasScale = activeScale !== 1 || hoverScale !== 1 || defaultScale !== 1;
230
+ const currentScale = pressed
231
+ ? activeScale
232
+ : effectiveHovered
233
+ ? hoverScale
234
+ : defaultScale;
103
235
 
104
236
  const easing = 'cubic-bezier(0.5, 1, 0.89, 1)';
105
237
  const transitionProps: string[] = [];
@@ -113,6 +245,8 @@ export const ButtonComponent = ({
113
245
 
114
246
  return (
115
247
  <View
248
+ {...rest}
249
+ ref={setRef}
116
250
  accessibilityRole="button"
117
251
  style={[
118
252
  style,
@@ -125,11 +259,11 @@ export const ButtonComponent = ({
125
259
  ...(hasUnderlay && { overflow: 'hidden' }),
126
260
  },
127
261
  ]}
262
+ onPointerEnter={handlePointerEnter}
128
263
  onPointerDown={pressIn}
129
264
  onPointerUp={pressOut}
130
265
  onPointerCancel={pressOut}
131
- onPointerLeave={pressOut}
132
- {...rest}>
266
+ onPointerLeave={handlePointerLeave}>
133
267
  {hasUnderlay && (
134
268
  <View
135
269
  style={{
@@ -151,4 +285,6 @@ export const ButtonComponent = ({
151
285
  );
152
286
  };
153
287
 
288
+ ButtonComponent.displayName = NativeGestureRole.Button;
289
+
154
290
  export default ButtonComponent;
@@ -323,7 +323,8 @@ const LegacyPressable = (props: LegacyPressableProps) => {
323
323
  handleFinalize();
324
324
  }
325
325
  }
326
- }),
326
+ })
327
+ .shouldActivateOnStart(Platform.OS === 'web'),
327
328
  [stateMachine, handlePressOut, handleFinalize]
328
329
  );
329
330
 
@@ -376,6 +377,7 @@ const LegacyPressable = (props: LegacyPressableProps) => {
376
377
  <GestureDetector gesture={gesture}>
377
378
  <NativeButton
378
379
  {...remainingProps}
380
+ needsOffscreenAlphaCompositing
379
381
  onLayout={setDimensions}
380
382
  accessible={accessible !== false}
381
383
  hitSlop={appliedHitSlop}
@@ -32,7 +32,8 @@ export type InnerPressableEvent = {
32
32
 
33
33
  export type PressableEvent = { nativeEvent: InnerPressableEvent };
34
34
 
35
- export interface LegacyPressableProps extends CommonPressableProps {
35
+ export interface LegacyPressableProps
36
+ extends Omit<CommonPressableProps, 'needsOffscreenAlphaCompositing'> {
36
37
  /**
37
38
  * A gesture object or an array of gesture objects containing the configuration and callbacks to be
38
39
  * used with the Pressable's gesture handlers.
@@ -61,6 +61,9 @@ function getIosStatesConfig(
61
61
  eventName: StateMachineEvent.NATIVE_BEGIN,
62
62
  callback: handlePressIn,
63
63
  },
64
+ {
65
+ eventName: StateMachineEvent.NATIVE_START,
66
+ },
64
67
  {
65
68
  eventName: StateMachineEvent.FINALIZE,
66
69
  callback: handlePressOut,
@@ -44,6 +44,7 @@ import { MouseButton } from '../handlers/gestureHandlerCommon';
44
44
  import { GestureDetector } from '../v3/detectors';
45
45
  import type { PanGestureActiveEvent } from '../v3/hooks/gestures';
46
46
  import { usePanGesture, useTapGesture } from '../v3/hooks/gestures';
47
+ import type { WithSharedValue } from '../v3/types';
47
48
 
48
49
  const DRAG_TOSS = 0.05;
49
50
 
@@ -75,7 +76,7 @@ export enum DrawerKeyboardDismissMode {
75
76
  ON_DRAG,
76
77
  }
77
78
 
78
- export interface DrawerLayoutProps {
79
+ export type DrawerLayoutProps = {
79
80
  /**
80
81
  * This attribute is present in the native android implementation already and is one
81
82
  * of the required params. The gesture handler version of DrawerLayout makes it
@@ -193,14 +194,6 @@ export interface DrawerLayoutProps {
193
194
  */
194
195
  drawerContainerStyle?: StyleProp<ViewStyle>;
195
196
 
196
- /**
197
- * Enables two-finger gestures on supported devices, for example iPads with
198
- * trackpads. If not enabled the gesture will require click + drag, with
199
- * `enableTrackpadTwoFingerGesture` swiping with two fingers will also trigger
200
- * the gesture.
201
- */
202
- enableTrackpadTwoFingerGesture?: boolean;
203
-
204
197
  onDrawerSlide?: (position: number) => void;
205
198
 
206
199
  // Implicit `children` prop has been removed in @types/react^18.0.
@@ -216,25 +209,36 @@ export interface DrawerLayoutProps {
216
209
  */
217
210
  userSelect?: UserSelect;
218
211
 
219
- /**
220
- * @default 'auto'
221
- * Sets the displayed cursor pictogram when the drawer is being dragged.
222
- * Values: see CSS cursor values
223
- */
224
- activeCursor?: ActiveCursor;
225
-
226
- /**
227
- * @default 'MouseButton.LEFT'
228
- * Allows to choose which mouse button should underlying pan handler react to.
229
- */
230
- mouseButton?: MouseButton;
231
-
232
212
  /**
233
213
  * @default 'false if MouseButton.RIGHT is specified'
234
214
  * Allows to enable/disable context menu.
235
215
  */
236
216
  enableContextMenu?: boolean;
237
- }
217
+ } & WithSharedValue<
218
+ {
219
+ /**
220
+ * Enables two-finger gestures on supported devices, for example iPads with
221
+ * trackpads. If not enabled the gesture will require click + drag, with
222
+ * `enableTrackpadTwoFingerGesture` swiping with two fingers will also trigger
223
+ * the gesture.
224
+ */
225
+ enableTrackpadTwoFingerGesture?: boolean;
226
+
227
+ /**
228
+ * @default 'auto'
229
+ * Sets the displayed cursor pictogram when the drawer is being dragged.
230
+ * Values: see CSS cursor values
231
+ */
232
+ activeCursor?: ActiveCursor;
233
+
234
+ /**
235
+ * @default 'MouseButton.LEFT'
236
+ * Allows to choose which mouse button should underlying pan handler react to.
237
+ */
238
+ mouseButton?: MouseButton;
239
+ },
240
+ ActiveCursor | MouseButton
241
+ >;
238
242
 
239
243
  export type DrawerMovementOption = {
240
244
  initialVelocity?: number;