react-native-gesture-handler 2.27.1 → 2.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (426) hide show
  1. package/RNGestureHandler.podspec +3 -2
  2. package/ReanimatedSwipeable/package.json +4 -4
  3. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt +14 -8
  4. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +10 -5
  5. package/android/src/main/jni/CMakeLists.txt +5 -0
  6. package/android/src/main/jni/cpp-adapter.cpp +6 -0
  7. package/apple/RNGestureHandler.h +4 -0
  8. package/apple/RNGestureHandler.mm +41 -6
  9. package/apple/RNGestureHandlerModule.mm +5 -0
  10. package/jestSetup.js +22 -3
  11. package/lib/commonjs/components/Pressable/Pressable.js +12 -21
  12. package/lib/commonjs/components/Pressable/Pressable.js.map +1 -1
  13. package/lib/commonjs/components/Pressable/StateMachine.js +8 -2
  14. package/lib/commonjs/components/Pressable/StateMachine.js.map +1 -1
  15. package/lib/commonjs/components/Pressable/stateDefinitions.js +22 -23
  16. package/lib/commonjs/components/Pressable/stateDefinitions.js.map +1 -1
  17. package/lib/commonjs/components/{ReanimatedSwipeable.js → ReanimatedSwipeable/ReanimatedSwipeable.js} +30 -39
  18. package/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeable.js.map +1 -0
  19. package/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeableProps.js +12 -0
  20. package/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeableProps.js.map +1 -0
  21. package/lib/commonjs/components/ReanimatedSwipeable/index.js +21 -0
  22. package/lib/commonjs/components/ReanimatedSwipeable/index.js.map +1 -0
  23. package/lib/commonjs/components/gestureHandlerRootHOC.js +4 -1
  24. package/lib/commonjs/components/gestureHandlerRootHOC.js.map +1 -1
  25. package/lib/commonjs/handlers/createHandler.js +1 -1
  26. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  27. package/lib/commonjs/handlers/gestures/GestureDetector/index.js +1 -1
  28. package/lib/commonjs/handlers/gestures/GestureDetector/index.js.map +1 -1
  29. package/lib/commonjs/mocks/Pressable.js +13 -0
  30. package/lib/commonjs/mocks/Pressable.js.map +1 -0
  31. package/lib/commonjs/{mocks.js → mocks/mocks.js} +8 -11
  32. package/lib/commonjs/mocks/mocks.js.map +1 -0
  33. package/lib/commonjs/web/handlers/GestureHandler.js +5 -2
  34. package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
  35. package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js +0 -5
  36. package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js.map +1 -1
  37. package/lib/commonjs/web/tools/KeyboardEventManager.js +34 -8
  38. package/lib/commonjs/web/tools/KeyboardEventManager.js.map +1 -1
  39. package/lib/module/components/Pressable/Pressable.js +14 -23
  40. package/lib/module/components/Pressable/Pressable.js.map +1 -1
  41. package/lib/module/components/Pressable/StateMachine.js +8 -2
  42. package/lib/module/components/Pressable/StateMachine.js.map +1 -1
  43. package/lib/module/components/Pressable/stateDefinitions.js +21 -22
  44. package/lib/module/components/Pressable/stateDefinitions.js.map +1 -1
  45. package/lib/module/components/{ReanimatedSwipeable.js → ReanimatedSwipeable/ReanimatedSwipeable.js} +24 -33
  46. package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeable.js.map +1 -0
  47. package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeableProps.js +8 -0
  48. package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeableProps.js.map +1 -0
  49. package/lib/module/components/ReanimatedSwipeable/index.js +5 -0
  50. package/lib/module/components/ReanimatedSwipeable/index.js.map +1 -0
  51. package/lib/module/components/gestureHandlerRootHOC.js +5 -0
  52. package/lib/module/components/gestureHandlerRootHOC.js.map +1 -1
  53. package/lib/module/handlers/createHandler.js +1 -1
  54. package/lib/module/handlers/createHandler.js.map +1 -1
  55. package/lib/module/handlers/gestures/GestureDetector/index.js +1 -1
  56. package/lib/module/handlers/gestures/GestureDetector/index.js.map +1 -1
  57. package/lib/module/mocks/Pressable.js +4 -0
  58. package/lib/module/mocks/Pressable.js.map +1 -0
  59. package/lib/module/{mocks.js → mocks/mocks.js} +7 -11
  60. package/lib/module/mocks/mocks.js.map +1 -0
  61. package/lib/module/web/handlers/GestureHandler.js +5 -2
  62. package/lib/module/web/handlers/GestureHandler.js.map +1 -1
  63. package/lib/module/web/tools/GestureHandlerWebDelegate.js +0 -5
  64. package/lib/module/web/tools/GestureHandlerWebDelegate.js.map +1 -1
  65. package/lib/module/web/tools/KeyboardEventManager.js +34 -8
  66. package/lib/module/web/tools/KeyboardEventManager.js.map +1 -1
  67. package/lib/typescript/ActionType.d.ts +1 -0
  68. package/lib/typescript/Directions.d.ts +1 -0
  69. package/lib/typescript/EnableNewWebImplementation.d.ts +1 -0
  70. package/lib/typescript/GestureHandlerRootViewContext.d.ts +1 -0
  71. package/lib/typescript/PlatformConstants.d.ts +1 -0
  72. package/lib/typescript/PlatformConstants.web.d.ts +1 -0
  73. package/lib/typescript/PointerType.d.ts +1 -0
  74. package/lib/typescript/RNGestureHandlerModule.d.ts +1 -0
  75. package/lib/typescript/RNGestureHandlerModule.web.d.ts +1 -0
  76. package/lib/typescript/RNGestureHandlerModule.windows.d.ts +1 -0
  77. package/lib/typescript/RNRenderer.d.ts +1 -0
  78. package/lib/typescript/RNRenderer.web.d.ts +1 -0
  79. package/lib/typescript/State.d.ts +1 -0
  80. package/lib/typescript/TouchEventType.d.ts +1 -0
  81. package/lib/typescript/components/DrawerLayout.d.ts +1 -0
  82. package/lib/typescript/components/GestureButtons.d.ts +1 -0
  83. package/lib/typescript/components/GestureButtonsProps.d.ts +10 -1
  84. package/lib/typescript/components/GestureButtonsProps.d.ts.map +1 -1
  85. package/lib/typescript/components/GestureComponents.d.ts +1 -0
  86. package/lib/typescript/components/GestureComponents.web.d.ts +1 -0
  87. package/lib/typescript/components/GestureHandlerButton.d.ts +1 -0
  88. package/lib/typescript/components/GestureHandlerButton.web.d.ts +1 -0
  89. package/lib/typescript/components/GestureHandlerRootView.android.d.ts +1 -0
  90. package/lib/typescript/components/GestureHandlerRootView.d.ts +1 -0
  91. package/lib/typescript/components/GestureHandlerRootView.web.d.ts +1 -0
  92. package/lib/typescript/components/Pressable/Pressable.d.ts +1 -0
  93. package/lib/typescript/components/Pressable/Pressable.d.ts.map +1 -1
  94. package/lib/typescript/components/Pressable/PressableProps.d.ts +3 -4
  95. package/lib/typescript/components/Pressable/PressableProps.d.ts.map +1 -1
  96. package/lib/typescript/components/Pressable/StateMachine.d.ts +4 -2
  97. package/lib/typescript/components/Pressable/StateMachine.d.ts.map +1 -1
  98. package/lib/typescript/components/Pressable/index.d.ts +1 -0
  99. package/lib/typescript/components/Pressable/stateDefinitions.d.ts +3 -2
  100. package/lib/typescript/components/Pressable/stateDefinitions.d.ts.map +1 -1
  101. package/lib/typescript/components/Pressable/utils.d.ts +1 -0
  102. package/lib/typescript/components/ReanimatedDrawerLayout.d.ts +1 -0
  103. package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeable.d.ts +6 -0
  104. package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeable.d.ts.map +1 -0
  105. package/lib/typescript/components/{ReanimatedSwipeable.d.ts → ReanimatedSwipeable/ReanimatedSwipeableProps.d.ts} +10 -7
  106. package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeableProps.d.ts.map +1 -0
  107. package/lib/typescript/components/ReanimatedSwipeable/index.d.ts +3 -0
  108. package/lib/typescript/components/ReanimatedSwipeable/index.d.ts.map +1 -0
  109. package/lib/typescript/components/Swipeable.d.ts +1 -0
  110. package/lib/typescript/components/Text.d.ts +1 -0
  111. package/lib/typescript/components/gestureHandlerRootHOC.d.ts +5 -0
  112. package/lib/typescript/components/gestureHandlerRootHOC.d.ts.map +1 -1
  113. package/lib/typescript/components/touchables/ExtraButtonProps.d.ts +1 -0
  114. package/lib/typescript/components/touchables/GenericTouchable.d.ts +1 -0
  115. package/lib/typescript/components/touchables/GenericTouchableProps.d.ts +1 -0
  116. package/lib/typescript/components/touchables/TouchableHighlight.d.ts +1 -0
  117. package/lib/typescript/components/touchables/TouchableNativeFeedback.android.d.ts +1 -0
  118. package/lib/typescript/components/touchables/TouchableNativeFeedback.d.ts +1 -0
  119. package/lib/typescript/components/touchables/TouchableNativeFeedbackProps.d.ts +1 -0
  120. package/lib/typescript/components/touchables/TouchableOpacity.d.ts +1 -0
  121. package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts +1 -0
  122. package/lib/typescript/components/touchables/index.d.ts +1 -0
  123. package/lib/typescript/components/utils.d.ts +1 -0
  124. package/lib/typescript/findNodeHandle.d.ts +1 -0
  125. package/lib/typescript/findNodeHandle.web.d.ts +1 -0
  126. package/lib/typescript/getShadowNodeFromRef.d.ts +1 -0
  127. package/lib/typescript/getShadowNodeFromRef.web.d.ts +1 -0
  128. package/lib/typescript/ghQueueMicrotask.d.ts +1 -0
  129. package/lib/typescript/handlers/FlingGestureHandler.d.ts +1 -0
  130. package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +1 -0
  131. package/lib/typescript/handlers/GestureHandlerEventPayload.d.ts +1 -0
  132. package/lib/typescript/handlers/LongPressGestureHandler.d.ts +1 -0
  133. package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +1 -0
  134. package/lib/typescript/handlers/PanGestureHandler.d.ts +1 -0
  135. package/lib/typescript/handlers/PinchGestureHandler.d.ts +1 -0
  136. package/lib/typescript/handlers/PressabilityDebugView.d.ts +1 -0
  137. package/lib/typescript/handlers/PressabilityDebugView.web.d.ts +1 -0
  138. package/lib/typescript/handlers/RotationGestureHandler.d.ts +1 -0
  139. package/lib/typescript/handlers/TapGestureHandler.d.ts +1 -0
  140. package/lib/typescript/handlers/createHandler.d.ts +1 -0
  141. package/lib/typescript/handlers/createNativeWrapper.d.ts +1 -0
  142. package/lib/typescript/handlers/customDirectEventTypes.d.ts +1 -0
  143. package/lib/typescript/handlers/customDirectEventTypes.web.d.ts +1 -0
  144. package/lib/typescript/handlers/gestureHandlerCommon.d.ts +1 -0
  145. package/lib/typescript/handlers/gestureHandlerTypesCompat.d.ts +1 -0
  146. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.d.ts +1 -0
  147. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.web.d.ts +1 -0
  148. package/lib/typescript/handlers/gestures/GestureDetector/attachHandlers.d.ts +1 -0
  149. package/lib/typescript/handlers/gestures/GestureDetector/dropHandlers.d.ts +1 -0
  150. package/lib/typescript/handlers/gestures/GestureDetector/index.d.ts +1 -0
  151. package/lib/typescript/handlers/gestures/GestureDetector/needsToReattach.d.ts +1 -0
  152. package/lib/typescript/handlers/gestures/GestureDetector/types.d.ts +1 -0
  153. package/lib/typescript/handlers/gestures/GestureDetector/updateHandlers.d.ts +1 -0
  154. package/lib/typescript/handlers/gestures/GestureDetector/useAnimatedGesture.d.ts +1 -0
  155. package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.d.ts +1 -0
  156. package/lib/typescript/handlers/gestures/GestureDetector/useMountReactions.d.ts +1 -0
  157. package/lib/typescript/handlers/gestures/GestureDetector/useViewRefHandler.d.ts +1 -0
  158. package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts +1 -0
  159. package/lib/typescript/handlers/gestures/eventReceiver.d.ts +1 -0
  160. package/lib/typescript/handlers/gestures/flingGesture.d.ts +1 -0
  161. package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +1 -0
  162. package/lib/typescript/handlers/gestures/gesture.d.ts +1 -0
  163. package/lib/typescript/handlers/gestures/gestureComposition.d.ts +1 -0
  164. package/lib/typescript/handlers/gestures/gestureObjects.d.ts +1 -0
  165. package/lib/typescript/handlers/gestures/gestureStateManager.d.ts +1 -0
  166. package/lib/typescript/handlers/gestures/gestureStateManager.web.d.ts +1 -0
  167. package/lib/typescript/handlers/gestures/hoverGesture.d.ts +1 -0
  168. package/lib/typescript/handlers/gestures/longPressGesture.d.ts +1 -0
  169. package/lib/typescript/handlers/gestures/manualGesture.d.ts +1 -0
  170. package/lib/typescript/handlers/gestures/nativeGesture.d.ts +1 -0
  171. package/lib/typescript/handlers/gestures/panGesture.d.ts +1 -0
  172. package/lib/typescript/handlers/gestures/pinchGesture.d.ts +1 -0
  173. package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts +1 -0
  174. package/lib/typescript/handlers/gestures/rotationGesture.d.ts +1 -0
  175. package/lib/typescript/handlers/gestures/tapGesture.d.ts +1 -0
  176. package/lib/typescript/handlers/getNextHandlerTag.d.ts +1 -0
  177. package/lib/typescript/handlers/handlersRegistry.d.ts +1 -0
  178. package/lib/typescript/handlers/utils.d.ts +1 -0
  179. package/lib/typescript/index.d.ts +1 -0
  180. package/lib/typescript/init.d.ts +1 -0
  181. package/lib/typescript/jestUtils/index.d.ts +1 -0
  182. package/lib/typescript/jestUtils/jestUtils.d.ts +1 -0
  183. package/lib/typescript/mocks/Pressable.d.ts +2 -0
  184. package/lib/typescript/mocks/Pressable.d.ts.map +1 -0
  185. package/lib/typescript/{mocks.d.ts → mocks/mocks.d.ts} +5 -4
  186. package/lib/typescript/mocks/mocks.d.ts.map +1 -0
  187. package/lib/typescript/mountRegistry.d.ts +1 -0
  188. package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts +1 -0
  189. package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts +1 -0
  190. package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.d.ts +1 -0
  191. package/lib/typescript/typeUtils.d.ts +1 -0
  192. package/lib/typescript/utils.d.ts +1 -0
  193. package/lib/typescript/web/Gestures.d.ts +1 -0
  194. package/lib/typescript/web/constants.d.ts +1 -0
  195. package/lib/typescript/web/detectors/RotationGestureDetector.d.ts +1 -0
  196. package/lib/typescript/web/detectors/ScaleGestureDetector.d.ts +1 -0
  197. package/lib/typescript/web/handlers/FlingGestureHandler.d.ts +1 -0
  198. package/lib/typescript/web/handlers/GestureHandler.d.ts +1 -0
  199. package/lib/typescript/web/handlers/GestureHandler.d.ts.map +1 -1
  200. package/lib/typescript/web/handlers/HoverGestureHandler.d.ts +1 -0
  201. package/lib/typescript/web/handlers/IGestureHandler.d.ts +1 -0
  202. package/lib/typescript/web/handlers/LongPressGestureHandler.d.ts +1 -0
  203. package/lib/typescript/web/handlers/ManualGestureHandler.d.ts +1 -0
  204. package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +1 -0
  205. package/lib/typescript/web/handlers/PanGestureHandler.d.ts +1 -0
  206. package/lib/typescript/web/handlers/PinchGestureHandler.d.ts +1 -0
  207. package/lib/typescript/web/handlers/RotationGestureHandler.d.ts +1 -0
  208. package/lib/typescript/web/handlers/TapGestureHandler.d.ts +1 -0
  209. package/lib/typescript/web/interfaces.d.ts +1 -0
  210. package/lib/typescript/web/tools/CircularBuffer.d.ts +1 -0
  211. package/lib/typescript/web/tools/EventManager.d.ts +1 -0
  212. package/lib/typescript/web/tools/GestureHandlerDelegate.d.ts +1 -0
  213. package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts +1 -0
  214. package/lib/typescript/web/tools/GestureHandlerWebDelegate.d.ts +1 -0
  215. package/lib/typescript/web/tools/GestureHandlerWebDelegate.d.ts.map +1 -1
  216. package/lib/typescript/web/tools/InteractionManager.d.ts +1 -0
  217. package/lib/typescript/web/tools/KeyboardEventManager.d.ts +7 -3
  218. package/lib/typescript/web/tools/KeyboardEventManager.d.ts.map +1 -1
  219. package/lib/typescript/web/tools/LeastSquareSolver.d.ts +1 -0
  220. package/lib/typescript/web/tools/NodeManager.d.ts +1 -0
  221. package/lib/typescript/web/tools/PointerEventManager.d.ts +1 -0
  222. package/lib/typescript/web/tools/PointerTracker.d.ts +1 -0
  223. package/lib/typescript/web/tools/Vector.d.ts +1 -0
  224. package/lib/typescript/web/tools/VelocityTracker.d.ts +1 -0
  225. package/lib/typescript/web/tools/WheelEventManager.d.ts +1 -0
  226. package/lib/typescript/web/utils.d.ts +1 -0
  227. package/lib/typescript/web_hammer/DiscreteGestureHandler.d.ts +1 -0
  228. package/lib/typescript/web_hammer/DraggingGestureHandler.d.ts +1 -0
  229. package/lib/typescript/web_hammer/Errors.d.ts +1 -0
  230. package/lib/typescript/web_hammer/FlingGestureHandler.d.ts +1 -0
  231. package/lib/typescript/web_hammer/GestureHandler.d.ts +1 -0
  232. package/lib/typescript/web_hammer/IndiscreteGestureHandler.d.ts +1 -0
  233. package/lib/typescript/web_hammer/LongPressGestureHandler.d.ts +1 -0
  234. package/lib/typescript/web_hammer/NativeViewGestureHandler.d.ts +1 -0
  235. package/lib/typescript/web_hammer/NodeManager.d.ts +1 -0
  236. package/lib/typescript/web_hammer/PanGestureHandler.d.ts +1 -0
  237. package/lib/typescript/web_hammer/PinchGestureHandler.d.ts +1 -0
  238. package/lib/typescript/web_hammer/PressGestureHandler.d.ts +1 -0
  239. package/lib/typescript/web_hammer/RotationGestureHandler.d.ts +1 -0
  240. package/lib/typescript/web_hammer/TapGestureHandler.d.ts +1 -0
  241. package/lib/typescript/web_hammer/constants.d.ts +1 -0
  242. package/lib/typescript/web_hammer/utils.d.ts +1 -0
  243. package/package.json +4 -3
  244. package/scripts/gesture_handler_utils.rb +25 -0
  245. package/src/components/GestureButtonsProps.ts +10 -0
  246. package/src/components/Pressable/Pressable.tsx +20 -31
  247. package/src/components/Pressable/PressableProps.tsx +2 -4
  248. package/src/components/Pressable/StateMachine.tsx +12 -4
  249. package/src/components/Pressable/stateDefinitions.ts +23 -23
  250. package/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx +603 -0
  251. package/src/components/ReanimatedSwipeable/ReanimatedSwipeableProps.ts +199 -0
  252. package/src/components/ReanimatedSwipeable/index.ts +6 -0
  253. package/src/components/gestureHandlerRootHOC.tsx +4 -0
  254. package/src/handlers/createHandler.tsx +1 -1
  255. package/src/handlers/gestures/GestureDetector/index.tsx +1 -1
  256. package/src/mocks/Pressable.tsx +1 -0
  257. package/src/{mocks.tsx → mocks/mocks.tsx} +7 -11
  258. package/src/web/handlers/GestureHandler.ts +8 -3
  259. package/src/web/tools/GestureHandlerWebDelegate.ts +0 -5
  260. package/src/web/tools/KeyboardEventManager.ts +50 -8
  261. package/lib/commonjs/components/ReanimatedSwipeable.js.map +0 -1
  262. package/lib/commonjs/mocks.js.map +0 -1
  263. package/lib/module/components/ReanimatedSwipeable.js.map +0 -1
  264. package/lib/module/mocks.js.map +0 -1
  265. package/lib/typescript/ActionType.js +0 -6
  266. package/lib/typescript/Directions.js +0 -18
  267. package/lib/typescript/EnableNewWebImplementation.js +0 -30
  268. package/lib/typescript/GestureHandlerRootViewContext.js +0 -2
  269. package/lib/typescript/PlatformConstants.js +0 -3
  270. package/lib/typescript/PlatformConstants.web.js +0 -5
  271. package/lib/typescript/PointerType.js +0 -8
  272. package/lib/typescript/RNGestureHandlerModule.js +0 -4
  273. package/lib/typescript/RNGestureHandlerModule.web.js +0 -92
  274. package/lib/typescript/RNGestureHandlerModule.windows.js +0 -47
  275. package/lib/typescript/RNRenderer.js +0 -3
  276. package/lib/typescript/RNRenderer.web.js +0 -3
  277. package/lib/typescript/State.js +0 -9
  278. package/lib/typescript/TouchEventType.js +0 -7
  279. package/lib/typescript/components/DrawerLayout.js +0 -417
  280. package/lib/typescript/components/GestureButtons.js +0 -165
  281. package/lib/typescript/components/GestureButtonsProps.js +0 -1
  282. package/lib/typescript/components/GestureComponents.js +0 -67
  283. package/lib/typescript/components/GestureComponents.web.js +0 -21
  284. package/lib/typescript/components/GestureHandlerButton.js +0 -2
  285. package/lib/typescript/components/GestureHandlerButton.web.js +0 -3
  286. package/lib/typescript/components/GestureHandlerRootView.android.js +0 -17
  287. package/lib/typescript/components/GestureHandlerRootView.js +0 -16
  288. package/lib/typescript/components/GestureHandlerRootView.web.js +0 -11
  289. package/lib/typescript/components/Pressable/Pressable.js +0 -231
  290. package/lib/typescript/components/Pressable/PressableProps.js +0 -1
  291. package/lib/typescript/components/Pressable/StateMachine.js +0 -34
  292. package/lib/typescript/components/Pressable/index.js +0 -1
  293. package/lib/typescript/components/Pressable/stateDefinitions.js +0 -104
  294. package/lib/typescript/components/Pressable/utils.js +0 -80
  295. package/lib/typescript/components/ReanimatedDrawerLayout.js +0 -364
  296. package/lib/typescript/components/ReanimatedSwipeable.d.ts.map +0 -1
  297. package/lib/typescript/components/ReanimatedSwipeable.js +0 -400
  298. package/lib/typescript/components/Swipeable.js +0 -287
  299. package/lib/typescript/components/Text.js +0 -38
  300. package/lib/typescript/components/gestureHandlerRootHOC.js +0 -18
  301. package/lib/typescript/components/touchables/ExtraButtonProps.js +0 -1
  302. package/lib/typescript/components/touchables/GenericTouchable.js +0 -221
  303. package/lib/typescript/components/touchables/GenericTouchableProps.js +0 -1
  304. package/lib/typescript/components/touchables/TouchableHighlight.js +0 -75
  305. package/lib/typescript/components/touchables/TouchableNativeFeedback.android.js +0 -65
  306. package/lib/typescript/components/touchables/TouchableNativeFeedback.js +0 -6
  307. package/lib/typescript/components/touchables/TouchableNativeFeedbackProps.js +0 -1
  308. package/lib/typescript/components/touchables/TouchableOpacity.js +0 -51
  309. package/lib/typescript/components/touchables/TouchableWithoutFeedback.js +0 -10
  310. package/lib/typescript/components/touchables/index.js +0 -4
  311. package/lib/typescript/components/utils.js +0 -11
  312. package/lib/typescript/findNodeHandle.js +0 -2
  313. package/lib/typescript/findNodeHandle.web.js +0 -31
  314. package/lib/typescript/getShadowNodeFromRef.js +0 -45
  315. package/lib/typescript/getShadowNodeFromRef.web.js +0 -7
  316. package/lib/typescript/ghQueueMicrotask.js +0 -7
  317. package/lib/typescript/handlers/FlingGestureHandler.js +0 -19
  318. package/lib/typescript/handlers/ForceTouchGestureHandler.js +0 -37
  319. package/lib/typescript/handlers/GestureHandlerEventPayload.js +0 -1
  320. package/lib/typescript/handlers/LongPressGestureHandler.js +0 -22
  321. package/lib/typescript/handlers/NativeViewGestureHandler.js +0 -20
  322. package/lib/typescript/handlers/PanGestureHandler.js +0 -128
  323. package/lib/typescript/handlers/PinchGestureHandler.js +0 -12
  324. package/lib/typescript/handlers/PressabilityDebugView.js +0 -2
  325. package/lib/typescript/handlers/PressabilityDebugView.web.js +0 -4
  326. package/lib/typescript/handlers/RotationGestureHandler.js +0 -12
  327. package/lib/typescript/handlers/TapGestureHandler.js +0 -26
  328. package/lib/typescript/handlers/createHandler.js +0 -375
  329. package/lib/typescript/handlers/createNativeWrapper.js +0 -67
  330. package/lib/typescript/handlers/customDirectEventTypes.js +0 -2
  331. package/lib/typescript/handlers/customDirectEventTypes.web.js +0 -4
  332. package/lib/typescript/handlers/gestureHandlerCommon.js +0 -42
  333. package/lib/typescript/handlers/gestureHandlerTypesCompat.js +0 -1
  334. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.js +0 -22
  335. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.web.js +0 -24
  336. package/lib/typescript/handlers/gestures/GestureDetector/attachHandlers.js +0 -55
  337. package/lib/typescript/handlers/gestures/GestureDetector/dropHandlers.js +0 -12
  338. package/lib/typescript/handlers/gestures/GestureDetector/index.js +0 -114
  339. package/lib/typescript/handlers/gestures/GestureDetector/needsToReattach.js +0 -18
  340. package/lib/typescript/handlers/gestures/GestureDetector/types.js +0 -1
  341. package/lib/typescript/handlers/gestures/GestureDetector/updateHandlers.js +0 -54
  342. package/lib/typescript/handlers/gestures/GestureDetector/useAnimatedGesture.js +0 -137
  343. package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.js +0 -48
  344. package/lib/typescript/handlers/gestures/GestureDetector/useMountReactions.js +0 -35
  345. package/lib/typescript/handlers/gestures/GestureDetector/useViewRefHandler.js +0 -32
  346. package/lib/typescript/handlers/gestures/GestureDetector/utils.js +0 -140
  347. package/lib/typescript/handlers/gestures/eventReceiver.js +0 -105
  348. package/lib/typescript/handlers/gestures/flingGesture.js +0 -27
  349. package/lib/typescript/handlers/gestures/forceTouchGesture.js +0 -57
  350. package/lib/typescript/handlers/gestures/gesture.js +0 -303
  351. package/lib/typescript/handlers/gestures/gestureComposition.js +0 -78
  352. package/lib/typescript/handlers/gestures/gestureObjects.js +0 -125
  353. package/lib/typescript/handlers/gestures/gestureStateManager.js +0 -60
  354. package/lib/typescript/handlers/gestures/gestureStateManager.web.js +0 -19
  355. package/lib/typescript/handlers/gestures/hoverGesture.js +0 -45
  356. package/lib/typescript/handlers/gestures/longPressGesture.js +0 -35
  357. package/lib/typescript/handlers/gestures/manualGesture.js +0 -16
  358. package/lib/typescript/handlers/gestures/nativeGesture.js +0 -24
  359. package/lib/typescript/handlers/gestures/panGesture.js +0 -181
  360. package/lib/typescript/handlers/gestures/pinchGesture.js +0 -27
  361. package/lib/typescript/handlers/gestures/reanimatedWrapper.js +0 -23
  362. package/lib/typescript/handlers/gestures/rotationGesture.js +0 -27
  363. package/lib/typescript/handlers/gestures/tapGesture.js +0 -72
  364. package/lib/typescript/handlers/getNextHandlerTag.js +0 -4
  365. package/lib/typescript/handlers/handlersRegistry.js +0 -36
  366. package/lib/typescript/handlers/utils.js +0 -58
  367. package/lib/typescript/index.js +0 -28
  368. package/lib/typescript/init.js +0 -15
  369. package/lib/typescript/jestUtils/index.js +0 -1
  370. package/lib/typescript/jestUtils/jestUtils.js +0 -290
  371. package/lib/typescript/mocks.d.ts.map +0 -1
  372. package/lib/typescript/mocks.js +0 -59
  373. package/lib/typescript/mountRegistry.js +0 -29
  374. package/lib/typescript/specs/NativeRNGestureHandlerModule.js +0 -2
  375. package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.js +0 -2
  376. package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.js +0 -2
  377. package/lib/typescript/typeUtils.js +0 -1
  378. package/lib/typescript/utils.js +0 -80
  379. package/lib/typescript/web/Gestures.js +0 -38
  380. package/lib/typescript/web/constants.js +0 -2
  381. package/lib/typescript/web/detectors/RotationGestureDetector.js +0 -122
  382. package/lib/typescript/web/detectors/ScaleGestureDetector.js +0 -117
  383. package/lib/typescript/web/handlers/FlingGestureHandler.js +0 -133
  384. package/lib/typescript/web/handlers/GestureHandler.js +0 -656
  385. package/lib/typescript/web/handlers/HoverGestureHandler.js +0 -37
  386. package/lib/typescript/web/handlers/IGestureHandler.js +0 -1
  387. package/lib/typescript/web/handlers/LongPressGestureHandler.js +0 -136
  388. package/lib/typescript/web/handlers/ManualGestureHandler.js +0 -29
  389. package/lib/typescript/web/handlers/NativeViewGestureHandler.js +0 -133
  390. package/lib/typescript/web/handlers/PanGestureHandler.js +0 -420
  391. package/lib/typescript/web/handlers/PinchGestureHandler.js +0 -117
  392. package/lib/typescript/web/handlers/RotationGestureHandler.js +0 -122
  393. package/lib/typescript/web/handlers/TapGestureHandler.js +0 -202
  394. package/lib/typescript/web/interfaces.js +0 -25
  395. package/lib/typescript/web/tools/CircularBuffer.js +0 -37
  396. package/lib/typescript/web/tools/EventManager.js +0 -85
  397. package/lib/typescript/web/tools/GestureHandlerDelegate.js +0 -1
  398. package/lib/typescript/web/tools/GestureHandlerOrchestrator.js +0 -273
  399. package/lib/typescript/web/tools/GestureHandlerWebDelegate.js +0 -169
  400. package/lib/typescript/web/tools/InteractionManager.js +0 -91
  401. package/lib/typescript/web/tools/KeyboardEventManager.js +0 -73
  402. package/lib/typescript/web/tools/LeastSquareSolver.js +0 -147
  403. package/lib/typescript/web/tools/NodeManager.js +0 -28
  404. package/lib/typescript/web/tools/PointerEventManager.js +0 -179
  405. package/lib/typescript/web/tools/PointerTracker.js +0 -161
  406. package/lib/typescript/web/tools/Vector.js +0 -43
  407. package/lib/typescript/web/tools/VelocityTracker.js +0 -76
  408. package/lib/typescript/web/tools/WheelEventManager.js +0 -40
  409. package/lib/typescript/web/utils.js +0 -233
  410. package/lib/typescript/web_hammer/DiscreteGestureHandler.js +0 -48
  411. package/lib/typescript/web_hammer/DraggingGestureHandler.js +0 -25
  412. package/lib/typescript/web_hammer/Errors.js +0 -5
  413. package/lib/typescript/web_hammer/FlingGestureHandler.js +0 -119
  414. package/lib/typescript/web_hammer/GestureHandler.js +0 -469
  415. package/lib/typescript/web_hammer/IndiscreteGestureHandler.js +0 -26
  416. package/lib/typescript/web_hammer/LongPressGestureHandler.js +0 -46
  417. package/lib/typescript/web_hammer/NativeViewGestureHandler.js +0 -40
  418. package/lib/typescript/web_hammer/NodeManager.js +0 -28
  419. package/lib/typescript/web_hammer/PanGestureHandler.js +0 -151
  420. package/lib/typescript/web_hammer/PinchGestureHandler.js +0 -19
  421. package/lib/typescript/web_hammer/PressGestureHandler.js +0 -133
  422. package/lib/typescript/web_hammer/RotationGestureHandler.js +0 -20
  423. package/lib/typescript/web_hammer/TapGestureHandler.js +0 -142
  424. package/lib/typescript/web_hammer/constants.js +0 -42
  425. package/lib/typescript/web_hammer/utils.js +0 -15
  426. package/src/components/ReanimatedSwipeable.tsx +0 -811
@@ -1,202 +0,0 @@
1
- import { State } from '../../State';
2
- import { EventTypes } from '../interfaces';
3
- import GestureHandler from './GestureHandler';
4
- const DEFAULT_MAX_DURATION_MS = 500;
5
- const DEFAULT_MAX_DELAY_MS = 500;
6
- const DEFAULT_NUMBER_OF_TAPS = 1;
7
- const DEFAULT_MIN_NUMBER_OF_POINTERS = 1;
8
- export default class TapGestureHandler extends GestureHandler {
9
- maxDeltaX = Number.MIN_SAFE_INTEGER;
10
- maxDeltaY = Number.MIN_SAFE_INTEGER;
11
- maxDistSq = Number.MIN_SAFE_INTEGER;
12
- maxDurationMs = DEFAULT_MAX_DURATION_MS;
13
- maxDelayMs = DEFAULT_MAX_DELAY_MS;
14
- numberOfTaps = DEFAULT_NUMBER_OF_TAPS;
15
- minNumberOfPointers = DEFAULT_MIN_NUMBER_OF_POINTERS;
16
- currentMaxNumberOfPointers = 1;
17
- startX = 0;
18
- startY = 0;
19
- offsetX = 0;
20
- offsetY = 0;
21
- lastX = 0;
22
- lastY = 0;
23
- waitTimeout;
24
- delayTimeout;
25
- tapsSoFar = 0;
26
- updateGestureConfig({ enabled = true, ...props }) {
27
- super.updateGestureConfig({ enabled: enabled, ...props });
28
- if (this.config.numberOfTaps !== undefined) {
29
- this.numberOfTaps = this.config.numberOfTaps;
30
- }
31
- if (this.config.maxDurationMs !== undefined) {
32
- this.maxDurationMs = this.config.maxDurationMs;
33
- }
34
- if (this.config.maxDelayMs !== undefined) {
35
- this.maxDelayMs = this.config.maxDelayMs;
36
- }
37
- if (this.config.maxDeltaX !== undefined) {
38
- this.maxDeltaX = this.config.maxDeltaX;
39
- }
40
- if (this.config.maxDeltaY !== undefined) {
41
- this.maxDeltaY = this.config.maxDeltaY;
42
- }
43
- if (this.config.maxDist !== undefined) {
44
- this.maxDistSq = this.config.maxDist * this.config.maxDist;
45
- }
46
- if (this.config.minPointers !== undefined) {
47
- this.minNumberOfPointers = this.config.minPointers;
48
- }
49
- }
50
- resetConfig() {
51
- super.resetConfig();
52
- this.maxDeltaX = Number.MIN_SAFE_INTEGER;
53
- this.maxDeltaY = Number.MIN_SAFE_INTEGER;
54
- this.maxDistSq = Number.MIN_SAFE_INTEGER;
55
- this.maxDurationMs = DEFAULT_MAX_DURATION_MS;
56
- this.maxDelayMs = DEFAULT_MAX_DELAY_MS;
57
- this.numberOfTaps = DEFAULT_NUMBER_OF_TAPS;
58
- this.minNumberOfPointers = DEFAULT_MIN_NUMBER_OF_POINTERS;
59
- }
60
- clearTimeouts() {
61
- clearTimeout(this.waitTimeout);
62
- clearTimeout(this.delayTimeout);
63
- }
64
- startTap() {
65
- this.clearTimeouts();
66
- this.waitTimeout = setTimeout(() => this.fail(), this.maxDurationMs);
67
- }
68
- endTap() {
69
- this.clearTimeouts();
70
- if (++this.tapsSoFar === this.numberOfTaps &&
71
- this.currentMaxNumberOfPointers >= this.minNumberOfPointers) {
72
- this.activate();
73
- }
74
- else {
75
- this.delayTimeout = setTimeout(() => this.fail(), this.maxDelayMs);
76
- }
77
- }
78
- updateLastCoords() {
79
- const { x, y } = this.tracker.getAbsoluteCoordsAverage();
80
- this.lastX = x;
81
- this.lastY = y;
82
- }
83
- // Handling Events
84
- onPointerDown(event) {
85
- if (!this.isButtonInConfig(event.button)) {
86
- return;
87
- }
88
- this.tracker.addToTracker(event);
89
- super.onPointerDown(event);
90
- this.trySettingPosition(event);
91
- this.startX = event.x;
92
- this.startY = event.y;
93
- this.lastX = event.x;
94
- this.lastY = event.y;
95
- this.updateState(event);
96
- this.tryToSendTouchEvent(event);
97
- }
98
- onPointerAdd(event) {
99
- super.onPointerAdd(event);
100
- this.tracker.addToTracker(event);
101
- this.trySettingPosition(event);
102
- this.offsetX += this.lastX - this.startX;
103
- this.offsetY += this.lastY - this.startY;
104
- this.updateLastCoords();
105
- this.startX = this.lastX;
106
- this.startY = this.lastY;
107
- this.updateState(event);
108
- }
109
- onPointerUp(event) {
110
- super.onPointerUp(event);
111
- this.updateLastCoords();
112
- this.tracker.removeFromTracker(event.pointerId);
113
- this.updateState(event);
114
- }
115
- onPointerRemove(event) {
116
- super.onPointerRemove(event);
117
- this.tracker.removeFromTracker(event.pointerId);
118
- this.offsetX += this.lastX - this.startX;
119
- this.offsetY += this.lastY = this.startY;
120
- this.updateLastCoords();
121
- this.startX = this.lastX;
122
- this.startY = this.lastY;
123
- this.updateState(event);
124
- }
125
- onPointerMove(event) {
126
- this.trySettingPosition(event);
127
- this.tracker.track(event);
128
- this.updateLastCoords();
129
- this.updateState(event);
130
- super.onPointerMove(event);
131
- }
132
- onPointerOutOfBounds(event) {
133
- this.trySettingPosition(event);
134
- this.tracker.track(event);
135
- this.updateLastCoords();
136
- this.updateState(event);
137
- super.onPointerOutOfBounds(event);
138
- }
139
- updateState(event) {
140
- if (this.currentMaxNumberOfPointers < this.tracker.trackedPointersCount) {
141
- this.currentMaxNumberOfPointers = this.tracker.trackedPointersCount;
142
- }
143
- if (this.shouldFail()) {
144
- this.fail();
145
- return;
146
- }
147
- switch (this.state) {
148
- case State.UNDETERMINED:
149
- if (event.eventType === EventTypes.DOWN) {
150
- this.begin();
151
- }
152
- this.startTap();
153
- break;
154
- case State.BEGAN:
155
- if (event.eventType === EventTypes.UP) {
156
- this.endTap();
157
- }
158
- if (event.eventType === EventTypes.DOWN) {
159
- this.startTap();
160
- }
161
- break;
162
- default:
163
- break;
164
- }
165
- }
166
- trySettingPosition(event) {
167
- if (this.state !== State.UNDETERMINED) {
168
- return;
169
- }
170
- this.offsetX = 0;
171
- this.offsetY = 0;
172
- this.startX = event.x;
173
- this.startY = event.y;
174
- }
175
- shouldFail() {
176
- const dx = this.lastX - this.startX + this.offsetX;
177
- if (this.maxDeltaX !== Number.MIN_SAFE_INTEGER &&
178
- Math.abs(dx) > this.maxDeltaX) {
179
- return true;
180
- }
181
- const dy = this.lastY - this.startY + this.offsetY;
182
- if (this.maxDeltaY !== Number.MIN_SAFE_INTEGER &&
183
- Math.abs(dy) > this.maxDeltaY) {
184
- return true;
185
- }
186
- const distSq = dy * dy + dx * dx;
187
- return (this.maxDistSq !== Number.MIN_SAFE_INTEGER && distSq > this.maxDistSq);
188
- }
189
- activate() {
190
- super.activate();
191
- this.end();
192
- }
193
- onCancel() {
194
- this.resetProgress();
195
- this.clearTimeouts();
196
- }
197
- resetProgress() {
198
- this.clearTimeouts();
199
- this.tapsSoFar = 0;
200
- this.currentMaxNumberOfPointers = 0;
201
- }
202
- }
@@ -1,25 +0,0 @@
1
- export var EventTypes;
2
- (function (EventTypes) {
3
- EventTypes[EventTypes["DOWN"] = 0] = "DOWN";
4
- EventTypes[EventTypes["ADDITIONAL_POINTER_DOWN"] = 1] = "ADDITIONAL_POINTER_DOWN";
5
- EventTypes[EventTypes["UP"] = 2] = "UP";
6
- EventTypes[EventTypes["ADDITIONAL_POINTER_UP"] = 3] = "ADDITIONAL_POINTER_UP";
7
- EventTypes[EventTypes["MOVE"] = 4] = "MOVE";
8
- EventTypes[EventTypes["ENTER"] = 5] = "ENTER";
9
- EventTypes[EventTypes["LEAVE"] = 6] = "LEAVE";
10
- EventTypes[EventTypes["CANCEL"] = 7] = "CANCEL";
11
- })(EventTypes || (EventTypes = {}));
12
- export var TouchEventType;
13
- (function (TouchEventType) {
14
- TouchEventType[TouchEventType["UNDETERMINED"] = 0] = "UNDETERMINED";
15
- TouchEventType[TouchEventType["DOWN"] = 1] = "DOWN";
16
- TouchEventType[TouchEventType["MOVE"] = 2] = "MOVE";
17
- TouchEventType[TouchEventType["UP"] = 3] = "UP";
18
- TouchEventType[TouchEventType["CANCELLED"] = 4] = "CANCELLED";
19
- })(TouchEventType || (TouchEventType = {}));
20
- export var WheelDevice;
21
- (function (WheelDevice) {
22
- WheelDevice[WheelDevice["UNDETERMINED"] = 0] = "UNDETERMINED";
23
- WheelDevice[WheelDevice["MOUSE"] = 1] = "MOUSE";
24
- WheelDevice[WheelDevice["TOUCHPAD"] = 2] = "TOUCHPAD";
25
- })(WheelDevice || (WheelDevice = {}));
@@ -1,37 +0,0 @@
1
- export default class CircularBuffer {
2
- capacity;
3
- buffer;
4
- index;
5
- _size;
6
- constructor(size) {
7
- this.capacity = size;
8
- this.buffer = new Array(size);
9
- this.index = 0;
10
- this._size = 0;
11
- }
12
- push(element) {
13
- this.buffer[this.index] = element;
14
- this.index = (this.index + 1) % this.capacity;
15
- this._size = Math.min(this.size + 1, this.capacity);
16
- }
17
- get(at) {
18
- if (this._size === this.capacity) {
19
- let index = (this.index + at) % this.capacity;
20
- if (index < 0) {
21
- index += this.capacity;
22
- }
23
- return this.buffer[index];
24
- }
25
- else {
26
- return this.buffer[at];
27
- }
28
- }
29
- clear() {
30
- this.buffer = new Array(this.capacity);
31
- this.index = 0;
32
- this._size = 0;
33
- }
34
- get size() {
35
- return this._size;
36
- }
37
- }
@@ -1,85 +0,0 @@
1
- export default class EventManager {
2
- view;
3
- pointersInBounds = [];
4
- activePointersCounter;
5
- constructor(view) {
6
- this.view = view;
7
- this.activePointersCounter = 0;
8
- }
9
- onPointerDown(_event) { }
10
- onPointerAdd(_event) { }
11
- onPointerUp(_event) { }
12
- onPointerRemove(_event) { }
13
- onPointerMove(_event) { }
14
- onPointerLeave(_event) { } // Called only when pointer is pressed (or touching)
15
- onPointerEnter(_event) { } // Called only when pointer is pressed (or touching)
16
- onPointerCancel(_event) {
17
- // When pointer cancel is triggered and there are more pointers on the view, only one pointer is cancelled
18
- // Because we want all pointers to be cancelled by that event, we are doing it manually by reseting handler and changing activePointersCounter to 0
19
- // Events that correspond to removing the pointer (pointerup, touchend) have condition, that they don't perform any action when activePointersCounter
20
- // is equal to 0. This prevents counter from going to negative values, when pointers are removed from view after one of them has been cancelled
21
- }
22
- onPointerOutOfBounds(_event) { }
23
- onPointerMoveOver(_event) { }
24
- onPointerMoveOut(_event) { }
25
- onWheel(_event) { }
26
- setOnPointerDown(callback) {
27
- this.onPointerDown = callback;
28
- }
29
- setOnPointerAdd(callback) {
30
- this.onPointerAdd = callback;
31
- }
32
- setOnPointerUp(callback) {
33
- this.onPointerUp = callback;
34
- }
35
- setOnPointerRemove(callback) {
36
- this.onPointerRemove = callback;
37
- }
38
- setOnPointerMove(callback) {
39
- this.onPointerMove = callback;
40
- }
41
- setOnPointerLeave(callback) {
42
- this.onPointerLeave = callback;
43
- }
44
- setOnPointerEnter(callback) {
45
- this.onPointerEnter = callback;
46
- }
47
- setOnPointerCancel(callback) {
48
- this.onPointerCancel = callback;
49
- }
50
- setOnPointerOutOfBounds(callback) {
51
- this.onPointerOutOfBounds = callback;
52
- }
53
- setOnPointerMoveOver(callback) {
54
- this.onPointerMoveOver = callback;
55
- }
56
- setOnPointerMoveOut(callback) {
57
- this.onPointerMoveOut = callback;
58
- }
59
- setOnWheel(callback) {
60
- this.onWheel = callback;
61
- }
62
- markAsInBounds(pointerId) {
63
- if (this.pointersInBounds.indexOf(pointerId) >= 0) {
64
- return;
65
- }
66
- this.pointersInBounds.push(pointerId);
67
- }
68
- markAsOutOfBounds(pointerId) {
69
- const index = this.pointersInBounds.indexOf(pointerId);
70
- if (index < 0) {
71
- return;
72
- }
73
- this.pointersInBounds.splice(index, 1);
74
- }
75
- resetManager() {
76
- // Reseting activePointersCounter is necessary to make gestures such as pinch work properly
77
- // There are gestures that end when there is still one active pointer (like pinch/rotation)
78
- // When these gestures end, they are reset, but they still receive events from pointer that is active
79
- // This causes trouble, since only onPointerDown registers gesture in orchestrator, and while gestures receive
80
- // Events from active pointer after they finished, next pointerdown event will be registered as additional pointer, not the first one
81
- // This casues trouble like gestures getting stuck in END state, even though they should have gone to UNDETERMINED
82
- this.activePointersCounter = 0;
83
- this.pointersInBounds = [];
84
- }
85
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,273 +0,0 @@
1
- import { PointerType } from '../../PointerType';
2
- import { State } from '../../State';
3
- import PointerTracker from './PointerTracker';
4
- export default class GestureHandlerOrchestrator {
5
- static _instance;
6
- gestureHandlers = [];
7
- awaitingHandlers = [];
8
- awaitingHandlersTags = new Set();
9
- handlingChangeSemaphore = 0;
10
- activationIndex = 0;
11
- // Private beacuse of Singleton
12
- // eslint-disable-next-line no-useless-constructor, @typescript-eslint/no-empty-function
13
- constructor() { }
14
- scheduleFinishedHandlersCleanup() {
15
- if (this.handlingChangeSemaphore === 0) {
16
- this.cleanupFinishedHandlers();
17
- }
18
- }
19
- cleanHandler(handler) {
20
- handler.reset();
21
- handler.active = false;
22
- handler.awaiting = false;
23
- handler.activationIndex = Number.MAX_VALUE;
24
- }
25
- removeHandlerFromOrchestrator(handler) {
26
- const indexInGestureHandlers = this.gestureHandlers.indexOf(handler);
27
- const indexInAwaitingHandlers = this.awaitingHandlers.indexOf(handler);
28
- if (indexInGestureHandlers >= 0) {
29
- this.gestureHandlers.splice(indexInGestureHandlers, 1);
30
- }
31
- if (indexInAwaitingHandlers >= 0) {
32
- this.awaitingHandlers.splice(indexInAwaitingHandlers, 1);
33
- this.awaitingHandlersTags.delete(handler.handlerTag);
34
- }
35
- }
36
- cleanupFinishedHandlers() {
37
- const handlersToRemove = new Set();
38
- for (let i = this.gestureHandlers.length - 1; i >= 0; --i) {
39
- const handler = this.gestureHandlers[i];
40
- if (this.isFinished(handler.state) && !handler.awaiting) {
41
- this.cleanHandler(handler);
42
- handlersToRemove.add(handler);
43
- }
44
- }
45
- this.gestureHandlers = this.gestureHandlers.filter((handler) => !handlersToRemove.has(handler));
46
- }
47
- hasOtherHandlerToWaitFor(handler) {
48
- const hasToWaitFor = (otherHandler) => {
49
- return (!this.isFinished(otherHandler.state) &&
50
- this.shouldHandlerWaitForOther(handler, otherHandler));
51
- };
52
- return this.gestureHandlers.some(hasToWaitFor);
53
- }
54
- shouldBeCancelledByFinishedHandler(handler) {
55
- const shouldBeCancelled = (otherHandler) => {
56
- return (this.shouldHandlerWaitForOther(handler, otherHandler) &&
57
- otherHandler.state === State.END);
58
- };
59
- return this.gestureHandlers.some(shouldBeCancelled);
60
- }
61
- tryActivate(handler) {
62
- if (this.shouldBeCancelledByFinishedHandler(handler)) {
63
- handler.cancel();
64
- return;
65
- }
66
- if (this.hasOtherHandlerToWaitFor(handler)) {
67
- this.addAwaitingHandler(handler);
68
- return;
69
- }
70
- const handlerState = handler.state;
71
- if (handlerState === State.CANCELLED || handlerState === State.FAILED) {
72
- return;
73
- }
74
- if (this.shouldActivate(handler)) {
75
- this.makeActive(handler);
76
- return;
77
- }
78
- if (handlerState === State.ACTIVE) {
79
- handler.fail();
80
- return;
81
- }
82
- if (handlerState === State.BEGAN) {
83
- handler.cancel();
84
- }
85
- }
86
- shouldActivate(handler) {
87
- const shouldBeCancelledBy = (otherHandler) => {
88
- return this.shouldHandlerBeCancelledBy(handler, otherHandler);
89
- };
90
- return !this.gestureHandlers.some(shouldBeCancelledBy);
91
- }
92
- cleanupAwaitingHandlers(handler) {
93
- const shouldWait = (otherHandler) => {
94
- return (!otherHandler.awaiting &&
95
- this.shouldHandlerWaitForOther(otherHandler, handler));
96
- };
97
- for (const otherHandler of this.awaitingHandlers) {
98
- if (shouldWait(otherHandler)) {
99
- this.cleanHandler(otherHandler);
100
- this.awaitingHandlersTags.delete(otherHandler.handlerTag);
101
- }
102
- }
103
- this.awaitingHandlers = this.awaitingHandlers.filter((otherHandler) => this.awaitingHandlersTags.has(otherHandler.handlerTag));
104
- }
105
- onHandlerStateChange(handler, newState, oldState, sendIfDisabled) {
106
- if (!handler.enabled && !sendIfDisabled) {
107
- return;
108
- }
109
- this.handlingChangeSemaphore += 1;
110
- if (this.isFinished(newState)) {
111
- for (const otherHandler of this.awaitingHandlers) {
112
- if (!this.shouldHandlerWaitForOther(otherHandler, handler) ||
113
- !this.awaitingHandlersTags.has(otherHandler.handlerTag)) {
114
- continue;
115
- }
116
- if (newState !== State.END) {
117
- this.tryActivate(otherHandler);
118
- continue;
119
- }
120
- otherHandler.cancel();
121
- if (otherHandler.state === State.END) {
122
- // Handle edge case, where discrete gestures end immediately after activation thus
123
- // their state is set to END and when the gesture they are waiting for activates they
124
- // should be cancelled, however `cancel` was never sent as gestures were already in the END state.
125
- // Send synthetic BEGAN -> CANCELLED to properly handle JS logic
126
- otherHandler.sendEvent(State.CANCELLED, State.BEGAN);
127
- }
128
- otherHandler.awaiting = false;
129
- }
130
- }
131
- if (newState === State.ACTIVE) {
132
- this.tryActivate(handler);
133
- }
134
- else if (oldState === State.ACTIVE || oldState === State.END) {
135
- if (handler.active) {
136
- handler.sendEvent(newState, oldState);
137
- }
138
- else if (oldState === State.ACTIVE &&
139
- (newState === State.CANCELLED || newState === State.FAILED)) {
140
- handler.sendEvent(newState, State.BEGAN);
141
- }
142
- }
143
- else if (oldState !== State.UNDETERMINED ||
144
- newState !== State.CANCELLED) {
145
- handler.sendEvent(newState, oldState);
146
- }
147
- this.handlingChangeSemaphore -= 1;
148
- this.scheduleFinishedHandlersCleanup();
149
- if (!this.awaitingHandlers.includes(handler)) {
150
- this.cleanupAwaitingHandlers(handler);
151
- }
152
- }
153
- makeActive(handler) {
154
- const currentState = handler.state;
155
- handler.active = true;
156
- handler.shouldResetProgress = true;
157
- handler.activationIndex = this.activationIndex++;
158
- for (let i = this.gestureHandlers.length - 1; i >= 0; --i) {
159
- if (this.shouldHandlerBeCancelledBy(this.gestureHandlers[i], handler)) {
160
- this.gestureHandlers[i].cancel();
161
- }
162
- }
163
- for (const otherHandler of this.awaitingHandlers) {
164
- if (this.shouldHandlerBeCancelledBy(otherHandler, handler)) {
165
- otherHandler.awaiting = false;
166
- }
167
- }
168
- handler.sendEvent(State.ACTIVE, State.BEGAN);
169
- if (currentState !== State.ACTIVE) {
170
- handler.sendEvent(State.END, State.ACTIVE);
171
- if (currentState !== State.END) {
172
- handler.sendEvent(State.UNDETERMINED, State.END);
173
- }
174
- }
175
- if (!handler.awaiting) {
176
- return;
177
- }
178
- handler.awaiting = false;
179
- this.awaitingHandlers = this.awaitingHandlers.filter((otherHandler) => otherHandler !== handler);
180
- }
181
- addAwaitingHandler(handler) {
182
- if (this.awaitingHandlers.includes(handler)) {
183
- return;
184
- }
185
- this.awaitingHandlers.push(handler);
186
- this.awaitingHandlersTags.add(handler.handlerTag);
187
- handler.awaiting = true;
188
- handler.activationIndex = this.activationIndex++;
189
- }
190
- recordHandlerIfNotPresent(handler) {
191
- if (this.gestureHandlers.includes(handler)) {
192
- return;
193
- }
194
- this.gestureHandlers.push(handler);
195
- handler.active = false;
196
- handler.awaiting = false;
197
- handler.activationIndex = Number.MAX_SAFE_INTEGER;
198
- }
199
- shouldHandlerWaitForOther(handler, otherHandler) {
200
- return (handler !== otherHandler &&
201
- (handler.shouldWaitForHandlerFailure(otherHandler) ||
202
- otherHandler.shouldRequireToWaitForFailure(handler)));
203
- }
204
- canRunSimultaneously(gh1, gh2) {
205
- return (gh1 === gh2 ||
206
- gh1.shouldRecognizeSimultaneously(gh2) ||
207
- gh2.shouldRecognizeSimultaneously(gh1));
208
- }
209
- shouldHandlerBeCancelledBy(handler, otherHandler) {
210
- if (this.canRunSimultaneously(handler, otherHandler)) {
211
- return false;
212
- }
213
- if (handler.awaiting || handler.state === State.ACTIVE) {
214
- return handler.shouldBeCancelledByOther(otherHandler);
215
- }
216
- const handlerPointers = handler.getTrackedPointersID();
217
- const otherPointers = otherHandler.getTrackedPointersID();
218
- if (!PointerTracker.shareCommonPointers(handlerPointers, otherPointers) &&
219
- handler.delegate.view !== otherHandler.delegate.view) {
220
- return this.checkOverlap(handler, otherHandler);
221
- }
222
- return true;
223
- }
224
- checkOverlap(handler, otherHandler) {
225
- // If handlers don't have common pointers, default return value is false.
226
- // However, if at least on pointer overlaps with both handlers, we return true
227
- // This solves issue in overlapping parents example
228
- // TODO: Find better way to handle that issue, for example by activation order and handler cancelling
229
- const isPointerWithinBothBounds = (pointer) => {
230
- const point = handler.tracker.getLastAbsoluteCoords(pointer);
231
- return (point &&
232
- handler.delegate.isPointerInBounds(point) &&
233
- otherHandler.delegate.isPointerInBounds(point));
234
- };
235
- return handler.getTrackedPointersID().some(isPointerWithinBothBounds);
236
- }
237
- isFinished(state) {
238
- return (state === State.END || state === State.FAILED || state === State.CANCELLED);
239
- }
240
- // This function is called when handler receives touchdown event
241
- // If handler is using mouse or pen as a pointer and any handler receives touch event,
242
- // mouse/pen event dissappears - it doesn't send onPointerCancel nor onPointerUp (and others)
243
- // This became a problem because handler was left at active state without any signal to end or fail
244
- // To handle this, when new touch event is received, we loop through active handlers and check which type of
245
- // pointer they're using. If there are any handler with mouse/pen as a pointer, we cancel them
246
- cancelMouseAndPenGestures(currentHandler) {
247
- this.gestureHandlers.forEach((handler) => {
248
- if (handler.pointerType !== PointerType.MOUSE &&
249
- handler.pointerType !== PointerType.STYLUS) {
250
- return;
251
- }
252
- if (handler !== currentHandler) {
253
- handler.cancel();
254
- }
255
- else {
256
- // Handler that received touch event should have its pointer tracker reset
257
- // This allows handler to smoothly change from mouse/pen to touch
258
- // The drawback is, that when we try to use mouse/pen one more time, it doesn't send onPointerDown at the first time
259
- // so it is required to click two times to get handler to work
260
- //
261
- // However, handler will receive manually created onPointerEnter that is triggered in EventManager in onPointerMove method.
262
- // There may be possibility to use that fact to make handler respond properly to first mouse click
263
- handler.tracker.resetTracker();
264
- }
265
- });
266
- }
267
- static get instance() {
268
- if (!GestureHandlerOrchestrator._instance) {
269
- GestureHandlerOrchestrator._instance = new GestureHandlerOrchestrator();
270
- }
271
- return GestureHandlerOrchestrator._instance;
272
- }
273
- }