react-native-gesture-handler 2.26.0 → 2.27.1

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 (415) hide show
  1. package/README.md +69 -0
  2. package/android/src/main/jni/CMakeLists.txt +7 -26
  3. package/lib/commonjs/components/Pressable/Pressable.js +139 -188
  4. package/lib/commonjs/components/Pressable/Pressable.js.map +1 -1
  5. package/lib/commonjs/components/Pressable/StateMachine.js +38 -0
  6. package/lib/commonjs/components/Pressable/StateMachine.js.map +1 -0
  7. package/lib/commonjs/components/Pressable/stateDefinitions.js +88 -0
  8. package/lib/commonjs/components/Pressable/stateDefinitions.js.map +1 -0
  9. package/lib/commonjs/components/Pressable/utils.js +1 -1
  10. package/lib/commonjs/components/Pressable/utils.js.map +1 -1
  11. package/lib/commonjs/handlers/gestures/forceTouchGesture.js +12 -0
  12. package/lib/commonjs/handlers/gestures/forceTouchGesture.js.map +1 -1
  13. package/lib/commonjs/handlers/gestures/gestureObjects.js +3 -1
  14. package/lib/commonjs/handlers/gestures/gestureObjects.js.map +1 -1
  15. package/lib/commonjs/web/detectors/RotationGestureDetector.js +3 -0
  16. package/lib/commonjs/web/detectors/RotationGestureDetector.js.map +1 -1
  17. package/lib/commonjs/web/handlers/FlingGestureHandler.js +3 -0
  18. package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
  19. package/lib/commonjs/web/handlers/GestureHandler.js +6 -6
  20. package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
  21. package/lib/commonjs/web/handlers/PanGestureHandler.js +24 -33
  22. package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
  23. package/lib/commonjs/web/handlers/TapGestureHandler.js +15 -17
  24. package/lib/commonjs/web/handlers/TapGestureHandler.js.map +1 -1
  25. package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js +1 -1
  26. package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js.map +1 -1
  27. package/lib/commonjs/web/tools/PointerEventManager.js +1 -1
  28. package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
  29. package/lib/commonjs/web/tools/PointerTracker.js +12 -11
  30. package/lib/commonjs/web/tools/PointerTracker.js.map +1 -1
  31. package/lib/commonjs/web/tools/Vector.js +1 -1
  32. package/lib/commonjs/web/tools/Vector.js.map +1 -1
  33. package/lib/module/components/Pressable/Pressable.js +141 -190
  34. package/lib/module/components/Pressable/Pressable.js.map +1 -1
  35. package/lib/module/components/Pressable/StateMachine.js +34 -0
  36. package/lib/module/components/Pressable/StateMachine.js.map +1 -0
  37. package/lib/module/components/Pressable/stateDefinitions.js +83 -0
  38. package/lib/module/components/Pressable/stateDefinitions.js.map +1 -0
  39. package/lib/module/components/Pressable/utils.js +1 -1
  40. package/lib/module/components/Pressable/utils.js.map +1 -1
  41. package/lib/module/handlers/gestures/forceTouchGesture.js +13 -0
  42. package/lib/module/handlers/gestures/forceTouchGesture.js.map +1 -1
  43. package/lib/module/handlers/gestures/gestureObjects.js +3 -1
  44. package/lib/module/handlers/gestures/gestureObjects.js.map +1 -1
  45. package/lib/module/web/detectors/RotationGestureDetector.js +3 -0
  46. package/lib/module/web/detectors/RotationGestureDetector.js.map +1 -1
  47. package/lib/module/web/handlers/FlingGestureHandler.js +3 -0
  48. package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
  49. package/lib/module/web/handlers/GestureHandler.js +6 -6
  50. package/lib/module/web/handlers/GestureHandler.js.map +1 -1
  51. package/lib/module/web/handlers/PanGestureHandler.js +24 -33
  52. package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
  53. package/lib/module/web/handlers/TapGestureHandler.js +15 -17
  54. package/lib/module/web/handlers/TapGestureHandler.js.map +1 -1
  55. package/lib/module/web/tools/GestureHandlerOrchestrator.js +1 -1
  56. package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
  57. package/lib/module/web/tools/PointerEventManager.js +1 -1
  58. package/lib/module/web/tools/PointerEventManager.js.map +1 -1
  59. package/lib/module/web/tools/PointerTracker.js +12 -11
  60. package/lib/module/web/tools/PointerTracker.js.map +1 -1
  61. package/lib/module/web/tools/Vector.js +1 -1
  62. package/lib/module/web/tools/Vector.js.map +1 -1
  63. package/lib/typescript/ActionType.d.ts +0 -1
  64. package/lib/typescript/ActionType.js +6 -0
  65. package/lib/typescript/Directions.d.ts +0 -1
  66. package/lib/typescript/Directions.js +18 -0
  67. package/lib/typescript/EnableNewWebImplementation.d.ts +0 -1
  68. package/lib/typescript/EnableNewWebImplementation.js +30 -0
  69. package/lib/typescript/GestureHandlerRootViewContext.d.ts +0 -1
  70. package/lib/typescript/GestureHandlerRootViewContext.js +2 -0
  71. package/lib/typescript/PlatformConstants.d.ts +0 -1
  72. package/lib/typescript/PlatformConstants.js +3 -0
  73. package/lib/typescript/PlatformConstants.web.d.ts +0 -1
  74. package/lib/typescript/PlatformConstants.web.js +5 -0
  75. package/lib/typescript/PointerType.d.ts +0 -1
  76. package/lib/typescript/PointerType.js +8 -0
  77. package/lib/typescript/RNGestureHandlerModule.d.ts +0 -1
  78. package/lib/typescript/RNGestureHandlerModule.js +4 -0
  79. package/lib/typescript/RNGestureHandlerModule.web.d.ts +0 -1
  80. package/lib/typescript/RNGestureHandlerModule.web.js +92 -0
  81. package/lib/typescript/RNGestureHandlerModule.windows.d.ts +0 -1
  82. package/lib/typescript/RNGestureHandlerModule.windows.js +47 -0
  83. package/lib/typescript/RNRenderer.d.ts +0 -1
  84. package/lib/typescript/RNRenderer.js +3 -0
  85. package/lib/typescript/RNRenderer.web.d.ts +0 -1
  86. package/lib/typescript/RNRenderer.web.js +3 -0
  87. package/lib/typescript/State.d.ts +0 -1
  88. package/lib/typescript/State.js +9 -0
  89. package/lib/typescript/TouchEventType.d.ts +0 -1
  90. package/lib/typescript/TouchEventType.js +7 -0
  91. package/lib/typescript/components/DrawerLayout.d.ts +0 -1
  92. package/lib/typescript/components/DrawerLayout.js +417 -0
  93. package/lib/typescript/components/GestureButtons.d.ts +0 -1
  94. package/lib/typescript/components/GestureButtons.js +165 -0
  95. package/lib/typescript/components/GestureButtonsProps.d.ts +0 -1
  96. package/lib/typescript/components/GestureButtonsProps.js +1 -0
  97. package/lib/typescript/components/GestureComponents.d.ts +0 -1
  98. package/lib/typescript/components/GestureComponents.js +67 -0
  99. package/lib/typescript/components/GestureComponents.web.d.ts +0 -1
  100. package/lib/typescript/components/GestureComponents.web.js +21 -0
  101. package/lib/typescript/components/GestureHandlerButton.d.ts +0 -1
  102. package/lib/typescript/components/GestureHandlerButton.js +2 -0
  103. package/lib/typescript/components/GestureHandlerButton.web.d.ts +0 -1
  104. package/lib/typescript/components/GestureHandlerButton.web.js +3 -0
  105. package/lib/typescript/components/GestureHandlerRootView.android.d.ts +0 -1
  106. package/lib/typescript/components/GestureHandlerRootView.android.js +17 -0
  107. package/lib/typescript/components/GestureHandlerRootView.d.ts +0 -1
  108. package/lib/typescript/components/GestureHandlerRootView.js +16 -0
  109. package/lib/typescript/components/GestureHandlerRootView.web.d.ts +0 -1
  110. package/lib/typescript/components/GestureHandlerRootView.web.js +11 -0
  111. package/lib/typescript/components/Pressable/Pressable.d.ts +1 -3
  112. package/lib/typescript/components/Pressable/Pressable.d.ts.map +1 -1
  113. package/lib/typescript/components/Pressable/Pressable.js +231 -0
  114. package/lib/typescript/components/Pressable/PressableProps.d.ts +15 -2
  115. package/lib/typescript/components/Pressable/PressableProps.d.ts.map +1 -1
  116. package/lib/typescript/components/Pressable/PressableProps.js +1 -0
  117. package/lib/typescript/components/Pressable/StateMachine.d.ts +14 -0
  118. package/lib/typescript/components/Pressable/StateMachine.d.ts.map +1 -0
  119. package/lib/typescript/components/Pressable/StateMachine.js +34 -0
  120. package/lib/typescript/components/Pressable/index.d.ts +0 -1
  121. package/lib/typescript/components/Pressable/index.js +1 -0
  122. package/lib/typescript/components/Pressable/stateDefinitions.d.ts +9 -0
  123. package/lib/typescript/components/Pressable/stateDefinitions.d.ts.map +1 -0
  124. package/lib/typescript/components/Pressable/stateDefinitions.js +104 -0
  125. package/lib/typescript/components/Pressable/utils.d.ts +3 -7
  126. package/lib/typescript/components/Pressable/utils.d.ts.map +1 -1
  127. package/lib/typescript/components/Pressable/utils.js +80 -0
  128. package/lib/typescript/components/ReanimatedDrawerLayout.d.ts +0 -1
  129. package/lib/typescript/components/ReanimatedDrawerLayout.js +364 -0
  130. package/lib/typescript/components/ReanimatedSwipeable.d.ts +0 -1
  131. package/lib/typescript/components/ReanimatedSwipeable.js +400 -0
  132. package/lib/typescript/components/Swipeable.d.ts +0 -1
  133. package/lib/typescript/components/Swipeable.js +287 -0
  134. package/lib/typescript/components/Text.d.ts +0 -1
  135. package/lib/typescript/components/Text.js +38 -0
  136. package/lib/typescript/components/gestureHandlerRootHOC.d.ts +0 -1
  137. package/lib/typescript/components/gestureHandlerRootHOC.js +18 -0
  138. package/lib/typescript/components/touchables/ExtraButtonProps.d.ts +0 -1
  139. package/lib/typescript/components/touchables/ExtraButtonProps.js +1 -0
  140. package/lib/typescript/components/touchables/GenericTouchable.d.ts +0 -1
  141. package/lib/typescript/components/touchables/GenericTouchable.js +221 -0
  142. package/lib/typescript/components/touchables/GenericTouchableProps.d.ts +0 -1
  143. package/lib/typescript/components/touchables/GenericTouchableProps.js +1 -0
  144. package/lib/typescript/components/touchables/TouchableHighlight.d.ts +0 -1
  145. package/lib/typescript/components/touchables/TouchableHighlight.js +75 -0
  146. package/lib/typescript/components/touchables/TouchableNativeFeedback.android.d.ts +0 -1
  147. package/lib/typescript/components/touchables/TouchableNativeFeedback.android.js +65 -0
  148. package/lib/typescript/components/touchables/TouchableNativeFeedback.d.ts +0 -1
  149. package/lib/typescript/components/touchables/TouchableNativeFeedback.js +6 -0
  150. package/lib/typescript/components/touchables/TouchableNativeFeedbackProps.d.ts +0 -1
  151. package/lib/typescript/components/touchables/TouchableNativeFeedbackProps.js +1 -0
  152. package/lib/typescript/components/touchables/TouchableOpacity.d.ts +0 -1
  153. package/lib/typescript/components/touchables/TouchableOpacity.js +51 -0
  154. package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts +0 -1
  155. package/lib/typescript/components/touchables/TouchableWithoutFeedback.js +10 -0
  156. package/lib/typescript/components/touchables/index.d.ts +0 -1
  157. package/lib/typescript/components/touchables/index.js +4 -0
  158. package/lib/typescript/components/utils.d.ts +0 -1
  159. package/lib/typescript/components/utils.js +11 -0
  160. package/lib/typescript/findNodeHandle.d.ts +0 -1
  161. package/lib/typescript/findNodeHandle.js +2 -0
  162. package/lib/typescript/findNodeHandle.web.d.ts +0 -1
  163. package/lib/typescript/findNodeHandle.web.js +31 -0
  164. package/lib/typescript/getShadowNodeFromRef.d.ts +0 -1
  165. package/lib/typescript/getShadowNodeFromRef.js +45 -0
  166. package/lib/typescript/getShadowNodeFromRef.web.d.ts +0 -1
  167. package/lib/typescript/getShadowNodeFromRef.web.js +7 -0
  168. package/lib/typescript/ghQueueMicrotask.d.ts +0 -1
  169. package/lib/typescript/ghQueueMicrotask.js +7 -0
  170. package/lib/typescript/handlers/FlingGestureHandler.d.ts +0 -1
  171. package/lib/typescript/handlers/FlingGestureHandler.js +19 -0
  172. package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +0 -1
  173. package/lib/typescript/handlers/ForceTouchGestureHandler.js +37 -0
  174. package/lib/typescript/handlers/GestureHandlerEventPayload.d.ts +3 -1
  175. package/lib/typescript/handlers/GestureHandlerEventPayload.d.ts.map +1 -1
  176. package/lib/typescript/handlers/GestureHandlerEventPayload.js +1 -0
  177. package/lib/typescript/handlers/LongPressGestureHandler.d.ts +0 -1
  178. package/lib/typescript/handlers/LongPressGestureHandler.js +22 -0
  179. package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +0 -1
  180. package/lib/typescript/handlers/NativeViewGestureHandler.js +20 -0
  181. package/lib/typescript/handlers/PanGestureHandler.d.ts +0 -1
  182. package/lib/typescript/handlers/PanGestureHandler.js +128 -0
  183. package/lib/typescript/handlers/PinchGestureHandler.d.ts +0 -1
  184. package/lib/typescript/handlers/PinchGestureHandler.js +12 -0
  185. package/lib/typescript/handlers/PressabilityDebugView.d.ts +0 -1
  186. package/lib/typescript/handlers/PressabilityDebugView.js +2 -0
  187. package/lib/typescript/handlers/PressabilityDebugView.web.d.ts +0 -1
  188. package/lib/typescript/handlers/PressabilityDebugView.web.js +4 -0
  189. package/lib/typescript/handlers/RotationGestureHandler.d.ts +0 -1
  190. package/lib/typescript/handlers/RotationGestureHandler.js +12 -0
  191. package/lib/typescript/handlers/TapGestureHandler.d.ts +0 -1
  192. package/lib/typescript/handlers/TapGestureHandler.js +26 -0
  193. package/lib/typescript/handlers/createHandler.d.ts +0 -1
  194. package/lib/typescript/handlers/createHandler.js +375 -0
  195. package/lib/typescript/handlers/createNativeWrapper.d.ts +0 -1
  196. package/lib/typescript/handlers/createNativeWrapper.js +67 -0
  197. package/lib/typescript/handlers/customDirectEventTypes.d.ts +0 -1
  198. package/lib/typescript/handlers/customDirectEventTypes.js +2 -0
  199. package/lib/typescript/handlers/customDirectEventTypes.web.d.ts +0 -1
  200. package/lib/typescript/handlers/customDirectEventTypes.web.js +4 -0
  201. package/lib/typescript/handlers/gestureHandlerCommon.d.ts +0 -1
  202. package/lib/typescript/handlers/gestureHandlerCommon.js +42 -0
  203. package/lib/typescript/handlers/gestureHandlerTypesCompat.d.ts +9 -1
  204. package/lib/typescript/handlers/gestureHandlerTypesCompat.d.ts.map +1 -1
  205. package/lib/typescript/handlers/gestureHandlerTypesCompat.js +1 -0
  206. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.d.ts +0 -1
  207. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.js +22 -0
  208. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.web.d.ts +0 -1
  209. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.web.js +24 -0
  210. package/lib/typescript/handlers/gestures/GestureDetector/attachHandlers.d.ts +0 -1
  211. package/lib/typescript/handlers/gestures/GestureDetector/attachHandlers.js +55 -0
  212. package/lib/typescript/handlers/gestures/GestureDetector/dropHandlers.d.ts +0 -1
  213. package/lib/typescript/handlers/gestures/GestureDetector/dropHandlers.js +12 -0
  214. package/lib/typescript/handlers/gestures/GestureDetector/index.d.ts +0 -1
  215. package/lib/typescript/handlers/gestures/GestureDetector/index.js +114 -0
  216. package/lib/typescript/handlers/gestures/GestureDetector/needsToReattach.d.ts +0 -1
  217. package/lib/typescript/handlers/gestures/GestureDetector/needsToReattach.js +18 -0
  218. package/lib/typescript/handlers/gestures/GestureDetector/types.d.ts +0 -1
  219. package/lib/typescript/handlers/gestures/GestureDetector/types.js +1 -0
  220. package/lib/typescript/handlers/gestures/GestureDetector/updateHandlers.d.ts +0 -1
  221. package/lib/typescript/handlers/gestures/GestureDetector/updateHandlers.js +54 -0
  222. package/lib/typescript/handlers/gestures/GestureDetector/useAnimatedGesture.d.ts +0 -1
  223. package/lib/typescript/handlers/gestures/GestureDetector/useAnimatedGesture.js +137 -0
  224. package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.d.ts +0 -1
  225. package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.js +48 -0
  226. package/lib/typescript/handlers/gestures/GestureDetector/useMountReactions.d.ts +0 -1
  227. package/lib/typescript/handlers/gestures/GestureDetector/useMountReactions.js +35 -0
  228. package/lib/typescript/handlers/gestures/GestureDetector/useViewRefHandler.d.ts +0 -1
  229. package/lib/typescript/handlers/gestures/GestureDetector/useViewRefHandler.js +32 -0
  230. package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts +0 -1
  231. package/lib/typescript/handlers/gestures/GestureDetector/utils.js +140 -0
  232. package/lib/typescript/handlers/gestures/eventReceiver.d.ts +0 -1
  233. package/lib/typescript/handlers/gestures/eventReceiver.js +105 -0
  234. package/lib/typescript/handlers/gestures/flingGesture.d.ts +0 -1
  235. package/lib/typescript/handlers/gestures/flingGesture.js +27 -0
  236. package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +9 -1
  237. package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts.map +1 -1
  238. package/lib/typescript/handlers/gestures/forceTouchGesture.js +57 -0
  239. package/lib/typescript/handlers/gestures/gesture.d.ts +0 -1
  240. package/lib/typescript/handlers/gestures/gesture.js +303 -0
  241. package/lib/typescript/handlers/gestures/gestureComposition.d.ts +0 -1
  242. package/lib/typescript/handlers/gestures/gestureComposition.js +78 -0
  243. package/lib/typescript/handlers/gestures/gestureObjects.d.ts +3 -2
  244. package/lib/typescript/handlers/gestures/gestureObjects.d.ts.map +1 -1
  245. package/lib/typescript/handlers/gestures/gestureObjects.js +125 -0
  246. package/lib/typescript/handlers/gestures/gestureStateManager.d.ts +0 -1
  247. package/lib/typescript/handlers/gestures/gestureStateManager.js +60 -0
  248. package/lib/typescript/handlers/gestures/gestureStateManager.web.d.ts +0 -1
  249. package/lib/typescript/handlers/gestures/gestureStateManager.web.js +19 -0
  250. package/lib/typescript/handlers/gestures/hoverGesture.d.ts +0 -1
  251. package/lib/typescript/handlers/gestures/hoverGesture.js +45 -0
  252. package/lib/typescript/handlers/gestures/longPressGesture.d.ts +0 -1
  253. package/lib/typescript/handlers/gestures/longPressGesture.js +35 -0
  254. package/lib/typescript/handlers/gestures/manualGesture.d.ts +0 -1
  255. package/lib/typescript/handlers/gestures/manualGesture.js +16 -0
  256. package/lib/typescript/handlers/gestures/nativeGesture.d.ts +0 -1
  257. package/lib/typescript/handlers/gestures/nativeGesture.js +24 -0
  258. package/lib/typescript/handlers/gestures/panGesture.d.ts +0 -1
  259. package/lib/typescript/handlers/gestures/panGesture.js +181 -0
  260. package/lib/typescript/handlers/gestures/pinchGesture.d.ts +0 -1
  261. package/lib/typescript/handlers/gestures/pinchGesture.js +27 -0
  262. package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts +0 -1
  263. package/lib/typescript/handlers/gestures/reanimatedWrapper.js +23 -0
  264. package/lib/typescript/handlers/gestures/rotationGesture.d.ts +0 -1
  265. package/lib/typescript/handlers/gestures/rotationGesture.js +27 -0
  266. package/lib/typescript/handlers/gestures/tapGesture.d.ts +0 -1
  267. package/lib/typescript/handlers/gestures/tapGesture.js +72 -0
  268. package/lib/typescript/handlers/getNextHandlerTag.d.ts +0 -1
  269. package/lib/typescript/handlers/getNextHandlerTag.js +4 -0
  270. package/lib/typescript/handlers/handlersRegistry.d.ts +0 -1
  271. package/lib/typescript/handlers/handlersRegistry.js +36 -0
  272. package/lib/typescript/handlers/utils.d.ts +0 -1
  273. package/lib/typescript/handlers/utils.js +58 -0
  274. package/lib/typescript/index.d.ts +0 -1
  275. package/lib/typescript/index.js +28 -0
  276. package/lib/typescript/init.d.ts +0 -1
  277. package/lib/typescript/init.js +15 -0
  278. package/lib/typescript/jestUtils/index.d.ts +0 -1
  279. package/lib/typescript/jestUtils/index.js +1 -0
  280. package/lib/typescript/jestUtils/jestUtils.d.ts +0 -1
  281. package/lib/typescript/jestUtils/jestUtils.js +290 -0
  282. package/lib/typescript/mocks.d.ts +0 -1
  283. package/lib/typescript/mocks.js +59 -0
  284. package/lib/typescript/mountRegistry.d.ts +0 -1
  285. package/lib/typescript/mountRegistry.js +29 -0
  286. package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts +0 -1
  287. package/lib/typescript/specs/NativeRNGestureHandlerModule.js +2 -0
  288. package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts +0 -1
  289. package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.js +2 -0
  290. package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.d.ts +0 -1
  291. package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.js +2 -0
  292. package/lib/typescript/typeUtils.d.ts +0 -1
  293. package/lib/typescript/typeUtils.js +1 -0
  294. package/lib/typescript/utils.d.ts +0 -1
  295. package/lib/typescript/utils.js +80 -0
  296. package/lib/typescript/web/Gestures.d.ts +0 -1
  297. package/lib/typescript/web/Gestures.js +38 -0
  298. package/lib/typescript/web/constants.d.ts +0 -1
  299. package/lib/typescript/web/constants.js +2 -0
  300. package/lib/typescript/web/detectors/RotationGestureDetector.d.ts +0 -1
  301. package/lib/typescript/web/detectors/RotationGestureDetector.d.ts.map +1 -1
  302. package/lib/typescript/web/detectors/RotationGestureDetector.js +122 -0
  303. package/lib/typescript/web/detectors/ScaleGestureDetector.d.ts +0 -1
  304. package/lib/typescript/web/detectors/ScaleGestureDetector.js +117 -0
  305. package/lib/typescript/web/handlers/FlingGestureHandler.d.ts +0 -1
  306. package/lib/typescript/web/handlers/FlingGestureHandler.d.ts.map +1 -1
  307. package/lib/typescript/web/handlers/FlingGestureHandler.js +133 -0
  308. package/lib/typescript/web/handlers/GestureHandler.d.ts +0 -1
  309. package/lib/typescript/web/handlers/GestureHandler.d.ts.map +1 -1
  310. package/lib/typescript/web/handlers/GestureHandler.js +656 -0
  311. package/lib/typescript/web/handlers/HoverGestureHandler.d.ts +0 -1
  312. package/lib/typescript/web/handlers/HoverGestureHandler.js +37 -0
  313. package/lib/typescript/web/handlers/IGestureHandler.d.ts +0 -1
  314. package/lib/typescript/web/handlers/IGestureHandler.js +1 -0
  315. package/lib/typescript/web/handlers/LongPressGestureHandler.d.ts +0 -1
  316. package/lib/typescript/web/handlers/LongPressGestureHandler.js +136 -0
  317. package/lib/typescript/web/handlers/ManualGestureHandler.d.ts +0 -1
  318. package/lib/typescript/web/handlers/ManualGestureHandler.js +29 -0
  319. package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +0 -1
  320. package/lib/typescript/web/handlers/NativeViewGestureHandler.js +133 -0
  321. package/lib/typescript/web/handlers/PanGestureHandler.d.ts +2 -1
  322. package/lib/typescript/web/handlers/PanGestureHandler.d.ts.map +1 -1
  323. package/lib/typescript/web/handlers/PanGestureHandler.js +420 -0
  324. package/lib/typescript/web/handlers/PinchGestureHandler.d.ts +0 -1
  325. package/lib/typescript/web/handlers/PinchGestureHandler.js +117 -0
  326. package/lib/typescript/web/handlers/RotationGestureHandler.d.ts +0 -1
  327. package/lib/typescript/web/handlers/RotationGestureHandler.js +122 -0
  328. package/lib/typescript/web/handlers/TapGestureHandler.d.ts +1 -1
  329. package/lib/typescript/web/handlers/TapGestureHandler.d.ts.map +1 -1
  330. package/lib/typescript/web/handlers/TapGestureHandler.js +202 -0
  331. package/lib/typescript/web/interfaces.d.ts +0 -1
  332. package/lib/typescript/web/interfaces.js +25 -0
  333. package/lib/typescript/web/tools/CircularBuffer.d.ts +0 -1
  334. package/lib/typescript/web/tools/CircularBuffer.js +37 -0
  335. package/lib/typescript/web/tools/EventManager.d.ts +0 -1
  336. package/lib/typescript/web/tools/EventManager.js +85 -0
  337. package/lib/typescript/web/tools/GestureHandlerDelegate.d.ts +0 -1
  338. package/lib/typescript/web/tools/GestureHandlerDelegate.js +1 -0
  339. package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts +0 -1
  340. package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts.map +1 -1
  341. package/lib/typescript/web/tools/GestureHandlerOrchestrator.js +273 -0
  342. package/lib/typescript/web/tools/GestureHandlerWebDelegate.d.ts +0 -1
  343. package/lib/typescript/web/tools/GestureHandlerWebDelegate.js +169 -0
  344. package/lib/typescript/web/tools/InteractionManager.d.ts +0 -1
  345. package/lib/typescript/web/tools/InteractionManager.js +91 -0
  346. package/lib/typescript/web/tools/KeyboardEventManager.d.ts +0 -1
  347. package/lib/typescript/web/tools/KeyboardEventManager.js +73 -0
  348. package/lib/typescript/web/tools/LeastSquareSolver.d.ts +0 -1
  349. package/lib/typescript/web/tools/LeastSquareSolver.js +147 -0
  350. package/lib/typescript/web/tools/NodeManager.d.ts +0 -1
  351. package/lib/typescript/web/tools/NodeManager.js +28 -0
  352. package/lib/typescript/web/tools/PointerEventManager.d.ts +0 -1
  353. package/lib/typescript/web/tools/PointerEventManager.js +179 -0
  354. package/lib/typescript/web/tools/PointerTracker.d.ts +3 -4
  355. package/lib/typescript/web/tools/PointerTracker.d.ts.map +1 -1
  356. package/lib/typescript/web/tools/PointerTracker.js +161 -0
  357. package/lib/typescript/web/tools/Vector.d.ts +1 -2
  358. package/lib/typescript/web/tools/Vector.js +43 -0
  359. package/lib/typescript/web/tools/VelocityTracker.d.ts +0 -1
  360. package/lib/typescript/web/tools/VelocityTracker.js +76 -0
  361. package/lib/typescript/web/tools/WheelEventManager.d.ts +0 -1
  362. package/lib/typescript/web/tools/WheelEventManager.js +40 -0
  363. package/lib/typescript/web/utils.d.ts +0 -1
  364. package/lib/typescript/web/utils.js +233 -0
  365. package/lib/typescript/web_hammer/DiscreteGestureHandler.d.ts +0 -1
  366. package/lib/typescript/web_hammer/DiscreteGestureHandler.js +48 -0
  367. package/lib/typescript/web_hammer/DraggingGestureHandler.d.ts +0 -1
  368. package/lib/typescript/web_hammer/DraggingGestureHandler.js +25 -0
  369. package/lib/typescript/web_hammer/Errors.d.ts +0 -1
  370. package/lib/typescript/web_hammer/Errors.js +5 -0
  371. package/lib/typescript/web_hammer/FlingGestureHandler.d.ts +0 -1
  372. package/lib/typescript/web_hammer/FlingGestureHandler.js +119 -0
  373. package/lib/typescript/web_hammer/GestureHandler.d.ts +0 -1
  374. package/lib/typescript/web_hammer/GestureHandler.js +469 -0
  375. package/lib/typescript/web_hammer/IndiscreteGestureHandler.d.ts +0 -1
  376. package/lib/typescript/web_hammer/IndiscreteGestureHandler.js +26 -0
  377. package/lib/typescript/web_hammer/LongPressGestureHandler.d.ts +0 -1
  378. package/lib/typescript/web_hammer/LongPressGestureHandler.js +46 -0
  379. package/lib/typescript/web_hammer/NativeViewGestureHandler.d.ts +0 -1
  380. package/lib/typescript/web_hammer/NativeViewGestureHandler.js +40 -0
  381. package/lib/typescript/web_hammer/NodeManager.d.ts +0 -1
  382. package/lib/typescript/web_hammer/NodeManager.js +28 -0
  383. package/lib/typescript/web_hammer/PanGestureHandler.d.ts +0 -1
  384. package/lib/typescript/web_hammer/PanGestureHandler.js +151 -0
  385. package/lib/typescript/web_hammer/PinchGestureHandler.d.ts +0 -1
  386. package/lib/typescript/web_hammer/PinchGestureHandler.js +19 -0
  387. package/lib/typescript/web_hammer/PressGestureHandler.d.ts +0 -1
  388. package/lib/typescript/web_hammer/PressGestureHandler.js +133 -0
  389. package/lib/typescript/web_hammer/RotationGestureHandler.d.ts +0 -1
  390. package/lib/typescript/web_hammer/RotationGestureHandler.js +20 -0
  391. package/lib/typescript/web_hammer/TapGestureHandler.d.ts +0 -1
  392. package/lib/typescript/web_hammer/TapGestureHandler.js +142 -0
  393. package/lib/typescript/web_hammer/constants.d.ts +0 -1
  394. package/lib/typescript/web_hammer/constants.js +42 -0
  395. package/lib/typescript/web_hammer/utils.d.ts +0 -1
  396. package/lib/typescript/web_hammer/utils.js +15 -0
  397. package/package.json +4 -2
  398. package/src/components/Pressable/Pressable.tsx +357 -445
  399. package/src/components/Pressable/PressableProps.tsx +15 -0
  400. package/src/components/Pressable/StateMachine.tsx +49 -0
  401. package/src/components/Pressable/stateDefinitions.ts +125 -0
  402. package/src/components/Pressable/utils.ts +11 -7
  403. package/src/handlers/GestureHandlerEventPayload.ts +3 -0
  404. package/src/handlers/gestureHandlerTypesCompat.ts +9 -0
  405. package/src/handlers/gestures/forceTouchGesture.ts +9 -0
  406. package/src/handlers/gestures/gestureObjects.ts +3 -1
  407. package/src/web/detectors/RotationGestureDetector.ts +4 -0
  408. package/src/web/handlers/FlingGestureHandler.ts +4 -0
  409. package/src/web/handlers/GestureHandler.ts +9 -3
  410. package/src/web/handlers/PanGestureHandler.ts +25 -36
  411. package/src/web/handlers/TapGestureHandler.ts +14 -19
  412. package/src/web/tools/GestureHandlerOrchestrator.ts +1 -0
  413. package/src/web/tools/PointerEventManager.ts +1 -1
  414. package/src/web/tools/PointerTracker.ts +17 -15
  415. package/src/web/tools/Vector.ts +1 -1
@@ -0,0 +1,55 @@
1
+ import { registerHandler } from '../../handlersRegistry';
2
+ import RNGestureHandlerModule from '../../../RNGestureHandlerModule';
3
+ import { filterConfig, scheduleFlushOperations } from '../../utils';
4
+ import { ActionType } from '../../../ActionType';
5
+ import { Platform } from 'react-native';
6
+ import { ghQueueMicrotask } from '../../../ghQueueMicrotask';
7
+ import { extractGestureRelations, checkGestureCallbacksForWorklets, ALLOWED_PROPS, } from './utils';
8
+ import { MountRegistry } from '../../../mountRegistry';
9
+ export function attachHandlers({ preparedGesture, gestureConfig, gesturesToAttach, viewTag, webEventHandlersRef, }) {
10
+ gestureConfig.initialize();
11
+ // Use queueMicrotask to extract handlerTags, because all refs should be initialized
12
+ // when it's ran
13
+ ghQueueMicrotask(() => {
14
+ if (!preparedGesture.isMounted) {
15
+ return;
16
+ }
17
+ gestureConfig.prepare();
18
+ });
19
+ for (const handler of gesturesToAttach) {
20
+ checkGestureCallbacksForWorklets(handler);
21
+ RNGestureHandlerModule.createGestureHandler(handler.handlerName, handler.handlerTag, filterConfig(handler.config, ALLOWED_PROPS));
22
+ registerHandler(handler.handlerTag, handler, handler.config.testId);
23
+ }
24
+ // Use queueMicrotask to extract handlerTags, because all refs should be initialized
25
+ // when it's ran
26
+ ghQueueMicrotask(() => {
27
+ if (!preparedGesture.isMounted) {
28
+ return;
29
+ }
30
+ for (const handler of gesturesToAttach) {
31
+ RNGestureHandlerModule.updateGestureHandler(handler.handlerTag, filterConfig(handler.config, ALLOWED_PROPS, extractGestureRelations(handler)));
32
+ }
33
+ scheduleFlushOperations();
34
+ });
35
+ for (const gesture of gesturesToAttach) {
36
+ const actionType = gesture.shouldUseReanimated
37
+ ? ActionType.REANIMATED_WORKLET
38
+ : ActionType.JS_FUNCTION_NEW_API;
39
+ if (Platform.OS === 'web') {
40
+ RNGestureHandlerModule.attachGestureHandler(gesture.handlerTag, viewTag, ActionType.JS_FUNCTION_OLD_API, // Ignored on web
41
+ webEventHandlersRef);
42
+ }
43
+ else {
44
+ RNGestureHandlerModule.attachGestureHandler(gesture.handlerTag, viewTag, actionType);
45
+ }
46
+ MountRegistry.gestureWillMount(gesture);
47
+ }
48
+ preparedGesture.attachedGestures = gesturesToAttach;
49
+ if (preparedGesture.animatedHandlers) {
50
+ const isAnimatedGesture = (g) => g.shouldUseReanimated;
51
+ preparedGesture.animatedHandlers.value = gesturesToAttach
52
+ .filter(isAnimatedGesture)
53
+ .map((g) => g.handlers);
54
+ }
55
+ }
@@ -1,3 +1,2 @@
1
1
  import { AttachedGestureState } from './types';
2
2
  export declare function dropHandlers(preparedGesture: AttachedGestureState): void;
3
- //# sourceMappingURL=dropHandlers.d.ts.map
@@ -0,0 +1,12 @@
1
+ import { unregisterHandler } from '../../handlersRegistry';
2
+ import RNGestureHandlerModule from '../../../RNGestureHandlerModule';
3
+ import { scheduleFlushOperations } from '../../utils';
4
+ import { MountRegistry } from '../../../mountRegistry';
5
+ export function dropHandlers(preparedGesture) {
6
+ for (const handler of preparedGesture.attachedGestures) {
7
+ RNGestureHandlerModule.dropGestureHandler(handler.handlerTag);
8
+ unregisterHandler(handler.handlerTag, handler.config.testId);
9
+ MountRegistry.gestureWillUnmount(handler);
10
+ }
11
+ scheduleFlushOperations();
12
+ }
@@ -47,4 +47,3 @@ interface GestureDetectorProps {
47
47
  */
48
48
  export declare const GestureDetector: (props: GestureDetectorProps) => React.JSX.Element;
49
49
  export {};
50
- //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,114 @@
1
+ /* eslint-disable react/no-unused-prop-types */
2
+ import React, { useContext, useEffect, useLayoutEffect, useMemo, useRef, } from 'react';
3
+ import { Platform } from 'react-native';
4
+ import findNodeHandle from '../../../findNodeHandle';
5
+ import { isTestEnv } from '../../../utils';
6
+ import GestureHandlerRootViewContext from '../../../GestureHandlerRootViewContext';
7
+ import { useAnimatedGesture } from './useAnimatedGesture';
8
+ import { attachHandlers } from './attachHandlers';
9
+ import { needsToReattach } from './needsToReattach';
10
+ import { dropHandlers } from './dropHandlers';
11
+ import { useWebEventHandlers } from './utils';
12
+ import { Wrap, AnimatedWrap } from './Wrap';
13
+ import { useDetectorUpdater } from './useDetectorUpdater';
14
+ import { useViewRefHandler } from './useViewRefHandler';
15
+ import { useMountReactions } from './useMountReactions';
16
+ function propagateDetectorConfig(props, gesture) {
17
+ const keysToPropagate = [
18
+ 'userSelect',
19
+ 'enableContextMenu',
20
+ 'touchAction',
21
+ ];
22
+ for (const key of keysToPropagate) {
23
+ const value = props[key];
24
+ if (value === undefined) {
25
+ continue;
26
+ }
27
+ for (const g of gesture.toGestureArray()) {
28
+ const config = g.config;
29
+ config[key] = value;
30
+ }
31
+ }
32
+ }
33
+ /**
34
+ * `GestureDetector` is responsible for creating and updating native gesture handlers based on the config of provided gesture.
35
+ *
36
+ * ### Props
37
+ * - `gesture`
38
+ * - `userSelect` (**Web only**)
39
+ * - `enableContextMenu` (**Web only**)
40
+ * - `touchAction` (**Web only**)
41
+ *
42
+ * ### Remarks
43
+ * - Gesture Detector will use first native view in its subtree to recognize gestures, however if this view is used only to group its children it may get automatically collapsed.
44
+ * - Using the same instance of a gesture across multiple Gesture Detectors is not possible.
45
+ *
46
+ * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/gesture-detector
47
+ */
48
+ export const GestureDetector = (props) => {
49
+ const rootViewContext = useContext(GestureHandlerRootViewContext);
50
+ if (__DEV__ && !rootViewContext && !isTestEnv() && Platform.OS !== 'web') {
51
+ throw new Error('GestureDetector must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/installation for more details.');
52
+ }
53
+ // Gesture config should be wrapped with useMemo to prevent unnecessary re-renders
54
+ const gestureConfig = props.gesture;
55
+ propagateDetectorConfig(props, gestureConfig);
56
+ const gesturesToAttach = useMemo(() => gestureConfig.toGestureArray(), [gestureConfig]);
57
+ const shouldUseReanimated = gesturesToAttach.some((g) => g.shouldUseReanimated);
58
+ const webEventHandlersRef = useWebEventHandlers();
59
+ // Store state in ref to prevent unnecessary renders
60
+ const state = useRef({
61
+ firstRender: true,
62
+ viewRef: null,
63
+ previousViewTag: -1,
64
+ forceRebuildReanimatedEvent: false,
65
+ }).current;
66
+ const preparedGesture = React.useRef({
67
+ attachedGestures: [],
68
+ animatedEventHandler: null,
69
+ animatedHandlers: null,
70
+ shouldUseReanimated: shouldUseReanimated,
71
+ isMounted: false,
72
+ }).current;
73
+ const updateAttachedGestures = useDetectorUpdater(state, preparedGesture, gesturesToAttach, gestureConfig, webEventHandlersRef);
74
+ const refHandler = useViewRefHandler(state, updateAttachedGestures);
75
+ // Reanimated event should be rebuilt only when gestures are reattached, otherwise
76
+ // config update will be enough as all necessary items are stored in shared values anyway
77
+ const needsToRebuildReanimatedEvent = state.firstRender ||
78
+ state.forceRebuildReanimatedEvent ||
79
+ needsToReattach(preparedGesture, gesturesToAttach);
80
+ state.forceRebuildReanimatedEvent = false;
81
+ useAnimatedGesture(preparedGesture, needsToRebuildReanimatedEvent);
82
+ useLayoutEffect(() => {
83
+ const viewTag = findNodeHandle(state.viewRef);
84
+ preparedGesture.isMounted = true;
85
+ attachHandlers({
86
+ preparedGesture,
87
+ gestureConfig,
88
+ gesturesToAttach,
89
+ webEventHandlersRef,
90
+ viewTag,
91
+ });
92
+ return () => {
93
+ preparedGesture.isMounted = false;
94
+ dropHandlers(preparedGesture);
95
+ };
96
+ }, []);
97
+ useEffect(() => {
98
+ if (state.firstRender) {
99
+ state.firstRender = false;
100
+ }
101
+ else {
102
+ updateAttachedGestures();
103
+ }
104
+ }, [props]);
105
+ useMountReactions(updateAttachedGestures, preparedGesture);
106
+ if (shouldUseReanimated) {
107
+ return (<AnimatedWrap ref={refHandler} onGestureHandlerEvent={preparedGesture.animatedEventHandler}>
108
+ {props.children}
109
+ </AnimatedWrap>);
110
+ }
111
+ else {
112
+ return <Wrap ref={refHandler}>{props.children}</Wrap>;
113
+ }
114
+ };
@@ -1,4 +1,3 @@
1
1
  import { GestureType } from '../gesture';
2
2
  import { AttachedGestureState } from './types';
3
3
  export declare function needsToReattach(preparedGesture: AttachedGestureState, newGestures: GestureType[]): boolean;
4
- //# sourceMappingURL=needsToReattach.d.ts.map
@@ -0,0 +1,18 @@
1
+ // Checks whether the gesture should be reattached to the view, this will happen when:
2
+ // - The number of gestures in the preparedGesture is different than the number of gestures in the gesture
3
+ // - The handlerName is different in any of the gestures
4
+ // - At least one of the gestures changed the thread it runs on
5
+ export function needsToReattach(preparedGesture, newGestures) {
6
+ if (newGestures.length !== preparedGesture.attachedGestures.length) {
7
+ return true;
8
+ }
9
+ for (let i = 0; i < newGestures.length; i++) {
10
+ if (newGestures[i].handlerName !==
11
+ preparedGesture.attachedGestures[i].handlerName ||
12
+ newGestures[i].shouldUseReanimated !==
13
+ preparedGesture.attachedGestures[i].shouldUseReanimated) {
14
+ return true;
15
+ }
16
+ }
17
+ return false;
18
+ }
@@ -18,4 +18,3 @@ export interface WebEventHandler {
18
18
  onGestureHandlerEvent: (event: HandlerStateChangeEvent<unknown>) => void;
19
19
  onGestureHandlerStateChange?: (event: HandlerStateChangeEvent<unknown>) => void;
20
20
  }
21
- //# sourceMappingURL=types.d.ts.map
@@ -2,4 +2,3 @@ import { GestureType } from '../gesture';
2
2
  import { ComposedGesture } from '../gestureComposition';
3
3
  import { AttachedGestureState } from './types';
4
4
  export declare function updateHandlers(preparedGesture: AttachedGestureState, gestureConfig: ComposedGesture | GestureType, newGestures: GestureType[]): void;
5
- //# sourceMappingURL=updateHandlers.d.ts.map
@@ -0,0 +1,54 @@
1
+ import { registerHandler } from '../../handlersRegistry';
2
+ import RNGestureHandlerModule from '../../../RNGestureHandlerModule';
3
+ import { filterConfig, scheduleFlushOperations } from '../../utils';
4
+ import { ghQueueMicrotask } from '../../../ghQueueMicrotask';
5
+ import { extractGestureRelations, checkGestureCallbacksForWorklets, ALLOWED_PROPS, } from './utils';
6
+ export function updateHandlers(preparedGesture, gestureConfig, newGestures) {
7
+ gestureConfig.prepare();
8
+ for (let i = 0; i < newGestures.length; i++) {
9
+ const handler = preparedGesture.attachedGestures[i];
10
+ checkGestureCallbacksForWorklets(handler);
11
+ // Only update handlerTag when it's actually different, it may be the same
12
+ // if gesture config object is wrapped with useMemo
13
+ if (newGestures[i].handlerTag !== handler.handlerTag) {
14
+ newGestures[i].handlerTag = handler.handlerTag;
15
+ newGestures[i].handlers.handlerTag = handler.handlerTag;
16
+ }
17
+ }
18
+ // Store attached gestures to avoid crash when gestures changed after queueing micro task
19
+ const attachedGestures = preparedGesture.attachedGestures;
20
+ // Use queueMicrotask to extract handlerTags, because when it's ran, all refs should be updated
21
+ // and handlerTags in BaseGesture references should be updated in the loop above (we need to wait
22
+ // in case of external relations)
23
+ ghQueueMicrotask(() => {
24
+ if (!preparedGesture.isMounted) {
25
+ return;
26
+ }
27
+ // Stop if attached gestures changed after queueing micro task
28
+ if (attachedGestures !== preparedGesture.attachedGestures) {
29
+ return;
30
+ }
31
+ // If amount of gesture configs changes, we need to update the callbacks in shared value
32
+ let shouldUpdateSharedValueIfUsed = attachedGestures.length !== newGestures.length;
33
+ for (let i = 0; i < newGestures.length; i++) {
34
+ const handler = attachedGestures[i];
35
+ // If the gestureId is different (gesture isn't wrapped with useMemo or its dependencies changed),
36
+ // we need to update the shared value, assuming the gesture runs on UI thread or the thread changed
37
+ if (handler.handlers.gestureId !== newGestures[i].handlers.gestureId &&
38
+ (newGestures[i].shouldUseReanimated || handler.shouldUseReanimated)) {
39
+ shouldUpdateSharedValueIfUsed = true;
40
+ }
41
+ handler.config = newGestures[i].config;
42
+ handler.handlers = newGestures[i].handlers;
43
+ RNGestureHandlerModule.updateGestureHandler(handler.handlerTag, filterConfig(handler.config, ALLOWED_PROPS, extractGestureRelations(handler)));
44
+ registerHandler(handler.handlerTag, handler, handler.config.testId);
45
+ }
46
+ if (preparedGesture.animatedHandlers && shouldUpdateSharedValueIfUsed) {
47
+ const newHandlersValue = attachedGestures
48
+ .filter((g) => g.shouldUseReanimated) // Ignore gestures that shouldn't run on UI
49
+ .map((g) => g.handlers);
50
+ preparedGesture.animatedHandlers.value = newHandlersValue;
51
+ }
52
+ scheduleFlushOperations();
53
+ });
54
+ }
@@ -1,3 +1,2 @@
1
1
  import { AttachedGestureState } from './types';
2
2
  export declare function useAnimatedGesture(preparedGesture: AttachedGestureState, needsRebuild: boolean): void;
3
- //# sourceMappingURL=useAnimatedGesture.d.ts.map
@@ -0,0 +1,137 @@
1
+ import { CALLBACK_TYPE } from '../gesture';
2
+ import { Reanimated } from '../reanimatedWrapper';
3
+ import { GestureStateManager, } from '../gestureStateManager';
4
+ import { State } from '../../../State';
5
+ import { TouchEventType } from '../../../TouchEventType';
6
+ import { tagMessage } from '../../../utils';
7
+ function getHandler(type, gesture) {
8
+ 'worklet';
9
+ switch (type) {
10
+ case CALLBACK_TYPE.BEGAN:
11
+ return gesture.onBegin;
12
+ case CALLBACK_TYPE.START:
13
+ return gesture.onStart;
14
+ case CALLBACK_TYPE.UPDATE:
15
+ return gesture.onUpdate;
16
+ case CALLBACK_TYPE.CHANGE:
17
+ return gesture.onChange;
18
+ case CALLBACK_TYPE.END:
19
+ return gesture.onEnd;
20
+ case CALLBACK_TYPE.FINALIZE:
21
+ return gesture.onFinalize;
22
+ case CALLBACK_TYPE.TOUCHES_DOWN:
23
+ return gesture.onTouchesDown;
24
+ case CALLBACK_TYPE.TOUCHES_MOVE:
25
+ return gesture.onTouchesMove;
26
+ case CALLBACK_TYPE.TOUCHES_UP:
27
+ return gesture.onTouchesUp;
28
+ case CALLBACK_TYPE.TOUCHES_CANCELLED:
29
+ return gesture.onTouchesCancelled;
30
+ }
31
+ }
32
+ function touchEventTypeToCallbackType(eventType) {
33
+ 'worklet';
34
+ switch (eventType) {
35
+ case TouchEventType.TOUCHES_DOWN:
36
+ return CALLBACK_TYPE.TOUCHES_DOWN;
37
+ case TouchEventType.TOUCHES_MOVE:
38
+ return CALLBACK_TYPE.TOUCHES_MOVE;
39
+ case TouchEventType.TOUCHES_UP:
40
+ return CALLBACK_TYPE.TOUCHES_UP;
41
+ case TouchEventType.TOUCHES_CANCELLED:
42
+ return CALLBACK_TYPE.TOUCHES_CANCELLED;
43
+ }
44
+ return CALLBACK_TYPE.UNDEFINED;
45
+ }
46
+ function runWorklet(type, gesture, event, ...args) {
47
+ 'worklet';
48
+ const handler = getHandler(type, gesture);
49
+ if (gesture.isWorklet[type]) {
50
+ // @ts-ignore Logic below makes sure the correct event is send to the
51
+ // correct handler.
52
+ handler?.(event, ...args);
53
+ }
54
+ else if (handler) {
55
+ console.warn(tagMessage('Animated gesture callback must be a worklet'));
56
+ }
57
+ }
58
+ function isStateChangeEvent(event) {
59
+ 'worklet';
60
+ // @ts-ignore Yes, the oldState prop is missing on GestureTouchEvent, that's the point
61
+ return event.oldState != null;
62
+ }
63
+ function isTouchEvent(event) {
64
+ 'worklet';
65
+ return event.eventType != null;
66
+ }
67
+ export function useAnimatedGesture(preparedGesture, needsRebuild) {
68
+ if (!Reanimated) {
69
+ return;
70
+ }
71
+ // Hooks are called conditionally, but the condition is whether the
72
+ // react-native-reanimated is installed, which shouldn't change while running
73
+ // eslint-disable-next-line react-hooks/rules-of-hooks
74
+ const sharedHandlersCallbacks = Reanimated.useSharedValue(null);
75
+ // eslint-disable-next-line react-hooks/rules-of-hooks
76
+ const lastUpdateEvent = Reanimated.useSharedValue([]);
77
+ // not every gesture needs a state controller, init them lazily
78
+ const stateControllers = [];
79
+ const callback = (event) => {
80
+ 'worklet';
81
+ const currentCallback = sharedHandlersCallbacks.value;
82
+ if (!currentCallback) {
83
+ return;
84
+ }
85
+ for (let i = 0; i < currentCallback.length; i++) {
86
+ const gesture = currentCallback[i];
87
+ if (event.handlerTag !== gesture.handlerTag) {
88
+ continue;
89
+ }
90
+ if (isStateChangeEvent(event)) {
91
+ if (event.oldState === State.UNDETERMINED &&
92
+ event.state === State.BEGAN) {
93
+ runWorklet(CALLBACK_TYPE.BEGAN, gesture, event);
94
+ }
95
+ else if ((event.oldState === State.BEGAN ||
96
+ event.oldState === State.UNDETERMINED) &&
97
+ event.state === State.ACTIVE) {
98
+ runWorklet(CALLBACK_TYPE.START, gesture, event);
99
+ lastUpdateEvent.value[gesture.handlerTag] = undefined;
100
+ }
101
+ else if (event.oldState !== event.state &&
102
+ event.state === State.END) {
103
+ if (event.oldState === State.ACTIVE) {
104
+ runWorklet(CALLBACK_TYPE.END, gesture, event, true);
105
+ }
106
+ runWorklet(CALLBACK_TYPE.FINALIZE, gesture, event, true);
107
+ }
108
+ else if ((event.state === State.FAILED || event.state === State.CANCELLED) &&
109
+ event.state !== event.oldState) {
110
+ if (event.oldState === State.ACTIVE) {
111
+ runWorklet(CALLBACK_TYPE.END, gesture, event, false);
112
+ }
113
+ runWorklet(CALLBACK_TYPE.FINALIZE, gesture, event, false);
114
+ }
115
+ }
116
+ else if (isTouchEvent(event)) {
117
+ if (!stateControllers[i]) {
118
+ stateControllers[i] = GestureStateManager.create(event.handlerTag);
119
+ }
120
+ if (event.eventType !== TouchEventType.UNDETERMINED) {
121
+ runWorklet(touchEventTypeToCallbackType(event.eventType), gesture, event, stateControllers[i]);
122
+ }
123
+ }
124
+ else {
125
+ runWorklet(CALLBACK_TYPE.UPDATE, gesture, event);
126
+ if (gesture.onChange && gesture.changeEventCalculator) {
127
+ runWorklet(CALLBACK_TYPE.CHANGE, gesture, gesture.changeEventCalculator?.(event, lastUpdateEvent.value[gesture.handlerTag]));
128
+ lastUpdateEvent.value[gesture.handlerTag] = event;
129
+ }
130
+ }
131
+ }
132
+ };
133
+ // eslint-disable-next-line react-hooks/rules-of-hooks
134
+ const event = Reanimated.useEvent(callback, ['onGestureHandlerStateChange', 'onGestureHandlerEvent'], needsRebuild);
135
+ preparedGesture.animatedEventHandler = event;
136
+ preparedGesture.animatedHandlers = sharedHandlersCallbacks;
137
+ }
@@ -3,4 +3,3 @@ import { GestureType } from '../gesture';
3
3
  import { ComposedGesture } from '../gestureComposition';
4
4
  import { AttachedGestureState, GestureDetectorState, WebEventHandler } from './types';
5
5
  export declare function useDetectorUpdater(state: GestureDetectorState, preparedGesture: AttachedGestureState, gesturesToAttach: GestureType[], gestureConfig: ComposedGesture | GestureType, webEventHandlersRef: React.RefObject<WebEventHandler>): (skipConfigUpdate?: boolean) => void;
6
- //# sourceMappingURL=useDetectorUpdater.d.ts.map
@@ -0,0 +1,48 @@
1
+ import { useCallback } from 'react';
2
+ import { attachHandlers } from './attachHandlers';
3
+ import { updateHandlers } from './updateHandlers';
4
+ import { needsToReattach } from './needsToReattach';
5
+ import { dropHandlers } from './dropHandlers';
6
+ import { useForceRender, validateDetectorChildren } from './utils';
7
+ import findNodeHandle from '../../../findNodeHandle';
8
+ // Returns a function that's responsible for updating the attached gestures
9
+ // If the view has changed, it will reattach the handlers to the new view
10
+ // If the view remains the same, it will update the handlers with the new config
11
+ export function useDetectorUpdater(state, preparedGesture, gesturesToAttach, gestureConfig, webEventHandlersRef) {
12
+ const forceRender = useForceRender();
13
+ const updateAttachedGestures = useCallback(
14
+ // skipConfigUpdate is used to prevent unnecessary updates when only checking if the view has changed
15
+ (skipConfigUpdate) => {
16
+ // If the underlying view has changed we need to reattach handlers to the new view
17
+ const viewTag = findNodeHandle(state.viewRef);
18
+ const didUnderlyingViewChange = viewTag !== state.previousViewTag;
19
+ if (didUnderlyingViewChange ||
20
+ needsToReattach(preparedGesture, gesturesToAttach)) {
21
+ validateDetectorChildren(state.viewRef);
22
+ dropHandlers(preparedGesture);
23
+ attachHandlers({
24
+ preparedGesture,
25
+ gestureConfig,
26
+ gesturesToAttach,
27
+ webEventHandlersRef,
28
+ viewTag,
29
+ });
30
+ if (didUnderlyingViewChange) {
31
+ state.previousViewTag = viewTag;
32
+ state.forceRebuildReanimatedEvent = true;
33
+ forceRender();
34
+ }
35
+ }
36
+ else if (!skipConfigUpdate) {
37
+ updateHandlers(preparedGesture, gestureConfig, gesturesToAttach);
38
+ }
39
+ }, [
40
+ forceRender,
41
+ gestureConfig,
42
+ gesturesToAttach,
43
+ preparedGesture,
44
+ state,
45
+ webEventHandlersRef,
46
+ ]);
47
+ return updateAttachedGestures;
48
+ }
@@ -1,3 +1,2 @@
1
1
  import { AttachedGestureState } from './types';
2
2
  export declare function useMountReactions(updateDetector: () => void, state: AttachedGestureState): void;
3
- //# sourceMappingURL=useMountReactions.d.ts.map
@@ -0,0 +1,35 @@
1
+ import { transformIntoHandlerTags } from '../../utils';
2
+ import { MountRegistry } from '../../../mountRegistry';
3
+ import { useEffect } from 'react';
4
+ function shouldUpdateDetector(relation, gesture) {
5
+ if (relation === undefined) {
6
+ return false;
7
+ }
8
+ for (const tag of transformIntoHandlerTags(relation)) {
9
+ if (tag === gesture.handlerTag) {
10
+ return true;
11
+ }
12
+ }
13
+ return false;
14
+ }
15
+ export function useMountReactions(updateDetector, state) {
16
+ useEffect(() => {
17
+ return MountRegistry.addMountListener((gesture) => {
18
+ // At this point the ref in the gesture config should be updated, so we can check if one of the gestures
19
+ // set in a relation with the gesture got mounted. If so, we need to update the detector to propagate
20
+ // the changes to the native side.
21
+ for (const attachedGesture of state.attachedGestures) {
22
+ const blocksHandlers = attachedGesture.config.blocksHandlers;
23
+ const requireToFail = attachedGesture.config.requireToFail;
24
+ const simultaneousWith = attachedGesture.config.simultaneousWith;
25
+ if (shouldUpdateDetector(blocksHandlers, gesture) ||
26
+ shouldUpdateDetector(requireToFail, gesture) ||
27
+ shouldUpdateDetector(simultaneousWith, gesture)) {
28
+ updateDetector();
29
+ // We can safely return here, if any other gestures should be updated, they will be by the above call
30
+ return;
31
+ }
32
+ }
33
+ });
34
+ }, [updateDetector, state]);
35
+ }
@@ -1,4 +1,3 @@
1
1
  import { GestureDetectorState } from './types';
2
2
  import React from 'react';
3
3
  export declare function useViewRefHandler(state: GestureDetectorState, updateAttachedGestures: (skipConfigUpdate?: boolean) => void): (ref: React.Component | null) => void;
4
- //# sourceMappingURL=useViewRefHandler.d.ts.map
@@ -0,0 +1,32 @@
1
+ import { isFabric, tagMessage } from '../../../utils';
2
+ import { getShadowNodeFromRef } from '../../../getShadowNodeFromRef';
3
+ import { useCallback } from 'react';
4
+ import findNodeHandle from '../../../findNodeHandle';
5
+ // Ref handler for the Wrap component attached under the GestureDetector.
6
+ // It's responsible for setting the viewRef on the state and triggering the reattaching of handlers
7
+ // if the view has changed.
8
+ export function useViewRefHandler(state, updateAttachedGestures) {
9
+ const refHandler = useCallback((ref) => {
10
+ if (ref === null) {
11
+ return;
12
+ }
13
+ state.viewRef = ref;
14
+ // if it's the first render, also set the previousViewTag to prevent reattaching gestures when not needed
15
+ if (state.previousViewTag === -1) {
16
+ state.previousViewTag = findNodeHandle(state.viewRef);
17
+ }
18
+ // Pass true as `skipConfigUpdate`. Here we only want to trigger the eventual reattaching of handlers
19
+ // in case the view has changed. If the view doesn't change, the update will be handled by detector.
20
+ if (!state.firstRender) {
21
+ updateAttachedGestures(true);
22
+ }
23
+ if (__DEV__ && isFabric() && global.isViewFlatteningDisabled) {
24
+ const node = getShadowNodeFromRef(ref);
25
+ if (global.isViewFlatteningDisabled(node) === false) {
26
+ console.error(tagMessage('GestureDetector has received a child that may get view-flattened. ' +
27
+ '\nTo prevent it from misbehaving you need to wrap the child with a `<View collapsable={false}>`.'));
28
+ }
29
+ }
30
+ }, [state, updateAttachedGestures]);
31
+ return refHandler;
32
+ }
@@ -10,4 +10,3 @@ export declare function checkGestureCallbacksForWorklets(gesture: GestureType):
10
10
  export declare function validateDetectorChildren(ref: any): void;
11
11
  export declare function useForceRender(): () => void;
12
12
  export declare function useWebEventHandlers(): import("react").RefObject<WebEventHandler>;
13
- //# sourceMappingURL=utils.d.ts.map