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,303 @@
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
+ }
@@ -19,4 +19,3 @@ export type ComposedGestureType = InstanceType<typeof ComposedGesture>;
19
19
  export type RaceGestureType = ComposedGestureType;
20
20
  export type SimultaneousGestureType = InstanceType<typeof SimultaneousGesture>;
21
21
  export type ExclusiveGestureType = InstanceType<typeof ExclusiveGesture>;
22
- //# sourceMappingURL=gestureComposition.d.ts.map
@@ -0,0 +1,78 @@
1
+ import { BaseGesture, Gesture } from './gesture';
2
+ function extendRelation(currentRelation, extendWith) {
3
+ if (currentRelation === undefined) {
4
+ return [...extendWith];
5
+ }
6
+ else {
7
+ return [...currentRelation, ...extendWith];
8
+ }
9
+ }
10
+ export class ComposedGesture extends Gesture {
11
+ gestures = [];
12
+ simultaneousGestures = [];
13
+ requireGesturesToFail = [];
14
+ constructor(...gestures) {
15
+ super();
16
+ this.gestures = gestures;
17
+ }
18
+ prepareSingleGesture(gesture, simultaneousGestures, requireGesturesToFail) {
19
+ if (gesture instanceof BaseGesture) {
20
+ const newConfig = { ...gesture.config };
21
+ // No need to extend `blocksHandlers` here, because it's not changed in composition.
22
+ // The same effect is achieved by reversing the order of 2 gestures in `Exclusive`
23
+ newConfig.simultaneousWith = extendRelation(newConfig.simultaneousWith, simultaneousGestures);
24
+ newConfig.requireToFail = extendRelation(newConfig.requireToFail, requireGesturesToFail);
25
+ gesture.config = newConfig;
26
+ }
27
+ else if (gesture instanceof ComposedGesture) {
28
+ gesture.simultaneousGestures = simultaneousGestures;
29
+ gesture.requireGesturesToFail = requireGesturesToFail;
30
+ gesture.prepare();
31
+ }
32
+ }
33
+ prepare() {
34
+ for (const gesture of this.gestures) {
35
+ this.prepareSingleGesture(gesture, this.simultaneousGestures, this.requireGesturesToFail);
36
+ }
37
+ }
38
+ initialize() {
39
+ for (const gesture of this.gestures) {
40
+ gesture.initialize();
41
+ }
42
+ }
43
+ toGestureArray() {
44
+ return this.gestures.flatMap((gesture) => gesture.toGestureArray());
45
+ }
46
+ }
47
+ export class SimultaneousGesture extends ComposedGesture {
48
+ prepare() {
49
+ // This piece of magic works something like this:
50
+ // for every gesture in the array
51
+ const simultaneousArrays = this.gestures.map((gesture) =>
52
+ // we take the array it's in
53
+ this.gestures
54
+ // and make a copy without it
55
+ .filter((x) => x !== gesture)
56
+ // then we flatmap the result to get list of raw (not composed) gestures
57
+ // this way we don't make the gestures simultaneous with themselves, which is
58
+ // important when the gesture is `ExclusiveGesture` - we don't want to make
59
+ // exclusive gestures simultaneous
60
+ .flatMap((x) => x.toGestureArray()));
61
+ for (let i = 0; i < this.gestures.length; i++) {
62
+ this.prepareSingleGesture(this.gestures[i], simultaneousArrays[i], this.requireGesturesToFail);
63
+ }
64
+ }
65
+ }
66
+ export class ExclusiveGesture extends ComposedGesture {
67
+ prepare() {
68
+ // Transforms the array of gestures into array of grouped raw (not composed) gestures
69
+ // i.e. [gesture1, gesture2, ComposedGesture(gesture3, gesture4)] -> [[gesture1], [gesture2], [gesture3, gesture4]]
70
+ const gestureArrays = this.gestures.map((gesture) => gesture.toGestureArray());
71
+ let requireToFail = [];
72
+ for (let i = 0; i < this.gestures.length; i++) {
73
+ this.prepareSingleGesture(this.gestures[i], this.simultaneousGestures, this.requireGesturesToFail.concat(requireToFail));
74
+ // Every group gets to wait for all groups before it
75
+ requireToFail = requireToFail.concat(gestureArrays[i]);
76
+ }
77
+ }
78
+ }
@@ -50,7 +50,9 @@ export declare const GestureObjects: {
50
50
  */
51
51
  LongPress: () => LongPressGesture;
52
52
  /**
53
- * #### iOS only
53
+ * @deprecated ForceTouch gesture is deprecated and will be removed in the future.
54
+ *
55
+ * #### iOS only
54
56
  * A continuous gesture that recognizes force of a touch. It allows for tracking pressure of touch on some iOS devices.
55
57
  * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/force-touch-gesture
56
58
  */
@@ -96,4 +98,3 @@ export declare const GestureObjects: {
96
98
  */
97
99
  Exclusive(...gestures: Gesture[]): ExclusiveGesture;
98
100
  };
99
- //# sourceMappingURL=gestureObjects.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gestureObjects.d.ts","sourceRoot":"","sources":["../../../../src/handlers/gestures/gestureObjects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc;IACzB;;;OAGG;;IAKH;;;OAGG;;IAKH;;;OAGG;;IAKH;;;OAGG;;IAKH;;;OAGG;;IAKH;;;OAGG;;IAKH;;;;OAIG;;IAKH;;;;OAIG;;IAKH;;;;;OAKG;;IAKH;;;;;OAKG;;IAKH;;;;OAIG;wBACiB,OAAO,EAAE;IAI7B;;;OAGG;8BACuB,OAAO,EAAE;IAInC;;;;;;;OAOG;2BACoB,OAAO,EAAE;CAGjC,CAAC"}
1
+ {"version":3,"file":"gestureObjects.d.ts","sourceRoot":"","sources":["../../../../src/handlers/gestures/gestureObjects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc;IACzB;;;OAGG;;IAKH;;;OAGG;;IAKH;;;OAGG;;IAKH;;;OAGG;;IAKH;;;OAGG;;IAKH;;;OAGG;;IAKH;;;;;;OAMG;;IAKH;;;;OAIG;;IAKH;;;;;OAKG;;IAKH;;;;;OAKG;;IAKH;;;;OAIG;wBACiB,OAAO,EAAE;IAI7B;;;OAGG;8BACuB,OAAO,EAAE;IAInC;;;;;;;OAOG;2BACoB,OAAO,EAAE;CAGjC,CAAC"}
@@ -0,0 +1,125 @@
1
+ import { FlingGesture } from './flingGesture';
2
+ import { ForceTouchGesture } from './forceTouchGesture';
3
+ import { ComposedGesture, ExclusiveGesture, SimultaneousGesture, } from './gestureComposition';
4
+ import { LongPressGesture } from './longPressGesture';
5
+ import { PanGesture } from './panGesture';
6
+ import { PinchGesture } from './pinchGesture';
7
+ import { RotationGesture } from './rotationGesture';
8
+ import { TapGesture } from './tapGesture';
9
+ import { NativeGesture } from './nativeGesture';
10
+ import { ManualGesture } from './manualGesture';
11
+ import { HoverGesture } from './hoverGesture';
12
+ /**
13
+ * `Gesture` is the object that allows you to create and compose gestures.
14
+ *
15
+ * ### Remarks
16
+ * - Consider wrapping your gesture configurations with `useMemo`, as it will reduce the amount of work Gesture Handler has to do under the hood when updating gestures.
17
+ *
18
+ * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/gesture
19
+ */
20
+ export const GestureObjects = {
21
+ /**
22
+ * A discrete gesture that recognizes one or many taps.
23
+ * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/tap-gesture
24
+ */
25
+ Tap: () => {
26
+ return new TapGesture();
27
+ },
28
+ /**
29
+ * A continuous gesture that can recognize a panning (dragging) gesture and track its movement.
30
+ * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture
31
+ */
32
+ Pan: () => {
33
+ return new PanGesture();
34
+ },
35
+ /**
36
+ * A continuous gesture that recognizes pinch gesture. It allows for tracking the distance between two fingers and use that information to scale or zoom your content.
37
+ * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pinch-gesture
38
+ */
39
+ Pinch: () => {
40
+ return new PinchGesture();
41
+ },
42
+ /**
43
+ * A continuous gesture that can recognize rotation and track its movement.
44
+ * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/rotation-gesture
45
+ */
46
+ Rotation: () => {
47
+ return new RotationGesture();
48
+ },
49
+ /**
50
+ * A discrete gesture that activates when the movement is sufficiently fast.
51
+ * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/fling-gesture
52
+ */
53
+ Fling: () => {
54
+ return new FlingGesture();
55
+ },
56
+ /**
57
+ * A discrete gesture that activates when the corresponding view is pressed for a sufficiently long time.
58
+ * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/long-press-gesture
59
+ */
60
+ LongPress: () => {
61
+ return new LongPressGesture();
62
+ },
63
+ /**
64
+ * @deprecated ForceTouch gesture is deprecated and will be removed in the future.
65
+ *
66
+ * #### iOS only
67
+ * A continuous gesture that recognizes force of a touch. It allows for tracking pressure of touch on some iOS devices.
68
+ * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/force-touch-gesture
69
+ */
70
+ ForceTouch: () => {
71
+ return new ForceTouchGesture();
72
+ },
73
+ /**
74
+ * A gesture that allows other touch handling components to participate in RNGH's gesture system.
75
+ * When used, the other component should be the direct child of a `GestureDetector`.
76
+ * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/native-gesture
77
+ */
78
+ Native: () => {
79
+ return new NativeGesture();
80
+ },
81
+ /**
82
+ * A plain gesture that has no specific activation criteria nor event data set.
83
+ * Its state has to be controlled manually using a state manager.
84
+ * It will not fail when all the pointers are lifted from the screen.
85
+ * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/manual-gesture
86
+ */
87
+ Manual: () => {
88
+ return new ManualGesture();
89
+ },
90
+ /**
91
+ * A continuous gesture that can recognize hovering above the view it's attached to.
92
+ * The hover effect may be activated by moving a mouse or a stylus over the view.
93
+ *
94
+ * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/hover-gesture
95
+ */
96
+ Hover: () => {
97
+ return new HoverGesture();
98
+ },
99
+ /**
100
+ * Builds a composed gesture consisting of gestures provided as parameters.
101
+ * The first one that becomes active cancels the rest of gestures.
102
+ * @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#race
103
+ */
104
+ Race: (...gestures) => {
105
+ return new ComposedGesture(...gestures);
106
+ },
107
+ /**
108
+ * Builds a composed gesture that allows all base gestures to run simultaneously.
109
+ * @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#simultaneous
110
+ */
111
+ Simultaneous(...gestures) {
112
+ return new SimultaneousGesture(...gestures);
113
+ },
114
+ /**
115
+ * Builds a composed gesture where only one of the provided gestures can become active.
116
+ * Priority is decided through the order of gestures: the first one has higher priority
117
+ * than the second one, second one has higher priority than the third one, and so on.
118
+ * For example, to make a gesture that recognizes both single and double tap you need
119
+ * to call Exclusive(doubleTap, singleTap).
120
+ * @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#exclusive
121
+ */
122
+ Exclusive(...gestures) {
123
+ return new ExclusiveGesture(...gestures);
124
+ },
125
+ };
@@ -9,4 +9,3 @@ export declare const GestureStateManager: {
9
9
  create: typeof create;
10
10
  };
11
11
  export {};
12
- //# sourceMappingURL=gestureStateManager.d.ts.map
@@ -0,0 +1,60 @@
1
+ import { Reanimated } from './reanimatedWrapper';
2
+ import { State } from '../../State';
3
+ import { tagMessage } from '../../utils';
4
+ const warningMessage = tagMessage('react-native-reanimated is required in order to use synchronous state management');
5
+ // Check if reanimated module is available, but look for useSharedValue as conditional
6
+ // require of reanimated can sometimes return content of `utils.ts` file (?)
7
+ const REANIMATED_AVAILABLE = Reanimated?.useSharedValue !== undefined;
8
+ const setGestureState = Reanimated?.setGestureState;
9
+ function create(handlerTag) {
10
+ 'worklet';
11
+ return {
12
+ begin: () => {
13
+ 'worklet';
14
+ if (REANIMATED_AVAILABLE) {
15
+ // When Reanimated is available, setGestureState should be defined
16
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
17
+ setGestureState(handlerTag, State.BEGAN);
18
+ }
19
+ else {
20
+ console.warn(warningMessage);
21
+ }
22
+ },
23
+ activate: () => {
24
+ 'worklet';
25
+ if (REANIMATED_AVAILABLE) {
26
+ // When Reanimated is available, setGestureState should be defined
27
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
28
+ setGestureState(handlerTag, State.ACTIVE);
29
+ }
30
+ else {
31
+ console.warn(warningMessage);
32
+ }
33
+ },
34
+ fail: () => {
35
+ 'worklet';
36
+ if (REANIMATED_AVAILABLE) {
37
+ // When Reanimated is available, setGestureState should be defined
38
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
39
+ setGestureState(handlerTag, State.FAILED);
40
+ }
41
+ else {
42
+ console.warn(warningMessage);
43
+ }
44
+ },
45
+ end: () => {
46
+ 'worklet';
47
+ if (REANIMATED_AVAILABLE) {
48
+ // When Reanimated is available, setGestureState should be defined
49
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
50
+ setGestureState(handlerTag, State.END);
51
+ }
52
+ else {
53
+ console.warn(warningMessage);
54
+ }
55
+ },
56
+ };
57
+ }
58
+ export const GestureStateManager = {
59
+ create,
60
+ };
@@ -2,4 +2,3 @@ import { GestureStateManagerType } from './gestureStateManager';
2
2
  export declare const GestureStateManager: {
3
3
  create(handlerTag: number): GestureStateManagerType;
4
4
  };
5
- //# sourceMappingURL=gestureStateManager.web.d.ts.map
@@ -0,0 +1,19 @@
1
+ import NodeManager from '../../web/tools/NodeManager';
2
+ export const GestureStateManager = {
3
+ create(handlerTag) {
4
+ return {
5
+ begin: () => {
6
+ NodeManager.getHandler(handlerTag).begin();
7
+ },
8
+ activate: () => {
9
+ NodeManager.getHandler(handlerTag).activate(true);
10
+ },
11
+ fail: () => {
12
+ NodeManager.getHandler(handlerTag).fail();
13
+ },
14
+ end: () => {
15
+ NodeManager.getHandler(handlerTag).end();
16
+ },
17
+ };
18
+ },
19
+ };
@@ -25,4 +25,3 @@ export declare class HoverGesture extends ContinousBaseGesture<HoverGestureHandl
25
25
  onChange(callback: (event: GestureUpdateEvent<HoverGestureHandlerEventPayload & HoverGestureChangeEventPayload>) => void): this;
26
26
  }
27
27
  export type HoverGestureType = InstanceType<typeof HoverGesture>;
28
- //# sourceMappingURL=hoverGesture.d.ts.map
@@ -0,0 +1,45 @@
1
+ import { ContinousBaseGesture } from './gesture';
2
+ export var HoverEffect;
3
+ (function (HoverEffect) {
4
+ HoverEffect[HoverEffect["NONE"] = 0] = "NONE";
5
+ HoverEffect[HoverEffect["LIFT"] = 1] = "LIFT";
6
+ HoverEffect[HoverEffect["HIGHLIGHT"] = 2] = "HIGHLIGHT";
7
+ })(HoverEffect || (HoverEffect = {}));
8
+ export const hoverGestureHandlerProps = ['hoverEffect'];
9
+ function changeEventCalculator(current, previous) {
10
+ 'worklet';
11
+ let changePayload;
12
+ if (previous === undefined) {
13
+ changePayload = {
14
+ changeX: current.x,
15
+ changeY: current.y,
16
+ };
17
+ }
18
+ else {
19
+ changePayload = {
20
+ changeX: current.x - previous.x,
21
+ changeY: current.y - previous.y,
22
+ };
23
+ }
24
+ return { ...current, ...changePayload };
25
+ }
26
+ export class HoverGesture extends ContinousBaseGesture {
27
+ config = {};
28
+ constructor() {
29
+ super();
30
+ this.handlerName = 'HoverGestureHandler';
31
+ }
32
+ /**
33
+ * #### iOS only
34
+ * Sets the visual hover effect.
35
+ */
36
+ effect(effect) {
37
+ this.config.hoverEffect = effect;
38
+ return this;
39
+ }
40
+ onChange(callback) {
41
+ // @ts-ignore TS being overprotective, HoverGestureHandlerEventPayload is Record
42
+ this.handlers.changeEventCalculator = changeEventCalculator;
43
+ return super.onChange(callback);
44
+ }
45
+ }