react-native-gesture-handler 2.27.1 → 2.27.2

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 (394) hide show
  1. package/ReanimatedSwipeable/package.json +4 -4
  2. package/android/build.gradle +8 -1
  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/apple/RNGestureHandler.h +4 -0
  6. package/apple/RNGestureHandler.mm +41 -6
  7. package/jestSetup.js +22 -3
  8. package/lib/commonjs/components/Pressable/Pressable.js +12 -21
  9. package/lib/commonjs/components/Pressable/Pressable.js.map +1 -1
  10. package/lib/commonjs/components/Pressable/StateMachine.js +8 -2
  11. package/lib/commonjs/components/Pressable/StateMachine.js.map +1 -1
  12. package/lib/commonjs/components/Pressable/stateDefinitions.js +22 -23
  13. package/lib/commonjs/components/Pressable/stateDefinitions.js.map +1 -1
  14. package/lib/commonjs/components/{ReanimatedSwipeable.js → ReanimatedSwipeable/ReanimatedSwipeable.js} +30 -39
  15. package/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeable.js.map +1 -0
  16. package/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeableProps.js +12 -0
  17. package/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeableProps.js.map +1 -0
  18. package/lib/commonjs/components/ReanimatedSwipeable/index.js +21 -0
  19. package/lib/commonjs/components/ReanimatedSwipeable/index.js.map +1 -0
  20. package/lib/commonjs/mocks/Pressable.js +13 -0
  21. package/lib/commonjs/mocks/Pressable.js.map +1 -0
  22. package/lib/commonjs/{mocks.js → mocks/mocks.js} +8 -11
  23. package/lib/commonjs/mocks/mocks.js.map +1 -0
  24. package/lib/commonjs/web/handlers/GestureHandler.js +1 -0
  25. package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
  26. package/lib/module/components/Pressable/Pressable.js +14 -23
  27. package/lib/module/components/Pressable/Pressable.js.map +1 -1
  28. package/lib/module/components/Pressable/StateMachine.js +8 -2
  29. package/lib/module/components/Pressable/StateMachine.js.map +1 -1
  30. package/lib/module/components/Pressable/stateDefinitions.js +21 -22
  31. package/lib/module/components/Pressable/stateDefinitions.js.map +1 -1
  32. package/lib/module/components/{ReanimatedSwipeable.js → ReanimatedSwipeable/ReanimatedSwipeable.js} +24 -33
  33. package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeable.js.map +1 -0
  34. package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeableProps.js +8 -0
  35. package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeableProps.js.map +1 -0
  36. package/lib/module/components/ReanimatedSwipeable/index.js +5 -0
  37. package/lib/module/components/ReanimatedSwipeable/index.js.map +1 -0
  38. package/lib/module/mocks/Pressable.js +4 -0
  39. package/lib/module/mocks/Pressable.js.map +1 -0
  40. package/lib/module/{mocks.js → mocks/mocks.js} +7 -11
  41. package/lib/module/mocks/mocks.js.map +1 -0
  42. package/lib/module/web/handlers/GestureHandler.js +1 -0
  43. package/lib/module/web/handlers/GestureHandler.js.map +1 -1
  44. package/lib/typescript/ActionType.d.ts +1 -0
  45. package/lib/typescript/Directions.d.ts +1 -0
  46. package/lib/typescript/EnableNewWebImplementation.d.ts +1 -0
  47. package/lib/typescript/GestureHandlerRootViewContext.d.ts +1 -0
  48. package/lib/typescript/PlatformConstants.d.ts +1 -0
  49. package/lib/typescript/PlatformConstants.web.d.ts +1 -0
  50. package/lib/typescript/PointerType.d.ts +1 -0
  51. package/lib/typescript/RNGestureHandlerModule.d.ts +1 -0
  52. package/lib/typescript/RNGestureHandlerModule.web.d.ts +1 -0
  53. package/lib/typescript/RNGestureHandlerModule.windows.d.ts +1 -0
  54. package/lib/typescript/RNRenderer.d.ts +1 -0
  55. package/lib/typescript/RNRenderer.web.d.ts +1 -0
  56. package/lib/typescript/State.d.ts +1 -0
  57. package/lib/typescript/TouchEventType.d.ts +1 -0
  58. package/lib/typescript/components/DrawerLayout.d.ts +1 -0
  59. package/lib/typescript/components/GestureButtons.d.ts +1 -0
  60. package/lib/typescript/components/GestureButtonsProps.d.ts +10 -1
  61. package/lib/typescript/components/GestureButtonsProps.d.ts.map +1 -1
  62. package/lib/typescript/components/GestureComponents.d.ts +1 -0
  63. package/lib/typescript/components/GestureComponents.web.d.ts +1 -0
  64. package/lib/typescript/components/GestureHandlerButton.d.ts +1 -0
  65. package/lib/typescript/components/GestureHandlerButton.web.d.ts +1 -0
  66. package/lib/typescript/components/GestureHandlerRootView.android.d.ts +1 -0
  67. package/lib/typescript/components/GestureHandlerRootView.d.ts +1 -0
  68. package/lib/typescript/components/GestureHandlerRootView.web.d.ts +1 -0
  69. package/lib/typescript/components/Pressable/Pressable.d.ts +1 -0
  70. package/lib/typescript/components/Pressable/Pressable.d.ts.map +1 -1
  71. package/lib/typescript/components/Pressable/PressableProps.d.ts +3 -4
  72. package/lib/typescript/components/Pressable/PressableProps.d.ts.map +1 -1
  73. package/lib/typescript/components/Pressable/StateMachine.d.ts +4 -2
  74. package/lib/typescript/components/Pressable/StateMachine.d.ts.map +1 -1
  75. package/lib/typescript/components/Pressable/index.d.ts +1 -0
  76. package/lib/typescript/components/Pressable/stateDefinitions.d.ts +3 -2
  77. package/lib/typescript/components/Pressable/stateDefinitions.d.ts.map +1 -1
  78. package/lib/typescript/components/Pressable/utils.d.ts +1 -0
  79. package/lib/typescript/components/ReanimatedDrawerLayout.d.ts +1 -0
  80. package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeable.d.ts +6 -0
  81. package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeable.d.ts.map +1 -0
  82. package/lib/typescript/components/{ReanimatedSwipeable.d.ts → ReanimatedSwipeable/ReanimatedSwipeableProps.d.ts} +10 -7
  83. package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeableProps.d.ts.map +1 -0
  84. package/lib/typescript/components/ReanimatedSwipeable/index.d.ts +3 -0
  85. package/lib/typescript/components/ReanimatedSwipeable/index.d.ts.map +1 -0
  86. package/lib/typescript/components/Swipeable.d.ts +1 -0
  87. package/lib/typescript/components/Text.d.ts +1 -0
  88. package/lib/typescript/components/gestureHandlerRootHOC.d.ts +1 -0
  89. package/lib/typescript/components/touchables/ExtraButtonProps.d.ts +1 -0
  90. package/lib/typescript/components/touchables/GenericTouchable.d.ts +1 -0
  91. package/lib/typescript/components/touchables/GenericTouchableProps.d.ts +1 -0
  92. package/lib/typescript/components/touchables/TouchableHighlight.d.ts +1 -0
  93. package/lib/typescript/components/touchables/TouchableNativeFeedback.android.d.ts +1 -0
  94. package/lib/typescript/components/touchables/TouchableNativeFeedback.d.ts +1 -0
  95. package/lib/typescript/components/touchables/TouchableNativeFeedbackProps.d.ts +1 -0
  96. package/lib/typescript/components/touchables/TouchableOpacity.d.ts +1 -0
  97. package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts +1 -0
  98. package/lib/typescript/components/touchables/index.d.ts +1 -0
  99. package/lib/typescript/components/utils.d.ts +1 -0
  100. package/lib/typescript/findNodeHandle.d.ts +1 -0
  101. package/lib/typescript/findNodeHandle.web.d.ts +1 -0
  102. package/lib/typescript/getShadowNodeFromRef.d.ts +1 -0
  103. package/lib/typescript/getShadowNodeFromRef.web.d.ts +1 -0
  104. package/lib/typescript/ghQueueMicrotask.d.ts +1 -0
  105. package/lib/typescript/handlers/FlingGestureHandler.d.ts +1 -0
  106. package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +1 -0
  107. package/lib/typescript/handlers/GestureHandlerEventPayload.d.ts +1 -0
  108. package/lib/typescript/handlers/LongPressGestureHandler.d.ts +1 -0
  109. package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +1 -0
  110. package/lib/typescript/handlers/PanGestureHandler.d.ts +1 -0
  111. package/lib/typescript/handlers/PinchGestureHandler.d.ts +1 -0
  112. package/lib/typescript/handlers/PressabilityDebugView.d.ts +1 -0
  113. package/lib/typescript/handlers/PressabilityDebugView.web.d.ts +1 -0
  114. package/lib/typescript/handlers/RotationGestureHandler.d.ts +1 -0
  115. package/lib/typescript/handlers/TapGestureHandler.d.ts +1 -0
  116. package/lib/typescript/handlers/createHandler.d.ts +1 -0
  117. package/lib/typescript/handlers/createNativeWrapper.d.ts +1 -0
  118. package/lib/typescript/handlers/customDirectEventTypes.d.ts +1 -0
  119. package/lib/typescript/handlers/customDirectEventTypes.web.d.ts +1 -0
  120. package/lib/typescript/handlers/gestureHandlerCommon.d.ts +1 -0
  121. package/lib/typescript/handlers/gestureHandlerTypesCompat.d.ts +1 -0
  122. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.d.ts +1 -0
  123. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.web.d.ts +1 -0
  124. package/lib/typescript/handlers/gestures/GestureDetector/attachHandlers.d.ts +1 -0
  125. package/lib/typescript/handlers/gestures/GestureDetector/dropHandlers.d.ts +1 -0
  126. package/lib/typescript/handlers/gestures/GestureDetector/index.d.ts +1 -0
  127. package/lib/typescript/handlers/gestures/GestureDetector/needsToReattach.d.ts +1 -0
  128. package/lib/typescript/handlers/gestures/GestureDetector/types.d.ts +1 -0
  129. package/lib/typescript/handlers/gestures/GestureDetector/updateHandlers.d.ts +1 -0
  130. package/lib/typescript/handlers/gestures/GestureDetector/useAnimatedGesture.d.ts +1 -0
  131. package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.d.ts +1 -0
  132. package/lib/typescript/handlers/gestures/GestureDetector/useMountReactions.d.ts +1 -0
  133. package/lib/typescript/handlers/gestures/GestureDetector/useViewRefHandler.d.ts +1 -0
  134. package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts +1 -0
  135. package/lib/typescript/handlers/gestures/eventReceiver.d.ts +1 -0
  136. package/lib/typescript/handlers/gestures/flingGesture.d.ts +1 -0
  137. package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +1 -0
  138. package/lib/typescript/handlers/gestures/gesture.d.ts +1 -0
  139. package/lib/typescript/handlers/gestures/gestureComposition.d.ts +1 -0
  140. package/lib/typescript/handlers/gestures/gestureObjects.d.ts +1 -0
  141. package/lib/typescript/handlers/gestures/gestureStateManager.d.ts +1 -0
  142. package/lib/typescript/handlers/gestures/gestureStateManager.web.d.ts +1 -0
  143. package/lib/typescript/handlers/gestures/hoverGesture.d.ts +1 -0
  144. package/lib/typescript/handlers/gestures/longPressGesture.d.ts +1 -0
  145. package/lib/typescript/handlers/gestures/manualGesture.d.ts +1 -0
  146. package/lib/typescript/handlers/gestures/nativeGesture.d.ts +1 -0
  147. package/lib/typescript/handlers/gestures/panGesture.d.ts +1 -0
  148. package/lib/typescript/handlers/gestures/pinchGesture.d.ts +1 -0
  149. package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts +1 -0
  150. package/lib/typescript/handlers/gestures/rotationGesture.d.ts +1 -0
  151. package/lib/typescript/handlers/gestures/tapGesture.d.ts +1 -0
  152. package/lib/typescript/handlers/getNextHandlerTag.d.ts +1 -0
  153. package/lib/typescript/handlers/handlersRegistry.d.ts +1 -0
  154. package/lib/typescript/handlers/utils.d.ts +1 -0
  155. package/lib/typescript/index.d.ts +1 -0
  156. package/lib/typescript/init.d.ts +1 -0
  157. package/lib/typescript/jestUtils/index.d.ts +1 -0
  158. package/lib/typescript/jestUtils/jestUtils.d.ts +1 -0
  159. package/lib/typescript/mocks/Pressable.d.ts +2 -0
  160. package/lib/typescript/mocks/Pressable.d.ts.map +1 -0
  161. package/lib/typescript/{mocks.d.ts → mocks/mocks.d.ts} +5 -4
  162. package/lib/typescript/mocks/mocks.d.ts.map +1 -0
  163. package/lib/typescript/mountRegistry.d.ts +1 -0
  164. package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts +1 -0
  165. package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts +1 -0
  166. package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.d.ts +1 -0
  167. package/lib/typescript/typeUtils.d.ts +1 -0
  168. package/lib/typescript/utils.d.ts +1 -0
  169. package/lib/typescript/web/Gestures.d.ts +1 -0
  170. package/lib/typescript/web/constants.d.ts +1 -0
  171. package/lib/typescript/web/detectors/RotationGestureDetector.d.ts +1 -0
  172. package/lib/typescript/web/detectors/ScaleGestureDetector.d.ts +1 -0
  173. package/lib/typescript/web/handlers/FlingGestureHandler.d.ts +1 -0
  174. package/lib/typescript/web/handlers/GestureHandler.d.ts +1 -0
  175. package/lib/typescript/web/handlers/GestureHandler.d.ts.map +1 -1
  176. package/lib/typescript/web/handlers/HoverGestureHandler.d.ts +1 -0
  177. package/lib/typescript/web/handlers/IGestureHandler.d.ts +1 -0
  178. package/lib/typescript/web/handlers/LongPressGestureHandler.d.ts +1 -0
  179. package/lib/typescript/web/handlers/ManualGestureHandler.d.ts +1 -0
  180. package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +1 -0
  181. package/lib/typescript/web/handlers/PanGestureHandler.d.ts +1 -0
  182. package/lib/typescript/web/handlers/PinchGestureHandler.d.ts +1 -0
  183. package/lib/typescript/web/handlers/RotationGestureHandler.d.ts +1 -0
  184. package/lib/typescript/web/handlers/TapGestureHandler.d.ts +1 -0
  185. package/lib/typescript/web/interfaces.d.ts +1 -0
  186. package/lib/typescript/web/tools/CircularBuffer.d.ts +1 -0
  187. package/lib/typescript/web/tools/EventManager.d.ts +1 -0
  188. package/lib/typescript/web/tools/GestureHandlerDelegate.d.ts +1 -0
  189. package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts +1 -0
  190. package/lib/typescript/web/tools/GestureHandlerWebDelegate.d.ts +1 -0
  191. package/lib/typescript/web/tools/InteractionManager.d.ts +1 -0
  192. package/lib/typescript/web/tools/KeyboardEventManager.d.ts +1 -0
  193. package/lib/typescript/web/tools/LeastSquareSolver.d.ts +1 -0
  194. package/lib/typescript/web/tools/NodeManager.d.ts +1 -0
  195. package/lib/typescript/web/tools/PointerEventManager.d.ts +1 -0
  196. package/lib/typescript/web/tools/PointerTracker.d.ts +1 -0
  197. package/lib/typescript/web/tools/Vector.d.ts +1 -0
  198. package/lib/typescript/web/tools/VelocityTracker.d.ts +1 -0
  199. package/lib/typescript/web/tools/WheelEventManager.d.ts +1 -0
  200. package/lib/typescript/web/utils.d.ts +1 -0
  201. package/lib/typescript/web_hammer/DiscreteGestureHandler.d.ts +1 -0
  202. package/lib/typescript/web_hammer/DraggingGestureHandler.d.ts +1 -0
  203. package/lib/typescript/web_hammer/Errors.d.ts +1 -0
  204. package/lib/typescript/web_hammer/FlingGestureHandler.d.ts +1 -0
  205. package/lib/typescript/web_hammer/GestureHandler.d.ts +1 -0
  206. package/lib/typescript/web_hammer/IndiscreteGestureHandler.d.ts +1 -0
  207. package/lib/typescript/web_hammer/LongPressGestureHandler.d.ts +1 -0
  208. package/lib/typescript/web_hammer/NativeViewGestureHandler.d.ts +1 -0
  209. package/lib/typescript/web_hammer/NodeManager.d.ts +1 -0
  210. package/lib/typescript/web_hammer/PanGestureHandler.d.ts +1 -0
  211. package/lib/typescript/web_hammer/PinchGestureHandler.d.ts +1 -0
  212. package/lib/typescript/web_hammer/PressGestureHandler.d.ts +1 -0
  213. package/lib/typescript/web_hammer/RotationGestureHandler.d.ts +1 -0
  214. package/lib/typescript/web_hammer/TapGestureHandler.d.ts +1 -0
  215. package/lib/typescript/web_hammer/constants.d.ts +1 -0
  216. package/lib/typescript/web_hammer/utils.d.ts +1 -0
  217. package/package.json +1 -1
  218. package/src/components/GestureButtonsProps.ts +10 -0
  219. package/src/components/Pressable/Pressable.tsx +20 -31
  220. package/src/components/Pressable/PressableProps.tsx +2 -4
  221. package/src/components/Pressable/StateMachine.tsx +12 -4
  222. package/src/components/Pressable/stateDefinitions.ts +23 -23
  223. package/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx +603 -0
  224. package/src/components/ReanimatedSwipeable/ReanimatedSwipeableProps.ts +199 -0
  225. package/src/components/ReanimatedSwipeable/index.ts +6 -0
  226. package/src/mocks/Pressable.tsx +1 -0
  227. package/src/{mocks.tsx → mocks/mocks.tsx} +7 -11
  228. package/src/web/handlers/GestureHandler.ts +1 -0
  229. package/lib/commonjs/components/ReanimatedSwipeable.js.map +0 -1
  230. package/lib/commonjs/mocks.js.map +0 -1
  231. package/lib/module/components/ReanimatedSwipeable.js.map +0 -1
  232. package/lib/module/mocks.js.map +0 -1
  233. package/lib/typescript/ActionType.js +0 -6
  234. package/lib/typescript/Directions.js +0 -18
  235. package/lib/typescript/EnableNewWebImplementation.js +0 -30
  236. package/lib/typescript/GestureHandlerRootViewContext.js +0 -2
  237. package/lib/typescript/PlatformConstants.js +0 -3
  238. package/lib/typescript/PlatformConstants.web.js +0 -5
  239. package/lib/typescript/PointerType.js +0 -8
  240. package/lib/typescript/RNGestureHandlerModule.js +0 -4
  241. package/lib/typescript/RNGestureHandlerModule.web.js +0 -92
  242. package/lib/typescript/RNGestureHandlerModule.windows.js +0 -47
  243. package/lib/typescript/RNRenderer.js +0 -3
  244. package/lib/typescript/RNRenderer.web.js +0 -3
  245. package/lib/typescript/State.js +0 -9
  246. package/lib/typescript/TouchEventType.js +0 -7
  247. package/lib/typescript/components/DrawerLayout.js +0 -417
  248. package/lib/typescript/components/GestureButtons.js +0 -165
  249. package/lib/typescript/components/GestureButtonsProps.js +0 -1
  250. package/lib/typescript/components/GestureComponents.js +0 -67
  251. package/lib/typescript/components/GestureComponents.web.js +0 -21
  252. package/lib/typescript/components/GestureHandlerButton.js +0 -2
  253. package/lib/typescript/components/GestureHandlerButton.web.js +0 -3
  254. package/lib/typescript/components/GestureHandlerRootView.android.js +0 -17
  255. package/lib/typescript/components/GestureHandlerRootView.js +0 -16
  256. package/lib/typescript/components/GestureHandlerRootView.web.js +0 -11
  257. package/lib/typescript/components/Pressable/Pressable.js +0 -231
  258. package/lib/typescript/components/Pressable/PressableProps.js +0 -1
  259. package/lib/typescript/components/Pressable/StateMachine.js +0 -34
  260. package/lib/typescript/components/Pressable/index.js +0 -1
  261. package/lib/typescript/components/Pressable/stateDefinitions.js +0 -104
  262. package/lib/typescript/components/Pressable/utils.js +0 -80
  263. package/lib/typescript/components/ReanimatedDrawerLayout.js +0 -364
  264. package/lib/typescript/components/ReanimatedSwipeable.d.ts.map +0 -1
  265. package/lib/typescript/components/ReanimatedSwipeable.js +0 -400
  266. package/lib/typescript/components/Swipeable.js +0 -287
  267. package/lib/typescript/components/Text.js +0 -38
  268. package/lib/typescript/components/gestureHandlerRootHOC.js +0 -18
  269. package/lib/typescript/components/touchables/ExtraButtonProps.js +0 -1
  270. package/lib/typescript/components/touchables/GenericTouchable.js +0 -221
  271. package/lib/typescript/components/touchables/GenericTouchableProps.js +0 -1
  272. package/lib/typescript/components/touchables/TouchableHighlight.js +0 -75
  273. package/lib/typescript/components/touchables/TouchableNativeFeedback.android.js +0 -65
  274. package/lib/typescript/components/touchables/TouchableNativeFeedback.js +0 -6
  275. package/lib/typescript/components/touchables/TouchableNativeFeedbackProps.js +0 -1
  276. package/lib/typescript/components/touchables/TouchableOpacity.js +0 -51
  277. package/lib/typescript/components/touchables/TouchableWithoutFeedback.js +0 -10
  278. package/lib/typescript/components/touchables/index.js +0 -4
  279. package/lib/typescript/components/utils.js +0 -11
  280. package/lib/typescript/findNodeHandle.js +0 -2
  281. package/lib/typescript/findNodeHandle.web.js +0 -31
  282. package/lib/typescript/getShadowNodeFromRef.js +0 -45
  283. package/lib/typescript/getShadowNodeFromRef.web.js +0 -7
  284. package/lib/typescript/ghQueueMicrotask.js +0 -7
  285. package/lib/typescript/handlers/FlingGestureHandler.js +0 -19
  286. package/lib/typescript/handlers/ForceTouchGestureHandler.js +0 -37
  287. package/lib/typescript/handlers/GestureHandlerEventPayload.js +0 -1
  288. package/lib/typescript/handlers/LongPressGestureHandler.js +0 -22
  289. package/lib/typescript/handlers/NativeViewGestureHandler.js +0 -20
  290. package/lib/typescript/handlers/PanGestureHandler.js +0 -128
  291. package/lib/typescript/handlers/PinchGestureHandler.js +0 -12
  292. package/lib/typescript/handlers/PressabilityDebugView.js +0 -2
  293. package/lib/typescript/handlers/PressabilityDebugView.web.js +0 -4
  294. package/lib/typescript/handlers/RotationGestureHandler.js +0 -12
  295. package/lib/typescript/handlers/TapGestureHandler.js +0 -26
  296. package/lib/typescript/handlers/createHandler.js +0 -375
  297. package/lib/typescript/handlers/createNativeWrapper.js +0 -67
  298. package/lib/typescript/handlers/customDirectEventTypes.js +0 -2
  299. package/lib/typescript/handlers/customDirectEventTypes.web.js +0 -4
  300. package/lib/typescript/handlers/gestureHandlerCommon.js +0 -42
  301. package/lib/typescript/handlers/gestureHandlerTypesCompat.js +0 -1
  302. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.js +0 -22
  303. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.web.js +0 -24
  304. package/lib/typescript/handlers/gestures/GestureDetector/attachHandlers.js +0 -55
  305. package/lib/typescript/handlers/gestures/GestureDetector/dropHandlers.js +0 -12
  306. package/lib/typescript/handlers/gestures/GestureDetector/index.js +0 -114
  307. package/lib/typescript/handlers/gestures/GestureDetector/needsToReattach.js +0 -18
  308. package/lib/typescript/handlers/gestures/GestureDetector/types.js +0 -1
  309. package/lib/typescript/handlers/gestures/GestureDetector/updateHandlers.js +0 -54
  310. package/lib/typescript/handlers/gestures/GestureDetector/useAnimatedGesture.js +0 -137
  311. package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.js +0 -48
  312. package/lib/typescript/handlers/gestures/GestureDetector/useMountReactions.js +0 -35
  313. package/lib/typescript/handlers/gestures/GestureDetector/useViewRefHandler.js +0 -32
  314. package/lib/typescript/handlers/gestures/GestureDetector/utils.js +0 -140
  315. package/lib/typescript/handlers/gestures/eventReceiver.js +0 -105
  316. package/lib/typescript/handlers/gestures/flingGesture.js +0 -27
  317. package/lib/typescript/handlers/gestures/forceTouchGesture.js +0 -57
  318. package/lib/typescript/handlers/gestures/gesture.js +0 -303
  319. package/lib/typescript/handlers/gestures/gestureComposition.js +0 -78
  320. package/lib/typescript/handlers/gestures/gestureObjects.js +0 -125
  321. package/lib/typescript/handlers/gestures/gestureStateManager.js +0 -60
  322. package/lib/typescript/handlers/gestures/gestureStateManager.web.js +0 -19
  323. package/lib/typescript/handlers/gestures/hoverGesture.js +0 -45
  324. package/lib/typescript/handlers/gestures/longPressGesture.js +0 -35
  325. package/lib/typescript/handlers/gestures/manualGesture.js +0 -16
  326. package/lib/typescript/handlers/gestures/nativeGesture.js +0 -24
  327. package/lib/typescript/handlers/gestures/panGesture.js +0 -181
  328. package/lib/typescript/handlers/gestures/pinchGesture.js +0 -27
  329. package/lib/typescript/handlers/gestures/reanimatedWrapper.js +0 -23
  330. package/lib/typescript/handlers/gestures/rotationGesture.js +0 -27
  331. package/lib/typescript/handlers/gestures/tapGesture.js +0 -72
  332. package/lib/typescript/handlers/getNextHandlerTag.js +0 -4
  333. package/lib/typescript/handlers/handlersRegistry.js +0 -36
  334. package/lib/typescript/handlers/utils.js +0 -58
  335. package/lib/typescript/index.js +0 -28
  336. package/lib/typescript/init.js +0 -15
  337. package/lib/typescript/jestUtils/index.js +0 -1
  338. package/lib/typescript/jestUtils/jestUtils.js +0 -290
  339. package/lib/typescript/mocks.d.ts.map +0 -1
  340. package/lib/typescript/mocks.js +0 -59
  341. package/lib/typescript/mountRegistry.js +0 -29
  342. package/lib/typescript/specs/NativeRNGestureHandlerModule.js +0 -2
  343. package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.js +0 -2
  344. package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.js +0 -2
  345. package/lib/typescript/typeUtils.js +0 -1
  346. package/lib/typescript/utils.js +0 -80
  347. package/lib/typescript/web/Gestures.js +0 -38
  348. package/lib/typescript/web/constants.js +0 -2
  349. package/lib/typescript/web/detectors/RotationGestureDetector.js +0 -122
  350. package/lib/typescript/web/detectors/ScaleGestureDetector.js +0 -117
  351. package/lib/typescript/web/handlers/FlingGestureHandler.js +0 -133
  352. package/lib/typescript/web/handlers/GestureHandler.js +0 -656
  353. package/lib/typescript/web/handlers/HoverGestureHandler.js +0 -37
  354. package/lib/typescript/web/handlers/IGestureHandler.js +0 -1
  355. package/lib/typescript/web/handlers/LongPressGestureHandler.js +0 -136
  356. package/lib/typescript/web/handlers/ManualGestureHandler.js +0 -29
  357. package/lib/typescript/web/handlers/NativeViewGestureHandler.js +0 -133
  358. package/lib/typescript/web/handlers/PanGestureHandler.js +0 -420
  359. package/lib/typescript/web/handlers/PinchGestureHandler.js +0 -117
  360. package/lib/typescript/web/handlers/RotationGestureHandler.js +0 -122
  361. package/lib/typescript/web/handlers/TapGestureHandler.js +0 -202
  362. package/lib/typescript/web/interfaces.js +0 -25
  363. package/lib/typescript/web/tools/CircularBuffer.js +0 -37
  364. package/lib/typescript/web/tools/EventManager.js +0 -85
  365. package/lib/typescript/web/tools/GestureHandlerDelegate.js +0 -1
  366. package/lib/typescript/web/tools/GestureHandlerOrchestrator.js +0 -273
  367. package/lib/typescript/web/tools/GestureHandlerWebDelegate.js +0 -169
  368. package/lib/typescript/web/tools/InteractionManager.js +0 -91
  369. package/lib/typescript/web/tools/KeyboardEventManager.js +0 -73
  370. package/lib/typescript/web/tools/LeastSquareSolver.js +0 -147
  371. package/lib/typescript/web/tools/NodeManager.js +0 -28
  372. package/lib/typescript/web/tools/PointerEventManager.js +0 -179
  373. package/lib/typescript/web/tools/PointerTracker.js +0 -161
  374. package/lib/typescript/web/tools/Vector.js +0 -43
  375. package/lib/typescript/web/tools/VelocityTracker.js +0 -76
  376. package/lib/typescript/web/tools/WheelEventManager.js +0 -40
  377. package/lib/typescript/web/utils.js +0 -233
  378. package/lib/typescript/web_hammer/DiscreteGestureHandler.js +0 -48
  379. package/lib/typescript/web_hammer/DraggingGestureHandler.js +0 -25
  380. package/lib/typescript/web_hammer/Errors.js +0 -5
  381. package/lib/typescript/web_hammer/FlingGestureHandler.js +0 -119
  382. package/lib/typescript/web_hammer/GestureHandler.js +0 -469
  383. package/lib/typescript/web_hammer/IndiscreteGestureHandler.js +0 -26
  384. package/lib/typescript/web_hammer/LongPressGestureHandler.js +0 -46
  385. package/lib/typescript/web_hammer/NativeViewGestureHandler.js +0 -40
  386. package/lib/typescript/web_hammer/NodeManager.js +0 -28
  387. package/lib/typescript/web_hammer/PanGestureHandler.js +0 -151
  388. package/lib/typescript/web_hammer/PinchGestureHandler.js +0 -19
  389. package/lib/typescript/web_hammer/PressGestureHandler.js +0 -133
  390. package/lib/typescript/web_hammer/RotationGestureHandler.js +0 -20
  391. package/lib/typescript/web_hammer/TapGestureHandler.js +0 -142
  392. package/lib/typescript/web_hammer/constants.js +0 -42
  393. package/lib/typescript/web_hammer/utils.js +0 -15
  394. package/src/components/ReanimatedSwipeable.tsx +0 -811
@@ -1,40 +0,0 @@
1
- import DiscreteGestureHandler from './DiscreteGestureHandler';
2
- import * as NodeManager from './NodeManager';
3
- import PressGestureHandler from './PressGestureHandler';
4
- import { TEST_MIN_IF_NOT_NAN, VEC_LEN_SQ } from './utils';
5
- class NativeViewGestureHandler extends PressGestureHandler {
6
- get isNative() {
7
- return true;
8
- }
9
- onRawEvent(ev) {
10
- super.onRawEvent(ev);
11
- if (!ev.isFinal) {
12
- // if (this.ref instanceof ScrollView) {
13
- if (TEST_MIN_IF_NOT_NAN(VEC_LEN_SQ({ x: ev.deltaX, y: ev.deltaY }), 10)) {
14
- // @ts-ignore FIXME(TS) config type
15
- if (this.config.disallowInterruption) {
16
- const gestures = Object.values(NodeManager.getNodes()).filter((gesture) => {
17
- const { handlerTag, view, isGestureRunning } = gesture;
18
- return (
19
- // Check if this gesture isn't self
20
- handlerTag !== this.handlerTag &&
21
- // Ensure the gesture needs to be cancelled
22
- isGestureRunning &&
23
- // ScrollView can cancel discrete gestures like taps and presses
24
- gesture instanceof DiscreteGestureHandler &&
25
- // Ensure a view exists and is a child of the current view
26
- view &&
27
- // @ts-ignore FIXME(TS) view type
28
- this.view.contains(view));
29
- });
30
- // Cancel all of the gestures that passed the filter
31
- for (const gesture of gestures) {
32
- // TODO: Bacon: Send some cached event.
33
- gesture.forceInvalidate(ev);
34
- }
35
- }
36
- }
37
- }
38
- }
39
- }
40
- export default NativeViewGestureHandler;
@@ -1,28 +0,0 @@
1
- export const gestures = {};
2
- export function getHandler(tag) {
3
- if (tag in gestures) {
4
- return gestures[tag];
5
- }
6
- throw new Error(`No handler for tag ${tag}`);
7
- }
8
- export function createGestureHandler(handlerTag, handler) {
9
- if (handlerTag in gestures) {
10
- throw new Error(`Handler with tag ${handlerTag} already exists`);
11
- }
12
- gestures[handlerTag] = handler;
13
- // @ts-ignore no types for web handlers yet
14
- gestures[handlerTag].handlerTag = handlerTag;
15
- }
16
- export function dropGestureHandler(handlerTag) {
17
- // Since React 18, there are cases where componentWillUnmount gets called twice in a row
18
- // so skip this if the tag was already removed.
19
- if (!(handlerTag in gestures)) {
20
- return;
21
- }
22
- getHandler(handlerTag).destroy();
23
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
24
- delete gestures[handlerTag];
25
- }
26
- export function getNodes() {
27
- return { ...gestures };
28
- }
@@ -1,151 +0,0 @@
1
- import Hammer from '@egjs/hammerjs';
2
- import { MULTI_FINGER_PAN_MAX_PINCH_THRESHOLD, MULTI_FINGER_PAN_MAX_ROTATION_THRESHOLD, } from './constants';
3
- import DraggingGestureHandler from './DraggingGestureHandler';
4
- import { isValidNumber, isnan, TEST_MIN_IF_NOT_NAN, VEC_LEN_SQ } from './utils';
5
- import { State } from '../State';
6
- class PanGestureHandler extends DraggingGestureHandler {
7
- get name() {
8
- return 'pan';
9
- }
10
- get NativeGestureClass() {
11
- return Hammer.Pan;
12
- }
13
- getHammerConfig() {
14
- return {
15
- ...super.getHammerConfig(),
16
- direction: this.getDirection(),
17
- };
18
- }
19
- getState(type) {
20
- const nextState = super.getState(type);
21
- // Ensure that the first state sent is `BEGAN` and not `ACTIVE`
22
- if (this.previousState === State.UNDETERMINED &&
23
- nextState === State.ACTIVE) {
24
- return State.BEGAN;
25
- }
26
- return nextState;
27
- }
28
- getDirection() {
29
- const config = this.getConfig();
30
- const { activeOffsetXStart, activeOffsetXEnd, activeOffsetYStart, activeOffsetYEnd, minDist, } = config;
31
- let directions = [];
32
- let horizontalDirections = [];
33
- if (!isnan(minDist)) {
34
- return Hammer.DIRECTION_ALL;
35
- }
36
- if (!isnan(activeOffsetXStart)) {
37
- horizontalDirections.push(Hammer.DIRECTION_LEFT);
38
- }
39
- if (!isnan(activeOffsetXEnd)) {
40
- horizontalDirections.push(Hammer.DIRECTION_RIGHT);
41
- }
42
- if (horizontalDirections.length === 2) {
43
- horizontalDirections = [Hammer.DIRECTION_HORIZONTAL];
44
- }
45
- directions = directions.concat(horizontalDirections);
46
- let verticalDirections = [];
47
- if (!isnan(activeOffsetYStart)) {
48
- verticalDirections.push(Hammer.DIRECTION_UP);
49
- }
50
- if (!isnan(activeOffsetYEnd)) {
51
- verticalDirections.push(Hammer.DIRECTION_DOWN);
52
- }
53
- if (verticalDirections.length === 2) {
54
- verticalDirections = [Hammer.DIRECTION_VERTICAL];
55
- }
56
- directions = directions.concat(verticalDirections);
57
- if (!directions.length) {
58
- return Hammer.DIRECTION_NONE;
59
- }
60
- if (directions[0] === Hammer.DIRECTION_HORIZONTAL &&
61
- directions[1] === Hammer.DIRECTION_VERTICAL) {
62
- return Hammer.DIRECTION_ALL;
63
- }
64
- if (horizontalDirections.length && verticalDirections.length) {
65
- return Hammer.DIRECTION_ALL;
66
- }
67
- return directions[0];
68
- }
69
- getConfig() {
70
- if (!this.hasCustomActivationCriteria) {
71
- // Default config
72
- // If no params have been defined then this config should emulate the native gesture as closely as possible.
73
- return {
74
- minDistSq: 10,
75
- };
76
- }
77
- return this.config;
78
- }
79
- shouldFailUnderCustomCriteria({ deltaX, deltaY }, criteria) {
80
- return ((!isnan(criteria.failOffsetXStart) &&
81
- deltaX < criteria.failOffsetXStart) ||
82
- (!isnan(criteria.failOffsetXEnd) && deltaX > criteria.failOffsetXEnd) ||
83
- (!isnan(criteria.failOffsetYStart) &&
84
- deltaY < criteria.failOffsetYStart) ||
85
- (!isnan(criteria.failOffsetYEnd) && deltaY > criteria.failOffsetYEnd));
86
- }
87
- shouldActivateUnderCustomCriteria({ deltaX, deltaY, velocity }, criteria) {
88
- return ((!isnan(criteria.activeOffsetXStart) &&
89
- deltaX < criteria.activeOffsetXStart) ||
90
- (!isnan(criteria.activeOffsetXEnd) &&
91
- deltaX > criteria.activeOffsetXEnd) ||
92
- (!isnan(criteria.activeOffsetYStart) &&
93
- deltaY < criteria.activeOffsetYStart) ||
94
- (!isnan(criteria.activeOffsetYEnd) &&
95
- deltaY > criteria.activeOffsetYEnd) ||
96
- TEST_MIN_IF_NOT_NAN(VEC_LEN_SQ({ x: deltaX, y: deltaY }), criteria.minDistSq) ||
97
- TEST_MIN_IF_NOT_NAN(velocity.x, criteria.minVelocityX) ||
98
- TEST_MIN_IF_NOT_NAN(velocity.y, criteria.minVelocityY) ||
99
- TEST_MIN_IF_NOT_NAN(VEC_LEN_SQ(velocity), criteria.minVelocitySq));
100
- }
101
- shouldMultiFingerPanFail({ pointerLength, scale, deltaRotation, }) {
102
- if (pointerLength <= 1) {
103
- return false;
104
- }
105
- // Test if the pan had too much pinching or rotating.
106
- const deltaScale = Math.abs(scale - 1);
107
- const absDeltaRotation = Math.abs(deltaRotation);
108
- if (deltaScale > MULTI_FINGER_PAN_MAX_PINCH_THRESHOLD) {
109
- // > If the threshold doesn't seem right.
110
- // You can log the value which it failed at here:
111
- return true;
112
- }
113
- if (absDeltaRotation > MULTI_FINGER_PAN_MAX_ROTATION_THRESHOLD) {
114
- // > If the threshold doesn't seem right.
115
- // You can log the value which it failed at here:
116
- return true;
117
- }
118
- return false;
119
- }
120
- updateHasCustomActivationCriteria(criteria) {
121
- return (isValidNumber(criteria.minDistSq) ||
122
- isValidNumber(criteria.minVelocityX) ||
123
- isValidNumber(criteria.minVelocityY) ||
124
- isValidNumber(criteria.minVelocitySq) ||
125
- isValidNumber(criteria.activeOffsetXStart) ||
126
- isValidNumber(criteria.activeOffsetXEnd) ||
127
- isValidNumber(criteria.activeOffsetYStart) ||
128
- isValidNumber(criteria.activeOffsetYEnd));
129
- }
130
- isGestureEnabledForEvent(props, _recognizer, inputData) {
131
- if (this.shouldFailUnderCustomCriteria(inputData, props)) {
132
- return { failed: true };
133
- }
134
- const velocity = { x: inputData.velocityX, y: inputData.velocityY };
135
- if (this.hasCustomActivationCriteria &&
136
- this.shouldActivateUnderCustomCriteria({ deltaX: inputData.deltaX, deltaY: inputData.deltaY, velocity }, props)) {
137
- if (this.shouldMultiFingerPanFail({
138
- pointerLength: inputData.maxPointers,
139
- scale: inputData.scale,
140
- deltaRotation: inputData.deltaRotation,
141
- })) {
142
- return {
143
- failed: true,
144
- };
145
- }
146
- return { success: true };
147
- }
148
- return { success: false };
149
- }
150
- }
151
- export default PanGestureHandler;
@@ -1,19 +0,0 @@
1
- import Hammer from '@egjs/hammerjs';
2
- import IndiscreteGestureHandler from './IndiscreteGestureHandler';
3
- class PinchGestureHandler extends IndiscreteGestureHandler {
4
- get name() {
5
- return 'pinch';
6
- }
7
- get NativeGestureClass() {
8
- return Hammer.Pinch;
9
- }
10
- transformNativeEvent({ scale, velocity, center }) {
11
- return {
12
- focalX: center.x,
13
- focalY: center.y,
14
- velocity,
15
- scale,
16
- };
17
- }
18
- }
19
- export default PinchGestureHandler;
@@ -1,133 +0,0 @@
1
- import Hammer from '@egjs/hammerjs';
2
- import { State } from '../State';
3
- import { CONTENT_TOUCHES_DELAY, CONTENT_TOUCHES_QUICK_TAP_END_DELAY, } from './constants';
4
- import DiscreteGestureHandler from './DiscreteGestureHandler';
5
- import { fireAfterInterval, isValidNumber, isnan } from './utils';
6
- class PressGestureHandler extends DiscreteGestureHandler {
7
- visualFeedbackTimer;
8
- initialEvent = null;
9
- get name() {
10
- return 'press';
11
- }
12
- get minDurationMs() {
13
- // @ts-ignore FIXME(TS)
14
- return isnan(this.config.minDurationMs) ? 5 : this.config.minDurationMs;
15
- }
16
- get maxDist() {
17
- return isnan(this.config.maxDist) ? 9 : this.config.maxDist;
18
- }
19
- get NativeGestureClass() {
20
- return Hammer.Press;
21
- }
22
- shouldDelayTouches = true;
23
- simulateCancelEvent(inputData) {
24
- // Long press never starts so we can't rely on the running event boolean.
25
- this.hasGestureFailed = true;
26
- this.cancelEvent(inputData);
27
- }
28
- updateHasCustomActivationCriteria({ shouldCancelWhenOutside, maxDistSq, }) {
29
- return shouldCancelWhenOutside || !isValidNumber(maxDistSq);
30
- }
31
- getState(type) {
32
- return {
33
- [Hammer.INPUT_START]: State.BEGAN,
34
- [Hammer.INPUT_MOVE]: State.ACTIVE,
35
- [Hammer.INPUT_END]: State.END,
36
- [Hammer.INPUT_CANCEL]: State.CANCELLED,
37
- }[type];
38
- }
39
- getConfig() {
40
- if (!this.hasCustomActivationCriteria) {
41
- // Default config
42
- // If no params have been defined then this config should emulate the native gesture as closely as possible.
43
- return {
44
- shouldCancelWhenOutside: true,
45
- maxDistSq: 10,
46
- };
47
- }
48
- return this.config;
49
- }
50
- getHammerConfig() {
51
- return {
52
- ...super.getHammerConfig(),
53
- // threshold: this.maxDist,
54
- time: this.minDurationMs,
55
- };
56
- }
57
- onGestureActivated(ev) {
58
- this.onGestureStart(ev);
59
- }
60
- shouldDelayTouchForEvent({ pointerType }) {
61
- // Don't disable event for mouse input
62
- return this.shouldDelayTouches && pointerType === 'touch';
63
- }
64
- onGestureStart(ev) {
65
- this.isGestureRunning = true;
66
- clearTimeout(this.visualFeedbackTimer);
67
- this.initialEvent = ev;
68
- this.visualFeedbackTimer = fireAfterInterval(() => {
69
- this.sendGestureStartedEvent(this.initialEvent);
70
- this.initialEvent = null;
71
- }, this.shouldDelayTouchForEvent(ev) && CONTENT_TOUCHES_DELAY);
72
- }
73
- sendGestureStartedEvent(ev) {
74
- clearTimeout(this.visualFeedbackTimer);
75
- this.visualFeedbackTimer = null;
76
- this.sendEvent({
77
- ...ev,
78
- eventType: Hammer.INPUT_MOVE,
79
- isFirst: true,
80
- });
81
- }
82
- forceInvalidate(event) {
83
- super.forceInvalidate(event);
84
- clearTimeout(this.visualFeedbackTimer);
85
- this.visualFeedbackTimer = null;
86
- this.initialEvent = null;
87
- }
88
- onRawEvent(ev) {
89
- super.onRawEvent(ev);
90
- if (this.isGestureRunning) {
91
- if (ev.isFinal) {
92
- let timeout;
93
- if (this.visualFeedbackTimer) {
94
- // Aesthetic timing for a quick tap.
95
- // We haven't activated the tap right away to emulate iOS `delaysContentTouches`
96
- // Now we must send the initial activation event and wait a set amount of time before firing the end event.
97
- timeout = CONTENT_TOUCHES_QUICK_TAP_END_DELAY;
98
- this.sendGestureStartedEvent(this.initialEvent);
99
- this.initialEvent = null;
100
- }
101
- fireAfterInterval(() => {
102
- this.sendEvent({
103
- ...ev,
104
- eventType: Hammer.INPUT_END,
105
- isFinal: true,
106
- });
107
- // @ts-ignore -- this should explicitly support undefined
108
- this.onGestureEnded();
109
- }, timeout);
110
- }
111
- else {
112
- this.sendEvent({
113
- ...ev,
114
- eventType: Hammer.INPUT_MOVE,
115
- isFinal: false,
116
- });
117
- }
118
- }
119
- }
120
- updateGestureConfig({ shouldActivateOnStart = false, disallowInterruption = false, shouldCancelWhenOutside = true, minDurationMs = Number.NaN, maxDist = Number.NaN, minPointers = 1, maxPointers = 1, ...props }) {
121
- return super.updateGestureConfig({
122
- shouldActivateOnStart,
123
- disallowInterruption,
124
- shouldCancelWhenOutside,
125
- minDurationMs,
126
- maxDist,
127
- minPointers,
128
- maxPointers,
129
- ...props,
130
- });
131
- }
132
- }
133
- export default PressGestureHandler;
@@ -1,20 +0,0 @@
1
- import Hammer from '@egjs/hammerjs';
2
- import { DEG_RAD } from './constants';
3
- import IndiscreteGestureHandler from './IndiscreteGestureHandler';
4
- class RotationGestureHandler extends IndiscreteGestureHandler {
5
- get name() {
6
- return 'rotate';
7
- }
8
- get NativeGestureClass() {
9
- return Hammer.Rotate;
10
- }
11
- transformNativeEvent({ rotation, velocity, center }) {
12
- return {
13
- rotation: (rotation - (this.initialRotation ?? 0)) * DEG_RAD,
14
- anchorX: center.x,
15
- anchorY: center.y,
16
- velocity,
17
- };
18
- }
19
- }
20
- export default RotationGestureHandler;
@@ -1,142 +0,0 @@
1
- import Hammer from '@egjs/hammerjs';
2
- import DiscreteGestureHandler from './DiscreteGestureHandler';
3
- import { isnan } from './utils';
4
- class TapGestureHandler extends DiscreteGestureHandler {
5
- _shouldFireEndEvent = null;
6
- _timer;
7
- _multiTapTimer; // TODO unused?
8
- get name() {
9
- return 'tap';
10
- }
11
- get NativeGestureClass() {
12
- return Hammer.Tap;
13
- }
14
- get maxDelayMs() {
15
- // @ts-ignore TODO(TS) trace down config
16
- return isnan(this.config.maxDelayMs) ? 300 : this.config.maxDelayMs;
17
- }
18
- simulateCancelEvent(inputData) {
19
- if (this.isGestureRunning) {
20
- this.cancelEvent(inputData);
21
- }
22
- }
23
- onGestureActivated(ev) {
24
- if (this.isGestureRunning) {
25
- this.onSuccessfulTap(ev);
26
- }
27
- }
28
- onSuccessfulTap = (ev) => {
29
- if (this._getPendingGestures().length) {
30
- this._shouldFireEndEvent = ev;
31
- return;
32
- }
33
- if (ev.eventType === Hammer.INPUT_END) {
34
- this.sendEvent({ ...ev, eventType: Hammer.INPUT_MOVE });
35
- }
36
- // When handler gets activated it will turn into State.END immediately.
37
- this.sendEvent({ ...ev, isFinal: true });
38
- this.onGestureEnded(ev);
39
- };
40
- onRawEvent(ev) {
41
- super.onRawEvent(ev);
42
- // Attempt to create a touch-down event by checking if a valid tap hasn't started yet, then validating the input.
43
- if (!this.hasGestureFailed &&
44
- !this.isGestureRunning &&
45
- // Prevent multi-pointer events from misfiring.
46
- !ev.isFinal) {
47
- // Tap Gesture start event
48
- const gesture = this.hammer.get(this.name);
49
- // @ts-ignore TODO(TS) trace down config
50
- if (gesture.options.enable(gesture, ev)) {
51
- clearTimeout(this._multiTapTimer);
52
- this.onStart(ev);
53
- this.sendEvent(ev);
54
- }
55
- }
56
- if (ev.isFinal && ev.maxPointers > 1) {
57
- setTimeout(() => {
58
- // Handle case where one finger presses slightly
59
- // after the first finger on a multi-tap event
60
- if (this.isGestureRunning) {
61
- this.cancelEvent(ev);
62
- }
63
- });
64
- }
65
- if (this.hasGestureFailed) {
66
- return;
67
- }
68
- // Hammer doesn't send a `cancel` event for taps.
69
- // Manually fail the event.
70
- if (ev.isFinal) {
71
- // Handle case where one finger presses slightly
72
- // after the first finger on a multi-tap event
73
- if (ev.maxPointers > 1) {
74
- setTimeout(() => {
75
- if (this.isGestureRunning) {
76
- this.cancelEvent(ev);
77
- }
78
- });
79
- }
80
- // Clear last timer
81
- clearTimeout(this._timer);
82
- // Create time out for multi-taps.
83
- this._timer = setTimeout(() => {
84
- this.hasGestureFailed = true;
85
- this.cancelEvent(ev);
86
- }, this.maxDelayMs);
87
- }
88
- else if (!this.hasGestureFailed && !this.isGestureRunning) {
89
- // Tap Gesture start event
90
- const gesture = this.hammer.get(this.name);
91
- // @ts-ignore TODO(TS) trace down config
92
- if (gesture.options.enable(gesture, ev)) {
93
- clearTimeout(this._multiTapTimer);
94
- this.onStart(ev);
95
- this.sendEvent(ev);
96
- }
97
- }
98
- }
99
- getHammerConfig() {
100
- return {
101
- ...super.getHammerConfig(),
102
- event: this.name,
103
- // @ts-ignore TODO(TS) trace down config
104
- taps: isnan(this.config.numberOfTaps) ? 1 : this.config.numberOfTaps,
105
- interval: this.maxDelayMs,
106
- time:
107
- // @ts-ignore TODO(TS) trace down config
108
- isnan(this.config.maxDurationMs) || this.config.maxDurationMs == null
109
- ? 250
110
- : // @ts-ignore TODO(TS) trace down config
111
- this.config.maxDurationMs,
112
- };
113
- }
114
- updateGestureConfig({ shouldCancelWhenOutside = true, maxDeltaX = Number.NaN, maxDeltaY = Number.NaN, numberOfTaps = 1, minDurationMs = 525, maxDelayMs = Number.NaN,
115
- // eslint-disable-next-line @typescript-eslint/no-unused-vars -- TODO possibly forgotten to use in updateGestureConfig?
116
- maxDurationMs = Number.NaN, maxDist = 2, minPointers = 1, maxPointers = 1, ...props }) {
117
- return super.updateGestureConfig({
118
- shouldCancelWhenOutside,
119
- numberOfTaps,
120
- maxDeltaX,
121
- maxDeltaY,
122
- minDurationMs,
123
- maxDelayMs,
124
- maxDist,
125
- minPointers,
126
- maxPointers,
127
- ...props,
128
- });
129
- }
130
- onGestureEnded(...props) {
131
- clearTimeout(this._timer);
132
- // @ts-ignore TODO(TS) check how onGestureEnded works
133
- super.onGestureEnded(...props);
134
- }
135
- onWaitingEnded(_gesture) {
136
- if (this._shouldFireEndEvent) {
137
- this.onSuccessfulTap(this._shouldFireEndEvent);
138
- this._shouldFireEndEvent = null;
139
- }
140
- }
141
- }
142
- export default TapGestureHandler;
@@ -1,42 +0,0 @@
1
- import Hammer from '@egjs/hammerjs';
2
- import { State } from '../State';
3
- export const CONTENT_TOUCHES_DELAY = 240;
4
- export const CONTENT_TOUCHES_QUICK_TAP_END_DELAY = 50;
5
- export const MULTI_FINGER_PAN_MAX_PINCH_THRESHOLD = 0.1;
6
- export const MULTI_FINGER_PAN_MAX_ROTATION_THRESHOLD = 7;
7
- export const DEG_RAD = Math.PI / 180;
8
- // Map Hammer values to RNGH
9
- export const EventMap = {
10
- [Hammer.INPUT_START]: State.BEGAN,
11
- [Hammer.INPUT_MOVE]: State.ACTIVE,
12
- [Hammer.INPUT_END]: State.END,
13
- [Hammer.INPUT_CANCEL]: State.FAILED,
14
- };
15
- export const Direction = {
16
- RIGHT: 1,
17
- LEFT: 2,
18
- UP: 4,
19
- DOWN: 8,
20
- };
21
- export const DirectionMap = {
22
- [Hammer.DIRECTION_RIGHT]: Direction.RIGHT,
23
- [Hammer.DIRECTION_LEFT]: Direction.LEFT,
24
- [Hammer.DIRECTION_UP]: Direction.UP,
25
- [Hammer.DIRECTION_DOWN]: Direction.DOWN,
26
- };
27
- export const HammerInputNames = {
28
- [Hammer.INPUT_START]: 'START',
29
- [Hammer.INPUT_MOVE]: 'MOVE',
30
- [Hammer.INPUT_END]: 'END',
31
- [Hammer.INPUT_CANCEL]: 'CANCEL',
32
- };
33
- export const HammerDirectionNames = {
34
- [Hammer.DIRECTION_HORIZONTAL]: 'HORIZONTAL',
35
- [Hammer.DIRECTION_UP]: 'UP',
36
- [Hammer.DIRECTION_DOWN]: 'DOWN',
37
- [Hammer.DIRECTION_VERTICAL]: 'VERTICAL',
38
- [Hammer.DIRECTION_NONE]: 'NONE',
39
- [Hammer.DIRECTION_ALL]: 'ALL',
40
- [Hammer.DIRECTION_RIGHT]: 'RIGHT',
41
- [Hammer.DIRECTION_LEFT]: 'LEFT',
42
- };
@@ -1,15 +0,0 @@
1
- // TODO(TS) remove if not necessary after rewrite
2
- export const isnan = (v) => Number.isNaN(v);
3
- // TODO(TS) remove if not necessary after rewrite
4
- export const isValidNumber = (v) => typeof v === 'number' && !Number.isNaN(v);
5
- export const TEST_MIN_IF_NOT_NAN = (value, limit) => !isnan(limit) &&
6
- ((limit < 0 && value <= limit) || (limit >= 0 && value >= limit));
7
- export const VEC_LEN_SQ = ({ x = 0, y = 0 } = {}) => x * x + y * y;
8
- export const TEST_MAX_IF_NOT_NAN = (value, max) => !isnan(max) && ((max < 0 && value < max) || (max >= 0 && value > max));
9
- export function fireAfterInterval(method, interval) {
10
- if (!interval) {
11
- method();
12
- return null;
13
- }
14
- return setTimeout(() => method(), interval);
15
- }