react-native-gesture-handler 2.27.1 → 2.28.0

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 (426) hide show
  1. package/RNGestureHandler.podspec +3 -2
  2. package/ReanimatedSwipeable/package.json +4 -4
  3. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt +14 -8
  4. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +10 -5
  5. package/android/src/main/jni/CMakeLists.txt +5 -0
  6. package/android/src/main/jni/cpp-adapter.cpp +6 -0
  7. package/apple/RNGestureHandler.h +4 -0
  8. package/apple/RNGestureHandler.mm +41 -6
  9. package/apple/RNGestureHandlerModule.mm +5 -0
  10. package/jestSetup.js +22 -3
  11. package/lib/commonjs/components/Pressable/Pressable.js +12 -21
  12. package/lib/commonjs/components/Pressable/Pressable.js.map +1 -1
  13. package/lib/commonjs/components/Pressable/StateMachine.js +8 -2
  14. package/lib/commonjs/components/Pressable/StateMachine.js.map +1 -1
  15. package/lib/commonjs/components/Pressable/stateDefinitions.js +22 -23
  16. package/lib/commonjs/components/Pressable/stateDefinitions.js.map +1 -1
  17. package/lib/commonjs/components/{ReanimatedSwipeable.js → ReanimatedSwipeable/ReanimatedSwipeable.js} +30 -39
  18. package/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeable.js.map +1 -0
  19. package/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeableProps.js +12 -0
  20. package/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeableProps.js.map +1 -0
  21. package/lib/commonjs/components/ReanimatedSwipeable/index.js +21 -0
  22. package/lib/commonjs/components/ReanimatedSwipeable/index.js.map +1 -0
  23. package/lib/commonjs/components/gestureHandlerRootHOC.js +4 -1
  24. package/lib/commonjs/components/gestureHandlerRootHOC.js.map +1 -1
  25. package/lib/commonjs/handlers/createHandler.js +1 -1
  26. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  27. package/lib/commonjs/handlers/gestures/GestureDetector/index.js +1 -1
  28. package/lib/commonjs/handlers/gestures/GestureDetector/index.js.map +1 -1
  29. package/lib/commonjs/mocks/Pressable.js +13 -0
  30. package/lib/commonjs/mocks/Pressable.js.map +1 -0
  31. package/lib/commonjs/{mocks.js → mocks/mocks.js} +8 -11
  32. package/lib/commonjs/mocks/mocks.js.map +1 -0
  33. package/lib/commonjs/web/handlers/GestureHandler.js +5 -2
  34. package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
  35. package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js +0 -5
  36. package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js.map +1 -1
  37. package/lib/commonjs/web/tools/KeyboardEventManager.js +34 -8
  38. package/lib/commonjs/web/tools/KeyboardEventManager.js.map +1 -1
  39. package/lib/module/components/Pressable/Pressable.js +14 -23
  40. package/lib/module/components/Pressable/Pressable.js.map +1 -1
  41. package/lib/module/components/Pressable/StateMachine.js +8 -2
  42. package/lib/module/components/Pressable/StateMachine.js.map +1 -1
  43. package/lib/module/components/Pressable/stateDefinitions.js +21 -22
  44. package/lib/module/components/Pressable/stateDefinitions.js.map +1 -1
  45. package/lib/module/components/{ReanimatedSwipeable.js → ReanimatedSwipeable/ReanimatedSwipeable.js} +24 -33
  46. package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeable.js.map +1 -0
  47. package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeableProps.js +8 -0
  48. package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeableProps.js.map +1 -0
  49. package/lib/module/components/ReanimatedSwipeable/index.js +5 -0
  50. package/lib/module/components/ReanimatedSwipeable/index.js.map +1 -0
  51. package/lib/module/components/gestureHandlerRootHOC.js +5 -0
  52. package/lib/module/components/gestureHandlerRootHOC.js.map +1 -1
  53. package/lib/module/handlers/createHandler.js +1 -1
  54. package/lib/module/handlers/createHandler.js.map +1 -1
  55. package/lib/module/handlers/gestures/GestureDetector/index.js +1 -1
  56. package/lib/module/handlers/gestures/GestureDetector/index.js.map +1 -1
  57. package/lib/module/mocks/Pressable.js +4 -0
  58. package/lib/module/mocks/Pressable.js.map +1 -0
  59. package/lib/module/{mocks.js → mocks/mocks.js} +7 -11
  60. package/lib/module/mocks/mocks.js.map +1 -0
  61. package/lib/module/web/handlers/GestureHandler.js +5 -2
  62. package/lib/module/web/handlers/GestureHandler.js.map +1 -1
  63. package/lib/module/web/tools/GestureHandlerWebDelegate.js +0 -5
  64. package/lib/module/web/tools/GestureHandlerWebDelegate.js.map +1 -1
  65. package/lib/module/web/tools/KeyboardEventManager.js +34 -8
  66. package/lib/module/web/tools/KeyboardEventManager.js.map +1 -1
  67. package/lib/typescript/ActionType.d.ts +1 -0
  68. package/lib/typescript/Directions.d.ts +1 -0
  69. package/lib/typescript/EnableNewWebImplementation.d.ts +1 -0
  70. package/lib/typescript/GestureHandlerRootViewContext.d.ts +1 -0
  71. package/lib/typescript/PlatformConstants.d.ts +1 -0
  72. package/lib/typescript/PlatformConstants.web.d.ts +1 -0
  73. package/lib/typescript/PointerType.d.ts +1 -0
  74. package/lib/typescript/RNGestureHandlerModule.d.ts +1 -0
  75. package/lib/typescript/RNGestureHandlerModule.web.d.ts +1 -0
  76. package/lib/typescript/RNGestureHandlerModule.windows.d.ts +1 -0
  77. package/lib/typescript/RNRenderer.d.ts +1 -0
  78. package/lib/typescript/RNRenderer.web.d.ts +1 -0
  79. package/lib/typescript/State.d.ts +1 -0
  80. package/lib/typescript/TouchEventType.d.ts +1 -0
  81. package/lib/typescript/components/DrawerLayout.d.ts +1 -0
  82. package/lib/typescript/components/GestureButtons.d.ts +1 -0
  83. package/lib/typescript/components/GestureButtonsProps.d.ts +10 -1
  84. package/lib/typescript/components/GestureButtonsProps.d.ts.map +1 -1
  85. package/lib/typescript/components/GestureComponents.d.ts +1 -0
  86. package/lib/typescript/components/GestureComponents.web.d.ts +1 -0
  87. package/lib/typescript/components/GestureHandlerButton.d.ts +1 -0
  88. package/lib/typescript/components/GestureHandlerButton.web.d.ts +1 -0
  89. package/lib/typescript/components/GestureHandlerRootView.android.d.ts +1 -0
  90. package/lib/typescript/components/GestureHandlerRootView.d.ts +1 -0
  91. package/lib/typescript/components/GestureHandlerRootView.web.d.ts +1 -0
  92. package/lib/typescript/components/Pressable/Pressable.d.ts +1 -0
  93. package/lib/typescript/components/Pressable/Pressable.d.ts.map +1 -1
  94. package/lib/typescript/components/Pressable/PressableProps.d.ts +3 -4
  95. package/lib/typescript/components/Pressable/PressableProps.d.ts.map +1 -1
  96. package/lib/typescript/components/Pressable/StateMachine.d.ts +4 -2
  97. package/lib/typescript/components/Pressable/StateMachine.d.ts.map +1 -1
  98. package/lib/typescript/components/Pressable/index.d.ts +1 -0
  99. package/lib/typescript/components/Pressable/stateDefinitions.d.ts +3 -2
  100. package/lib/typescript/components/Pressable/stateDefinitions.d.ts.map +1 -1
  101. package/lib/typescript/components/Pressable/utils.d.ts +1 -0
  102. package/lib/typescript/components/ReanimatedDrawerLayout.d.ts +1 -0
  103. package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeable.d.ts +6 -0
  104. package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeable.d.ts.map +1 -0
  105. package/lib/typescript/components/{ReanimatedSwipeable.d.ts → ReanimatedSwipeable/ReanimatedSwipeableProps.d.ts} +10 -7
  106. package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeableProps.d.ts.map +1 -0
  107. package/lib/typescript/components/ReanimatedSwipeable/index.d.ts +3 -0
  108. package/lib/typescript/components/ReanimatedSwipeable/index.d.ts.map +1 -0
  109. package/lib/typescript/components/Swipeable.d.ts +1 -0
  110. package/lib/typescript/components/Text.d.ts +1 -0
  111. package/lib/typescript/components/gestureHandlerRootHOC.d.ts +5 -0
  112. package/lib/typescript/components/gestureHandlerRootHOC.d.ts.map +1 -1
  113. package/lib/typescript/components/touchables/ExtraButtonProps.d.ts +1 -0
  114. package/lib/typescript/components/touchables/GenericTouchable.d.ts +1 -0
  115. package/lib/typescript/components/touchables/GenericTouchableProps.d.ts +1 -0
  116. package/lib/typescript/components/touchables/TouchableHighlight.d.ts +1 -0
  117. package/lib/typescript/components/touchables/TouchableNativeFeedback.android.d.ts +1 -0
  118. package/lib/typescript/components/touchables/TouchableNativeFeedback.d.ts +1 -0
  119. package/lib/typescript/components/touchables/TouchableNativeFeedbackProps.d.ts +1 -0
  120. package/lib/typescript/components/touchables/TouchableOpacity.d.ts +1 -0
  121. package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts +1 -0
  122. package/lib/typescript/components/touchables/index.d.ts +1 -0
  123. package/lib/typescript/components/utils.d.ts +1 -0
  124. package/lib/typescript/findNodeHandle.d.ts +1 -0
  125. package/lib/typescript/findNodeHandle.web.d.ts +1 -0
  126. package/lib/typescript/getShadowNodeFromRef.d.ts +1 -0
  127. package/lib/typescript/getShadowNodeFromRef.web.d.ts +1 -0
  128. package/lib/typescript/ghQueueMicrotask.d.ts +1 -0
  129. package/lib/typescript/handlers/FlingGestureHandler.d.ts +1 -0
  130. package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +1 -0
  131. package/lib/typescript/handlers/GestureHandlerEventPayload.d.ts +1 -0
  132. package/lib/typescript/handlers/LongPressGestureHandler.d.ts +1 -0
  133. package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +1 -0
  134. package/lib/typescript/handlers/PanGestureHandler.d.ts +1 -0
  135. package/lib/typescript/handlers/PinchGestureHandler.d.ts +1 -0
  136. package/lib/typescript/handlers/PressabilityDebugView.d.ts +1 -0
  137. package/lib/typescript/handlers/PressabilityDebugView.web.d.ts +1 -0
  138. package/lib/typescript/handlers/RotationGestureHandler.d.ts +1 -0
  139. package/lib/typescript/handlers/TapGestureHandler.d.ts +1 -0
  140. package/lib/typescript/handlers/createHandler.d.ts +1 -0
  141. package/lib/typescript/handlers/createNativeWrapper.d.ts +1 -0
  142. package/lib/typescript/handlers/customDirectEventTypes.d.ts +1 -0
  143. package/lib/typescript/handlers/customDirectEventTypes.web.d.ts +1 -0
  144. package/lib/typescript/handlers/gestureHandlerCommon.d.ts +1 -0
  145. package/lib/typescript/handlers/gestureHandlerTypesCompat.d.ts +1 -0
  146. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.d.ts +1 -0
  147. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.web.d.ts +1 -0
  148. package/lib/typescript/handlers/gestures/GestureDetector/attachHandlers.d.ts +1 -0
  149. package/lib/typescript/handlers/gestures/GestureDetector/dropHandlers.d.ts +1 -0
  150. package/lib/typescript/handlers/gestures/GestureDetector/index.d.ts +1 -0
  151. package/lib/typescript/handlers/gestures/GestureDetector/needsToReattach.d.ts +1 -0
  152. package/lib/typescript/handlers/gestures/GestureDetector/types.d.ts +1 -0
  153. package/lib/typescript/handlers/gestures/GestureDetector/updateHandlers.d.ts +1 -0
  154. package/lib/typescript/handlers/gestures/GestureDetector/useAnimatedGesture.d.ts +1 -0
  155. package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.d.ts +1 -0
  156. package/lib/typescript/handlers/gestures/GestureDetector/useMountReactions.d.ts +1 -0
  157. package/lib/typescript/handlers/gestures/GestureDetector/useViewRefHandler.d.ts +1 -0
  158. package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts +1 -0
  159. package/lib/typescript/handlers/gestures/eventReceiver.d.ts +1 -0
  160. package/lib/typescript/handlers/gestures/flingGesture.d.ts +1 -0
  161. package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +1 -0
  162. package/lib/typescript/handlers/gestures/gesture.d.ts +1 -0
  163. package/lib/typescript/handlers/gestures/gestureComposition.d.ts +1 -0
  164. package/lib/typescript/handlers/gestures/gestureObjects.d.ts +1 -0
  165. package/lib/typescript/handlers/gestures/gestureStateManager.d.ts +1 -0
  166. package/lib/typescript/handlers/gestures/gestureStateManager.web.d.ts +1 -0
  167. package/lib/typescript/handlers/gestures/hoverGesture.d.ts +1 -0
  168. package/lib/typescript/handlers/gestures/longPressGesture.d.ts +1 -0
  169. package/lib/typescript/handlers/gestures/manualGesture.d.ts +1 -0
  170. package/lib/typescript/handlers/gestures/nativeGesture.d.ts +1 -0
  171. package/lib/typescript/handlers/gestures/panGesture.d.ts +1 -0
  172. package/lib/typescript/handlers/gestures/pinchGesture.d.ts +1 -0
  173. package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts +1 -0
  174. package/lib/typescript/handlers/gestures/rotationGesture.d.ts +1 -0
  175. package/lib/typescript/handlers/gestures/tapGesture.d.ts +1 -0
  176. package/lib/typescript/handlers/getNextHandlerTag.d.ts +1 -0
  177. package/lib/typescript/handlers/handlersRegistry.d.ts +1 -0
  178. package/lib/typescript/handlers/utils.d.ts +1 -0
  179. package/lib/typescript/index.d.ts +1 -0
  180. package/lib/typescript/init.d.ts +1 -0
  181. package/lib/typescript/jestUtils/index.d.ts +1 -0
  182. package/lib/typescript/jestUtils/jestUtils.d.ts +1 -0
  183. package/lib/typescript/mocks/Pressable.d.ts +2 -0
  184. package/lib/typescript/mocks/Pressable.d.ts.map +1 -0
  185. package/lib/typescript/{mocks.d.ts → mocks/mocks.d.ts} +5 -4
  186. package/lib/typescript/mocks/mocks.d.ts.map +1 -0
  187. package/lib/typescript/mountRegistry.d.ts +1 -0
  188. package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts +1 -0
  189. package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts +1 -0
  190. package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.d.ts +1 -0
  191. package/lib/typescript/typeUtils.d.ts +1 -0
  192. package/lib/typescript/utils.d.ts +1 -0
  193. package/lib/typescript/web/Gestures.d.ts +1 -0
  194. package/lib/typescript/web/constants.d.ts +1 -0
  195. package/lib/typescript/web/detectors/RotationGestureDetector.d.ts +1 -0
  196. package/lib/typescript/web/detectors/ScaleGestureDetector.d.ts +1 -0
  197. package/lib/typescript/web/handlers/FlingGestureHandler.d.ts +1 -0
  198. package/lib/typescript/web/handlers/GestureHandler.d.ts +1 -0
  199. package/lib/typescript/web/handlers/GestureHandler.d.ts.map +1 -1
  200. package/lib/typescript/web/handlers/HoverGestureHandler.d.ts +1 -0
  201. package/lib/typescript/web/handlers/IGestureHandler.d.ts +1 -0
  202. package/lib/typescript/web/handlers/LongPressGestureHandler.d.ts +1 -0
  203. package/lib/typescript/web/handlers/ManualGestureHandler.d.ts +1 -0
  204. package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +1 -0
  205. package/lib/typescript/web/handlers/PanGestureHandler.d.ts +1 -0
  206. package/lib/typescript/web/handlers/PinchGestureHandler.d.ts +1 -0
  207. package/lib/typescript/web/handlers/RotationGestureHandler.d.ts +1 -0
  208. package/lib/typescript/web/handlers/TapGestureHandler.d.ts +1 -0
  209. package/lib/typescript/web/interfaces.d.ts +1 -0
  210. package/lib/typescript/web/tools/CircularBuffer.d.ts +1 -0
  211. package/lib/typescript/web/tools/EventManager.d.ts +1 -0
  212. package/lib/typescript/web/tools/GestureHandlerDelegate.d.ts +1 -0
  213. package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts +1 -0
  214. package/lib/typescript/web/tools/GestureHandlerWebDelegate.d.ts +1 -0
  215. package/lib/typescript/web/tools/GestureHandlerWebDelegate.d.ts.map +1 -1
  216. package/lib/typescript/web/tools/InteractionManager.d.ts +1 -0
  217. package/lib/typescript/web/tools/KeyboardEventManager.d.ts +7 -3
  218. package/lib/typescript/web/tools/KeyboardEventManager.d.ts.map +1 -1
  219. package/lib/typescript/web/tools/LeastSquareSolver.d.ts +1 -0
  220. package/lib/typescript/web/tools/NodeManager.d.ts +1 -0
  221. package/lib/typescript/web/tools/PointerEventManager.d.ts +1 -0
  222. package/lib/typescript/web/tools/PointerTracker.d.ts +1 -0
  223. package/lib/typescript/web/tools/Vector.d.ts +1 -0
  224. package/lib/typescript/web/tools/VelocityTracker.d.ts +1 -0
  225. package/lib/typescript/web/tools/WheelEventManager.d.ts +1 -0
  226. package/lib/typescript/web/utils.d.ts +1 -0
  227. package/lib/typescript/web_hammer/DiscreteGestureHandler.d.ts +1 -0
  228. package/lib/typescript/web_hammer/DraggingGestureHandler.d.ts +1 -0
  229. package/lib/typescript/web_hammer/Errors.d.ts +1 -0
  230. package/lib/typescript/web_hammer/FlingGestureHandler.d.ts +1 -0
  231. package/lib/typescript/web_hammer/GestureHandler.d.ts +1 -0
  232. package/lib/typescript/web_hammer/IndiscreteGestureHandler.d.ts +1 -0
  233. package/lib/typescript/web_hammer/LongPressGestureHandler.d.ts +1 -0
  234. package/lib/typescript/web_hammer/NativeViewGestureHandler.d.ts +1 -0
  235. package/lib/typescript/web_hammer/NodeManager.d.ts +1 -0
  236. package/lib/typescript/web_hammer/PanGestureHandler.d.ts +1 -0
  237. package/lib/typescript/web_hammer/PinchGestureHandler.d.ts +1 -0
  238. package/lib/typescript/web_hammer/PressGestureHandler.d.ts +1 -0
  239. package/lib/typescript/web_hammer/RotationGestureHandler.d.ts +1 -0
  240. package/lib/typescript/web_hammer/TapGestureHandler.d.ts +1 -0
  241. package/lib/typescript/web_hammer/constants.d.ts +1 -0
  242. package/lib/typescript/web_hammer/utils.d.ts +1 -0
  243. package/package.json +4 -3
  244. package/scripts/gesture_handler_utils.rb +25 -0
  245. package/src/components/GestureButtonsProps.ts +10 -0
  246. package/src/components/Pressable/Pressable.tsx +20 -31
  247. package/src/components/Pressable/PressableProps.tsx +2 -4
  248. package/src/components/Pressable/StateMachine.tsx +12 -4
  249. package/src/components/Pressable/stateDefinitions.ts +23 -23
  250. package/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx +603 -0
  251. package/src/components/ReanimatedSwipeable/ReanimatedSwipeableProps.ts +199 -0
  252. package/src/components/ReanimatedSwipeable/index.ts +6 -0
  253. package/src/components/gestureHandlerRootHOC.tsx +4 -0
  254. package/src/handlers/createHandler.tsx +1 -1
  255. package/src/handlers/gestures/GestureDetector/index.tsx +1 -1
  256. package/src/mocks/Pressable.tsx +1 -0
  257. package/src/{mocks.tsx → mocks/mocks.tsx} +7 -11
  258. package/src/web/handlers/GestureHandler.ts +8 -3
  259. package/src/web/tools/GestureHandlerWebDelegate.ts +0 -5
  260. package/src/web/tools/KeyboardEventManager.ts +50 -8
  261. package/lib/commonjs/components/ReanimatedSwipeable.js.map +0 -1
  262. package/lib/commonjs/mocks.js.map +0 -1
  263. package/lib/module/components/ReanimatedSwipeable.js.map +0 -1
  264. package/lib/module/mocks.js.map +0 -1
  265. package/lib/typescript/ActionType.js +0 -6
  266. package/lib/typescript/Directions.js +0 -18
  267. package/lib/typescript/EnableNewWebImplementation.js +0 -30
  268. package/lib/typescript/GestureHandlerRootViewContext.js +0 -2
  269. package/lib/typescript/PlatformConstants.js +0 -3
  270. package/lib/typescript/PlatformConstants.web.js +0 -5
  271. package/lib/typescript/PointerType.js +0 -8
  272. package/lib/typescript/RNGestureHandlerModule.js +0 -4
  273. package/lib/typescript/RNGestureHandlerModule.web.js +0 -92
  274. package/lib/typescript/RNGestureHandlerModule.windows.js +0 -47
  275. package/lib/typescript/RNRenderer.js +0 -3
  276. package/lib/typescript/RNRenderer.web.js +0 -3
  277. package/lib/typescript/State.js +0 -9
  278. package/lib/typescript/TouchEventType.js +0 -7
  279. package/lib/typescript/components/DrawerLayout.js +0 -417
  280. package/lib/typescript/components/GestureButtons.js +0 -165
  281. package/lib/typescript/components/GestureButtonsProps.js +0 -1
  282. package/lib/typescript/components/GestureComponents.js +0 -67
  283. package/lib/typescript/components/GestureComponents.web.js +0 -21
  284. package/lib/typescript/components/GestureHandlerButton.js +0 -2
  285. package/lib/typescript/components/GestureHandlerButton.web.js +0 -3
  286. package/lib/typescript/components/GestureHandlerRootView.android.js +0 -17
  287. package/lib/typescript/components/GestureHandlerRootView.js +0 -16
  288. package/lib/typescript/components/GestureHandlerRootView.web.js +0 -11
  289. package/lib/typescript/components/Pressable/Pressable.js +0 -231
  290. package/lib/typescript/components/Pressable/PressableProps.js +0 -1
  291. package/lib/typescript/components/Pressable/StateMachine.js +0 -34
  292. package/lib/typescript/components/Pressable/index.js +0 -1
  293. package/lib/typescript/components/Pressable/stateDefinitions.js +0 -104
  294. package/lib/typescript/components/Pressable/utils.js +0 -80
  295. package/lib/typescript/components/ReanimatedDrawerLayout.js +0 -364
  296. package/lib/typescript/components/ReanimatedSwipeable.d.ts.map +0 -1
  297. package/lib/typescript/components/ReanimatedSwipeable.js +0 -400
  298. package/lib/typescript/components/Swipeable.js +0 -287
  299. package/lib/typescript/components/Text.js +0 -38
  300. package/lib/typescript/components/gestureHandlerRootHOC.js +0 -18
  301. package/lib/typescript/components/touchables/ExtraButtonProps.js +0 -1
  302. package/lib/typescript/components/touchables/GenericTouchable.js +0 -221
  303. package/lib/typescript/components/touchables/GenericTouchableProps.js +0 -1
  304. package/lib/typescript/components/touchables/TouchableHighlight.js +0 -75
  305. package/lib/typescript/components/touchables/TouchableNativeFeedback.android.js +0 -65
  306. package/lib/typescript/components/touchables/TouchableNativeFeedback.js +0 -6
  307. package/lib/typescript/components/touchables/TouchableNativeFeedbackProps.js +0 -1
  308. package/lib/typescript/components/touchables/TouchableOpacity.js +0 -51
  309. package/lib/typescript/components/touchables/TouchableWithoutFeedback.js +0 -10
  310. package/lib/typescript/components/touchables/index.js +0 -4
  311. package/lib/typescript/components/utils.js +0 -11
  312. package/lib/typescript/findNodeHandle.js +0 -2
  313. package/lib/typescript/findNodeHandle.web.js +0 -31
  314. package/lib/typescript/getShadowNodeFromRef.js +0 -45
  315. package/lib/typescript/getShadowNodeFromRef.web.js +0 -7
  316. package/lib/typescript/ghQueueMicrotask.js +0 -7
  317. package/lib/typescript/handlers/FlingGestureHandler.js +0 -19
  318. package/lib/typescript/handlers/ForceTouchGestureHandler.js +0 -37
  319. package/lib/typescript/handlers/GestureHandlerEventPayload.js +0 -1
  320. package/lib/typescript/handlers/LongPressGestureHandler.js +0 -22
  321. package/lib/typescript/handlers/NativeViewGestureHandler.js +0 -20
  322. package/lib/typescript/handlers/PanGestureHandler.js +0 -128
  323. package/lib/typescript/handlers/PinchGestureHandler.js +0 -12
  324. package/lib/typescript/handlers/PressabilityDebugView.js +0 -2
  325. package/lib/typescript/handlers/PressabilityDebugView.web.js +0 -4
  326. package/lib/typescript/handlers/RotationGestureHandler.js +0 -12
  327. package/lib/typescript/handlers/TapGestureHandler.js +0 -26
  328. package/lib/typescript/handlers/createHandler.js +0 -375
  329. package/lib/typescript/handlers/createNativeWrapper.js +0 -67
  330. package/lib/typescript/handlers/customDirectEventTypes.js +0 -2
  331. package/lib/typescript/handlers/customDirectEventTypes.web.js +0 -4
  332. package/lib/typescript/handlers/gestureHandlerCommon.js +0 -42
  333. package/lib/typescript/handlers/gestureHandlerTypesCompat.js +0 -1
  334. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.js +0 -22
  335. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.web.js +0 -24
  336. package/lib/typescript/handlers/gestures/GestureDetector/attachHandlers.js +0 -55
  337. package/lib/typescript/handlers/gestures/GestureDetector/dropHandlers.js +0 -12
  338. package/lib/typescript/handlers/gestures/GestureDetector/index.js +0 -114
  339. package/lib/typescript/handlers/gestures/GestureDetector/needsToReattach.js +0 -18
  340. package/lib/typescript/handlers/gestures/GestureDetector/types.js +0 -1
  341. package/lib/typescript/handlers/gestures/GestureDetector/updateHandlers.js +0 -54
  342. package/lib/typescript/handlers/gestures/GestureDetector/useAnimatedGesture.js +0 -137
  343. package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.js +0 -48
  344. package/lib/typescript/handlers/gestures/GestureDetector/useMountReactions.js +0 -35
  345. package/lib/typescript/handlers/gestures/GestureDetector/useViewRefHandler.js +0 -32
  346. package/lib/typescript/handlers/gestures/GestureDetector/utils.js +0 -140
  347. package/lib/typescript/handlers/gestures/eventReceiver.js +0 -105
  348. package/lib/typescript/handlers/gestures/flingGesture.js +0 -27
  349. package/lib/typescript/handlers/gestures/forceTouchGesture.js +0 -57
  350. package/lib/typescript/handlers/gestures/gesture.js +0 -303
  351. package/lib/typescript/handlers/gestures/gestureComposition.js +0 -78
  352. package/lib/typescript/handlers/gestures/gestureObjects.js +0 -125
  353. package/lib/typescript/handlers/gestures/gestureStateManager.js +0 -60
  354. package/lib/typescript/handlers/gestures/gestureStateManager.web.js +0 -19
  355. package/lib/typescript/handlers/gestures/hoverGesture.js +0 -45
  356. package/lib/typescript/handlers/gestures/longPressGesture.js +0 -35
  357. package/lib/typescript/handlers/gestures/manualGesture.js +0 -16
  358. package/lib/typescript/handlers/gestures/nativeGesture.js +0 -24
  359. package/lib/typescript/handlers/gestures/panGesture.js +0 -181
  360. package/lib/typescript/handlers/gestures/pinchGesture.js +0 -27
  361. package/lib/typescript/handlers/gestures/reanimatedWrapper.js +0 -23
  362. package/lib/typescript/handlers/gestures/rotationGesture.js +0 -27
  363. package/lib/typescript/handlers/gestures/tapGesture.js +0 -72
  364. package/lib/typescript/handlers/getNextHandlerTag.js +0 -4
  365. package/lib/typescript/handlers/handlersRegistry.js +0 -36
  366. package/lib/typescript/handlers/utils.js +0 -58
  367. package/lib/typescript/index.js +0 -28
  368. package/lib/typescript/init.js +0 -15
  369. package/lib/typescript/jestUtils/index.js +0 -1
  370. package/lib/typescript/jestUtils/jestUtils.js +0 -290
  371. package/lib/typescript/mocks.d.ts.map +0 -1
  372. package/lib/typescript/mocks.js +0 -59
  373. package/lib/typescript/mountRegistry.js +0 -29
  374. package/lib/typescript/specs/NativeRNGestureHandlerModule.js +0 -2
  375. package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.js +0 -2
  376. package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.js +0 -2
  377. package/lib/typescript/typeUtils.js +0 -1
  378. package/lib/typescript/utils.js +0 -80
  379. package/lib/typescript/web/Gestures.js +0 -38
  380. package/lib/typescript/web/constants.js +0 -2
  381. package/lib/typescript/web/detectors/RotationGestureDetector.js +0 -122
  382. package/lib/typescript/web/detectors/ScaleGestureDetector.js +0 -117
  383. package/lib/typescript/web/handlers/FlingGestureHandler.js +0 -133
  384. package/lib/typescript/web/handlers/GestureHandler.js +0 -656
  385. package/lib/typescript/web/handlers/HoverGestureHandler.js +0 -37
  386. package/lib/typescript/web/handlers/IGestureHandler.js +0 -1
  387. package/lib/typescript/web/handlers/LongPressGestureHandler.js +0 -136
  388. package/lib/typescript/web/handlers/ManualGestureHandler.js +0 -29
  389. package/lib/typescript/web/handlers/NativeViewGestureHandler.js +0 -133
  390. package/lib/typescript/web/handlers/PanGestureHandler.js +0 -420
  391. package/lib/typescript/web/handlers/PinchGestureHandler.js +0 -117
  392. package/lib/typescript/web/handlers/RotationGestureHandler.js +0 -122
  393. package/lib/typescript/web/handlers/TapGestureHandler.js +0 -202
  394. package/lib/typescript/web/interfaces.js +0 -25
  395. package/lib/typescript/web/tools/CircularBuffer.js +0 -37
  396. package/lib/typescript/web/tools/EventManager.js +0 -85
  397. package/lib/typescript/web/tools/GestureHandlerDelegate.js +0 -1
  398. package/lib/typescript/web/tools/GestureHandlerOrchestrator.js +0 -273
  399. package/lib/typescript/web/tools/GestureHandlerWebDelegate.js +0 -169
  400. package/lib/typescript/web/tools/InteractionManager.js +0 -91
  401. package/lib/typescript/web/tools/KeyboardEventManager.js +0 -73
  402. package/lib/typescript/web/tools/LeastSquareSolver.js +0 -147
  403. package/lib/typescript/web/tools/NodeManager.js +0 -28
  404. package/lib/typescript/web/tools/PointerEventManager.js +0 -179
  405. package/lib/typescript/web/tools/PointerTracker.js +0 -161
  406. package/lib/typescript/web/tools/Vector.js +0 -43
  407. package/lib/typescript/web/tools/VelocityTracker.js +0 -76
  408. package/lib/typescript/web/tools/WheelEventManager.js +0 -40
  409. package/lib/typescript/web/utils.js +0 -233
  410. package/lib/typescript/web_hammer/DiscreteGestureHandler.js +0 -48
  411. package/lib/typescript/web_hammer/DraggingGestureHandler.js +0 -25
  412. package/lib/typescript/web_hammer/Errors.js +0 -5
  413. package/lib/typescript/web_hammer/FlingGestureHandler.js +0 -119
  414. package/lib/typescript/web_hammer/GestureHandler.js +0 -469
  415. package/lib/typescript/web_hammer/IndiscreteGestureHandler.js +0 -26
  416. package/lib/typescript/web_hammer/LongPressGestureHandler.js +0 -46
  417. package/lib/typescript/web_hammer/NativeViewGestureHandler.js +0 -40
  418. package/lib/typescript/web_hammer/NodeManager.js +0 -28
  419. package/lib/typescript/web_hammer/PanGestureHandler.js +0 -151
  420. package/lib/typescript/web_hammer/PinchGestureHandler.js +0 -19
  421. package/lib/typescript/web_hammer/PressGestureHandler.js +0 -133
  422. package/lib/typescript/web_hammer/RotationGestureHandler.js +0 -20
  423. package/lib/typescript/web_hammer/TapGestureHandler.js +0 -142
  424. package/lib/typescript/web_hammer/constants.js +0 -42
  425. package/lib/typescript/web_hammer/utils.js +0 -15
  426. package/src/components/ReanimatedSwipeable.tsx +0 -811
@@ -1,32 +0,0 @@
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
- }
@@ -1,140 +0,0 @@
1
- import { Platform } from 'react-native';
2
- import { isTestEnv, tagMessage } from '../../../utils';
3
- import { BaseGesture } from '../gesture';
4
- import { flingGestureHandlerProps } from '../../FlingGestureHandler';
5
- import { forceTouchGestureHandlerProps } from '../../ForceTouchGestureHandler';
6
- import { longPressGestureHandlerProps } from '../../LongPressGestureHandler';
7
- import { panGestureHandlerProps, panGestureHandlerCustomNativeProps, } from '../../PanGestureHandler';
8
- import { tapGestureHandlerProps } from '../../TapGestureHandler';
9
- import { hoverGestureHandlerProps } from '../hoverGesture';
10
- import { nativeViewGestureHandlerProps } from '../../NativeViewGestureHandler';
11
- import { baseGestureHandlerWithDetectorProps, } from '../../gestureHandlerCommon';
12
- import { isNewWebImplementationEnabled } from '../../../EnableNewWebImplementation';
13
- import { RNRenderer } from '../../../RNRenderer';
14
- import { useCallback, useRef, useState } from 'react';
15
- import { Reanimated } from '../reanimatedWrapper';
16
- import { onGestureHandlerEvent } from '../eventReceiver';
17
- export const ALLOWED_PROPS = [
18
- ...baseGestureHandlerWithDetectorProps,
19
- ...tapGestureHandlerProps,
20
- ...panGestureHandlerProps,
21
- ...panGestureHandlerCustomNativeProps,
22
- ...longPressGestureHandlerProps,
23
- ...forceTouchGestureHandlerProps,
24
- ...flingGestureHandlerProps,
25
- ...hoverGestureHandlerProps,
26
- ...nativeViewGestureHandlerProps,
27
- ];
28
- function convertToHandlerTag(ref) {
29
- if (typeof ref === 'number') {
30
- return ref;
31
- }
32
- else if (ref instanceof BaseGesture) {
33
- return ref.handlerTag;
34
- }
35
- else {
36
- // @ts-ignore in this case it should be a ref either to gesture object or
37
- // a gesture handler component, in both cases handlerTag property exists
38
- return ref.current?.handlerTag ?? -1;
39
- }
40
- }
41
- function extractValidHandlerTags(interactionGroup) {
42
- return (interactionGroup?.map(convertToHandlerTag)?.filter((tag) => tag > 0) ?? []);
43
- }
44
- export function extractGestureRelations(gesture) {
45
- const requireToFail = extractValidHandlerTags(gesture.config.requireToFail);
46
- const simultaneousWith = extractValidHandlerTags(gesture.config.simultaneousWith);
47
- const blocksHandlers = extractValidHandlerTags(gesture.config.blocksHandlers);
48
- return {
49
- waitFor: requireToFail,
50
- simultaneousHandlers: simultaneousWith,
51
- blocksHandlers: blocksHandlers,
52
- };
53
- }
54
- export function checkGestureCallbacksForWorklets(gesture) {
55
- if (!__DEV__) {
56
- return;
57
- }
58
- // If a gesture is explicitly marked to run on the JS thread there is no need to check
59
- // if callbacks are worklets as the user is aware they will be ran on the JS thread
60
- if (gesture.config.runOnJS) {
61
- return;
62
- }
63
- const areSomeNotWorklets = gesture.handlers.isWorklet.includes(false);
64
- const areSomeWorklets = gesture.handlers.isWorklet.includes(true);
65
- // If some of the callbacks are worklets and some are not, and the gesture is not
66
- // explicitly marked with `.runOnJS(true)` show an error
67
- if (areSomeNotWorklets && areSomeWorklets) {
68
- console.error(tagMessage(`Some of the callbacks in the gesture are worklets and some are not. Either make sure that all calbacks are marked as 'worklet' if you wish to run them on the UI thread or use '.runOnJS(true)' modifier on the gesture explicitly to run all callbacks on the JS thread.`));
69
- }
70
- if (Reanimated === undefined) {
71
- // If Reanimated is not available, we can't run worklets, so we shouldn't show the warning
72
- return;
73
- }
74
- const areAllNotWorklets = !areSomeWorklets && areSomeNotWorklets;
75
- // If none of the callbacks are worklets and the gesture is not explicitly marked with
76
- // `.runOnJS(true)` show a warning
77
- if (areAllNotWorklets && !isTestEnv()) {
78
- console.warn(tagMessage(`None of the callbacks in the gesture are worklets. If you wish to run them on the JS thread use '.runOnJS(true)' modifier on the gesture to make this explicit. Otherwise, mark the callbacks as 'worklet' to run them on the UI thread.`));
79
- }
80
- }
81
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
82
- export function validateDetectorChildren(ref) {
83
- // Finds the first native view under the Wrap component and traverses the fiber tree upwards
84
- // to check whether there is more than one native view as a pseudo-direct child of GestureDetector
85
- // i.e. this is not ok:
86
- // Wrap
87
- // |
88
- // / \
89
- // / \
90
- // / \
91
- // / \
92
- // NativeView NativeView
93
- //
94
- // but this is fine:
95
- // Wrap
96
- // |
97
- // NativeView
98
- // |
99
- // / \
100
- // / \
101
- // / \
102
- // / \
103
- // NativeView NativeView
104
- if (__DEV__ && Platform.OS !== 'web') {
105
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
106
- const wrapType =
107
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
108
- ref._reactInternals.elementType;
109
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
110
- let instance = RNRenderer.findHostInstance_DEPRECATED(ref)._internalFiberInstanceHandleDEV;
111
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
112
- while (instance && instance.elementType !== wrapType) {
113
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
114
- if (instance.sibling) {
115
- throw new Error('GestureDetector has more than one native view as its children. This can happen if you are using a custom component that renders multiple views, like React.Fragment. You should wrap content of GestureDetector with a <View> or <Animated.View>.');
116
- }
117
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
118
- instance = instance.return;
119
- }
120
- }
121
- }
122
- export function useForceRender() {
123
- const [renderState, setRenderState] = useState(false);
124
- const forceRender = useCallback(() => {
125
- setRenderState(!renderState);
126
- }, [renderState, setRenderState]);
127
- return forceRender;
128
- }
129
- export function useWebEventHandlers() {
130
- return useRef({
131
- onGestureHandlerEvent: (e) => {
132
- onGestureHandlerEvent(e.nativeEvent);
133
- },
134
- onGestureHandlerStateChange: isNewWebImplementationEnabled()
135
- ? (e) => {
136
- onGestureHandlerEvent(e.nativeEvent);
137
- }
138
- : undefined,
139
- });
140
- }
@@ -1,105 +0,0 @@
1
- import { DeviceEventEmitter } from 'react-native';
2
- import { State } from '../../State';
3
- import { TouchEventType } from '../../TouchEventType';
4
- import { findHandler, findOldGestureHandler } from '../handlersRegistry';
5
- import { GestureStateManager, } from './gestureStateManager';
6
- let gestureHandlerEventSubscription = null;
7
- let gestureHandlerStateChangeEventSubscription = null;
8
- const gestureStateManagers = new Map();
9
- const lastUpdateEvent = [];
10
- function isStateChangeEvent(event) {
11
- // @ts-ignore oldState doesn't exist on GestureTouchEvent and that's the point
12
- return event.oldState != null;
13
- }
14
- function isTouchEvent(event) {
15
- return event.eventType != null;
16
- }
17
- export function onGestureHandlerEvent(event) {
18
- const handler = findHandler(event.handlerTag);
19
- if (handler) {
20
- if (isStateChangeEvent(event)) {
21
- if (event.oldState === State.UNDETERMINED &&
22
- event.state === State.BEGAN) {
23
- handler.handlers.onBegin?.(event);
24
- }
25
- else if ((event.oldState === State.BEGAN ||
26
- event.oldState === State.UNDETERMINED) &&
27
- event.state === State.ACTIVE) {
28
- handler.handlers.onStart?.(event);
29
- lastUpdateEvent[handler.handlers.handlerTag] = event;
30
- }
31
- else if (event.oldState !== event.state && event.state === State.END) {
32
- if (event.oldState === State.ACTIVE) {
33
- handler.handlers.onEnd?.(event, true);
34
- }
35
- handler.handlers.onFinalize?.(event, true);
36
- lastUpdateEvent[handler.handlers.handlerTag] = undefined;
37
- }
38
- else if ((event.state === State.FAILED || event.state === State.CANCELLED) &&
39
- event.oldState !== event.state) {
40
- if (event.oldState === State.ACTIVE) {
41
- handler.handlers.onEnd?.(event, false);
42
- }
43
- handler.handlers.onFinalize?.(event, false);
44
- gestureStateManagers.delete(event.handlerTag);
45
- lastUpdateEvent[handler.handlers.handlerTag] = undefined;
46
- }
47
- }
48
- else if (isTouchEvent(event)) {
49
- if (!gestureStateManagers.has(event.handlerTag)) {
50
- gestureStateManagers.set(event.handlerTag, GestureStateManager.create(event.handlerTag));
51
- }
52
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
53
- const manager = gestureStateManagers.get(event.handlerTag);
54
- switch (event.eventType) {
55
- case TouchEventType.TOUCHES_DOWN:
56
- handler.handlers?.onTouchesDown?.(event, manager);
57
- break;
58
- case TouchEventType.TOUCHES_MOVE:
59
- handler.handlers?.onTouchesMove?.(event, manager);
60
- break;
61
- case TouchEventType.TOUCHES_UP:
62
- handler.handlers?.onTouchesUp?.(event, manager);
63
- break;
64
- case TouchEventType.TOUCHES_CANCELLED:
65
- handler.handlers?.onTouchesCancelled?.(event, manager);
66
- break;
67
- }
68
- }
69
- else {
70
- handler.handlers.onUpdate?.(event);
71
- if (handler.handlers.onChange && handler.handlers.changeEventCalculator) {
72
- handler.handlers.onChange?.(handler.handlers.changeEventCalculator?.(event, lastUpdateEvent[handler.handlers.handlerTag]));
73
- lastUpdateEvent[handler.handlers.handlerTag] = event;
74
- }
75
- }
76
- }
77
- else {
78
- const oldHandler = findOldGestureHandler(event.handlerTag);
79
- if (oldHandler) {
80
- const nativeEvent = { nativeEvent: event };
81
- if (isStateChangeEvent(event)) {
82
- oldHandler.onGestureStateChange(nativeEvent);
83
- }
84
- else {
85
- oldHandler.onGestureEvent(nativeEvent);
86
- }
87
- return;
88
- }
89
- }
90
- }
91
- export function startListening() {
92
- stopListening();
93
- gestureHandlerEventSubscription = DeviceEventEmitter.addListener('onGestureHandlerEvent', onGestureHandlerEvent);
94
- gestureHandlerStateChangeEventSubscription = DeviceEventEmitter.addListener('onGestureHandlerStateChange', onGestureHandlerEvent);
95
- }
96
- export function stopListening() {
97
- if (gestureHandlerEventSubscription) {
98
- gestureHandlerEventSubscription.remove();
99
- gestureHandlerEventSubscription = null;
100
- }
101
- if (gestureHandlerStateChangeEventSubscription) {
102
- gestureHandlerStateChangeEventSubscription.remove();
103
- gestureHandlerStateChangeEventSubscription = null;
104
- }
105
- }
@@ -1,27 +0,0 @@
1
- import { BaseGesture } from './gesture';
2
- export class FlingGesture extends BaseGesture {
3
- config = {};
4
- constructor() {
5
- super();
6
- this.handlerName = 'FlingGestureHandler';
7
- }
8
- /**
9
- * Determine exact number of points required to handle the fling gesture.
10
- * @param pointers
11
- */
12
- numberOfPointers(pointers) {
13
- this.config.numberOfPointers = pointers;
14
- return this;
15
- }
16
- /**
17
- * Expressed allowed direction of movement.
18
- * Expected values are exported as constants in the Directions object.
19
- * Arguments can be combined using `|` operator. Default value is set to `MouseButton.LEFT`.
20
- * @param direction
21
- * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/fling-gesture/#directionvalue-directions
22
- */
23
- direction(direction) {
24
- this.config.direction = direction;
25
- return this;
26
- }
27
- }
@@ -1,57 +0,0 @@
1
- import { ContinousBaseGesture } from './gesture';
2
- function changeEventCalculator(current, previous) {
3
- 'worklet';
4
- let changePayload;
5
- if (previous === undefined) {
6
- changePayload = {
7
- forceChange: current.force,
8
- };
9
- }
10
- else {
11
- changePayload = {
12
- forceChange: current.force - previous.force,
13
- };
14
- }
15
- return { ...current, ...changePayload };
16
- }
17
- /**
18
- * @deprecated ForceTouch gesture is deprecated and will be removed in the future.
19
- */
20
- export class ForceTouchGesture extends ContinousBaseGesture {
21
- config = {};
22
- constructor() {
23
- super();
24
- this.handlerName = 'ForceTouchGestureHandler';
25
- }
26
- /**
27
- * A minimal pressure that is required before gesture can activate.
28
- * Should be a value from range [0.0, 1.0]. Default is 0.2.
29
- * @param force
30
- */
31
- minForce(force) {
32
- this.config.minForce = force;
33
- return this;
34
- }
35
- /**
36
- * A maximal pressure that could be applied for gesture.
37
- * If the pressure is greater, gesture fails. Should be a value from range [0.0, 1.0].
38
- * @param force
39
- */
40
- maxForce(force) {
41
- this.config.maxForce = force;
42
- return this;
43
- }
44
- /**
45
- * Value defining if haptic feedback has to be performed on activation.
46
- * @param value
47
- */
48
- feedbackOnActivation(value) {
49
- this.config.feedbackOnActivation = value;
50
- return this;
51
- }
52
- onChange(callback) {
53
- // @ts-ignore TS being overprotective, ForceTouchGestureHandlerEventPayload is Record
54
- this.handlers.changeEventCalculator = changeEventCalculator;
55
- return super.onChange(callback);
56
- }
57
- }
@@ -1,303 +0,0 @@
1
- import { getNextHandlerTag } from '../getNextHandlerTag';
2
- import { isRemoteDebuggingEnabled } from '../../utils';
3
- export const CALLBACK_TYPE = {
4
- UNDEFINED: 0,
5
- BEGAN: 1,
6
- START: 2,
7
- UPDATE: 3,
8
- CHANGE: 4,
9
- END: 5,
10
- FINALIZE: 6,
11
- TOUCHES_DOWN: 7,
12
- TOUCHES_MOVE: 8,
13
- TOUCHES_UP: 9,
14
- TOUCHES_CANCELLED: 10,
15
- };
16
- export class Gesture {
17
- }
18
- let nextGestureId = 0;
19
- export class BaseGesture extends Gesture {
20
- gestureId = -1;
21
- handlerTag = -1;
22
- handlerName = '';
23
- config = {};
24
- handlers = {
25
- gestureId: -1,
26
- handlerTag: -1,
27
- isWorklet: [],
28
- };
29
- constructor() {
30
- super();
31
- // Used to check whether the gesture config has been updated when wrapping it
32
- // with `useMemo`. Since every config will have a unique id, when the dependencies
33
- // don't change, the config won't be recreated and the id will stay the same.
34
- // If the id is different, it means that the config has changed and the gesture
35
- // needs to be updated.
36
- this.gestureId = nextGestureId++;
37
- this.handlers.gestureId = this.gestureId;
38
- }
39
- addDependency(key, gesture) {
40
- const value = this.config[key];
41
- this.config[key] = value
42
- ? Array().concat(value, gesture)
43
- : [gesture];
44
- }
45
- /**
46
- * Sets a `ref` to the gesture object, allowing for interoperability with the old API.
47
- * @param ref
48
- */
49
- withRef(ref) {
50
- this.config.ref = ref;
51
- return this;
52
- }
53
- // eslint-disable-next-line @typescript-eslint/ban-types
54
- isWorklet(callback) {
55
- // @ts-ignore if callback is a worklet, the property will be available, if not then the check will return false
56
- return callback.__workletHash !== undefined;
57
- }
58
- /**
59
- * Set the callback that is being called when given gesture handler starts receiving touches.
60
- * At the moment of this callback the handler is in `BEGAN` state and we don't know yet if it will recognize the gesture at all.
61
- * @param callback
62
- */
63
- onBegin(callback) {
64
- this.handlers.onBegin = callback;
65
- this.handlers.isWorklet[CALLBACK_TYPE.BEGAN] = this.isWorklet(callback);
66
- return this;
67
- }
68
- /**
69
- * Set the callback that is being called when the gesture is recognized by the handler and it transitions to the `ACTIVE` state.
70
- * @param callback
71
- */
72
- onStart(callback) {
73
- this.handlers.onStart = callback;
74
- this.handlers.isWorklet[CALLBACK_TYPE.START] = this.isWorklet(callback);
75
- return this;
76
- }
77
- /**
78
- * Set the callback that is being called when the gesture that was recognized by the handler finishes and handler reaches `END` state.
79
- * It will be called only if the handler was previously in the `ACTIVE` state.
80
- * @param callback
81
- */
82
- onEnd(callback) {
83
- this.handlers.onEnd = callback;
84
- // @ts-ignore if callback is a worklet, the property will be available, if not then the check will return false
85
- this.handlers.isWorklet[CALLBACK_TYPE.END] = this.isWorklet(callback);
86
- return this;
87
- }
88
- /**
89
- * Set the callback that is being called when the handler finalizes handling gesture - the gesture was recognized and has finished or it failed to recognize.
90
- * @param callback
91
- */
92
- onFinalize(callback) {
93
- this.handlers.onFinalize = callback;
94
- // @ts-ignore if callback is a worklet, the property will be available, if not then the check will return false
95
- this.handlers.isWorklet[CALLBACK_TYPE.FINALIZE] = this.isWorklet(callback);
96
- return this;
97
- }
98
- /**
99
- * Set the `onTouchesDown` callback which is called every time a pointer is placed on the screen.
100
- * @param callback
101
- */
102
- onTouchesDown(callback) {
103
- this.config.needsPointerData = true;
104
- this.handlers.onTouchesDown = callback;
105
- this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_DOWN] =
106
- this.isWorklet(callback);
107
- return this;
108
- }
109
- /**
110
- * Set the `onTouchesMove` callback which is called every time a pointer is moved on the screen.
111
- * @param callback
112
- */
113
- onTouchesMove(callback) {
114
- this.config.needsPointerData = true;
115
- this.handlers.onTouchesMove = callback;
116
- this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_MOVE] =
117
- this.isWorklet(callback);
118
- return this;
119
- }
120
- /**
121
- * Set the `onTouchesUp` callback which is called every time a pointer is lifted from the screen.
122
- * @param callback
123
- */
124
- onTouchesUp(callback) {
125
- this.config.needsPointerData = true;
126
- this.handlers.onTouchesUp = callback;
127
- this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_UP] =
128
- this.isWorklet(callback);
129
- return this;
130
- }
131
- /**
132
- * Set the `onTouchesCancelled` callback which is called every time a pointer stops being tracked, for example when the gesture finishes.
133
- * @param callback
134
- */
135
- onTouchesCancelled(callback) {
136
- this.config.needsPointerData = true;
137
- this.handlers.onTouchesCancelled = callback;
138
- this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_CANCELLED] =
139
- this.isWorklet(callback);
140
- return this;
141
- }
142
- /**
143
- * Indicates whether the given handler should be analyzing stream of touch events or not.
144
- * @param enabled
145
- * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#enabledvalue-boolean
146
- */
147
- enabled(enabled) {
148
- this.config.enabled = enabled;
149
- return this;
150
- }
151
- /**
152
- * When true the handler will cancel or fail recognition (depending on its current state) whenever the finger leaves the area of the connected view.
153
- * @param value
154
- * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#shouldcancelwhenoutsidevalue-boolean
155
- */
156
- shouldCancelWhenOutside(value) {
157
- this.config.shouldCancelWhenOutside = value;
158
- return this;
159
- }
160
- /**
161
- * This parameter enables control over what part of the connected view area can be used to begin recognizing the gesture.
162
- * When a negative number is provided the bounds of the view will reduce the area by the given number of points in each of the sides evenly.
163
- * @param hitSlop
164
- * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#hitslopsettings
165
- */
166
- hitSlop(hitSlop) {
167
- this.config.hitSlop = hitSlop;
168
- return this;
169
- }
170
- /**
171
- * #### Web only
172
- * This parameter allows to specify which `cursor` should be used when gesture activates.
173
- * Supports all CSS cursor values (e.g. `"grab"`, `"zoom-in"`). Default value is set to `"auto"`.
174
- * @param activeCursor
175
- */
176
- activeCursor(activeCursor) {
177
- this.config.activeCursor = activeCursor;
178
- return this;
179
- }
180
- /**
181
- * #### Web & Android only
182
- * Allows users to choose which mouse button should handler respond to.
183
- * Arguments can be combined using `|` operator, e.g. `mouseButton(MouseButton.LEFT | MouseButton.RIGHT)`.
184
- * Default value is set to `MouseButton.LEFT`.
185
- * @param mouseButton
186
- * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#mousebuttonvalue-mousebutton-web--android-only
187
- */
188
- mouseButton(mouseButton) {
189
- this.config.mouseButton = mouseButton;
190
- return this;
191
- }
192
- /**
193
- * When `react-native-reanimated` is installed, the callbacks passed to the gestures are automatically workletized and run on the UI thread when called.
194
- * This option allows for changing this behavior: when `true`, all the callbacks will be run on the JS thread instead of the UI thread, regardless of whether they are worklets or not.
195
- * Defaults to `false`.
196
- * @param runOnJS
197
- */
198
- runOnJS(runOnJS) {
199
- this.config.runOnJS = runOnJS;
200
- return this;
201
- }
202
- /**
203
- * Allows gestures across different components to be recognized simultaneously.
204
- * @param gestures
205
- * @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#simultaneouswithexternalgesture
206
- */
207
- simultaneousWithExternalGesture(...gestures) {
208
- for (const gesture of gestures) {
209
- this.addDependency('simultaneousWith', gesture);
210
- }
211
- return this;
212
- }
213
- /**
214
- * Allows to delay activation of the handler until all handlers passed as arguments to this method fail (or don't begin at all).
215
- * @param gestures
216
- * @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#requireexternalgesturetofail
217
- */
218
- requireExternalGestureToFail(...gestures) {
219
- for (const gesture of gestures) {
220
- this.addDependency('requireToFail', gesture);
221
- }
222
- return this;
223
- }
224
- /**
225
- * Works similarily to `requireExternalGestureToFail` but the direction of the relation is reversed - instead of being one-to-many relation, it's many-to-one.
226
- * @param gestures
227
- * @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#blocksexternalgesture
228
- */
229
- blocksExternalGesture(...gestures) {
230
- for (const gesture of gestures) {
231
- this.addDependency('blocksHandlers', gesture);
232
- }
233
- return this;
234
- }
235
- /**
236
- * Sets a `testID` property for gesture object, allowing for querying for it in tests.
237
- * @param id
238
- */
239
- withTestId(id) {
240
- this.config.testId = id;
241
- return this;
242
- }
243
- /**
244
- * #### iOS only
245
- * When `true`, the handler will cancel touches for native UI components (`UIButton`, `UISwitch`, etc) it's attached to when it becomes `ACTIVE`.
246
- * Default value is `true`.
247
- * @param value
248
- */
249
- cancelsTouchesInView(value) {
250
- this.config.cancelsTouchesInView = value;
251
- return this;
252
- }
253
- initialize() {
254
- this.handlerTag = getNextHandlerTag();
255
- this.handlers = { ...this.handlers, handlerTag: this.handlerTag };
256
- if (this.config.ref) {
257
- this.config.ref.current = this;
258
- }
259
- }
260
- toGestureArray() {
261
- return [this];
262
- }
263
- // eslint-disable-next-line @typescript-eslint/no-empty-function
264
- prepare() { }
265
- get shouldUseReanimated() {
266
- // Use Reanimated when runOnJS isn't set explicitly,
267
- // all defined callbacks are worklets
268
- // and remote debugging is disabled
269
- return (this.config.runOnJS !== true &&
270
- !this.handlers.isWorklet.includes(false) &&
271
- !isRemoteDebuggingEnabled());
272
- }
273
- }
274
- export class ContinousBaseGesture extends BaseGesture {
275
- /**
276
- * Set the callback that is being called every time the gesture receives an update while it's active.
277
- * @param callback
278
- */
279
- onUpdate(callback) {
280
- this.handlers.onUpdate = callback;
281
- this.handlers.isWorklet[CALLBACK_TYPE.UPDATE] = this.isWorklet(callback);
282
- return this;
283
- }
284
- /**
285
- * Set the callback that is being called every time the gesture receives an update while it's active.
286
- * This callback will receive information about change in value in relation to the last received event.
287
- * @param callback
288
- */
289
- onChange(callback) {
290
- this.handlers.onChange = callback;
291
- this.handlers.isWorklet[CALLBACK_TYPE.CHANGE] = this.isWorklet(callback);
292
- return this;
293
- }
294
- /**
295
- * When `true` the handler will not activate by itself even if its activation criteria are met.
296
- * Instead you can manipulate its state using state manager.
297
- * @param manualActivation
298
- */
299
- manualActivation(manualActivation) {
300
- this.config.manualActivation = manualActivation;
301
- return this;
302
- }
303
- }