react-native-gesture-handler 2.16.0-rc.0 → 2.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (399) hide show
  1. package/README.md +1 -0
  2. package/android/noreanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt +2 -0
  3. package/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java +9 -0
  4. package/android/paper/src/main/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerInterface.java +3 -0
  5. package/android/src/main/java/com/swmansion/gesturehandler/RNGestureHandlerPackage.kt +2 -2
  6. package/android/src/main/java/com/swmansion/gesturehandler/core/DiagonalDirections.kt +8 -0
  7. package/android/src/main/java/com/swmansion/gesturehandler/core/FlingGestureHandler.kt +61 -24
  8. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt +17 -22
  9. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +30 -11
  10. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureUtils.kt +3 -0
  11. package/android/src/main/java/com/swmansion/gesturehandler/core/Vector.kt +66 -0
  12. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +119 -19
  13. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.kt +2 -2
  14. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.kt +1 -4
  15. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +4 -2
  16. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt +1 -1
  17. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.kt +1 -4
  18. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerTouchEvent.kt +4 -7
  19. package/apple/Handlers/RNLongPressHandler.m +5 -13
  20. package/apple/Handlers/RNPinchHandler.m +12 -1
  21. package/apple/RNGestureHandler.m +3 -1
  22. package/lib/commonjs/Directions.js +19 -6
  23. package/lib/commonjs/Directions.js.map +1 -1
  24. package/lib/commonjs/RNGestureHandlerModule.js +97 -4
  25. package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
  26. package/lib/commonjs/RNGestureHandlerModule.native.js +16 -0
  27. package/lib/commonjs/RNGestureHandlerModule.native.js.map +1 -0
  28. package/lib/commonjs/RNRenderer.js +5 -10
  29. package/lib/commonjs/RNRenderer.js.map +1 -1
  30. package/lib/commonjs/RNRenderer.native.js +16 -0
  31. package/lib/commonjs/RNRenderer.native.js.map +1 -0
  32. package/lib/commonjs/components/DrawerLayout.js.map +1 -1
  33. package/lib/commonjs/components/GestureComponents.js +19 -82
  34. package/lib/commonjs/components/GestureComponents.js.map +1 -1
  35. package/lib/commonjs/components/GestureComponents.native.js +115 -0
  36. package/lib/commonjs/components/GestureComponents.native.js.map +1 -0
  37. package/lib/commonjs/components/GestureHandlerButton.js +13 -3
  38. package/lib/commonjs/components/GestureHandlerButton.js.map +1 -1
  39. package/lib/commonjs/components/GestureHandlerButton.native.js +14 -0
  40. package/lib/commonjs/components/GestureHandlerButton.native.js.map +1 -0
  41. package/lib/commonjs/components/GestureHandlerRootView.js +0 -6
  42. package/lib/commonjs/components/GestureHandlerRootView.js.map +1 -1
  43. package/lib/commonjs/components/{GestureHandlerRootView.web.js → GestureHandlerRootView.native.js} +7 -1
  44. package/lib/commonjs/components/GestureHandlerRootView.native.js.map +1 -0
  45. package/lib/commonjs/components/Swipeable.js +3 -1
  46. package/lib/commonjs/components/Swipeable.js.map +1 -1
  47. package/lib/commonjs/components/touchables/GenericTouchable.js +1 -0
  48. package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -1
  49. package/lib/commonjs/getReactNativeVersion.js +1 -12
  50. package/lib/commonjs/getReactNativeVersion.js.map +1 -1
  51. package/lib/commonjs/getReactNativeVersion.native.js +22 -0
  52. package/lib/commonjs/getReactNativeVersion.native.js.map +1 -0
  53. package/lib/commonjs/getShadowNodeFromRef.js +5 -34
  54. package/lib/commonjs/getShadowNodeFromRef.js.map +1 -1
  55. package/lib/commonjs/getShadowNodeFromRef.native.js +44 -0
  56. package/lib/commonjs/getShadowNodeFromRef.native.js.map +1 -0
  57. package/lib/commonjs/handlers/PanGestureHandler.js.map +1 -1
  58. package/lib/commonjs/handlers/PressabilityDebugView.js +5 -7
  59. package/lib/commonjs/handlers/PressabilityDebugView.js.map +1 -1
  60. package/lib/commonjs/handlers/PressabilityDebugView.native.js +14 -0
  61. package/lib/commonjs/handlers/PressabilityDebugView.native.js.map +1 -0
  62. package/lib/commonjs/handlers/createHandler.js +11 -5
  63. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  64. package/lib/commonjs/handlers/customDirectEventTypes.js +11 -0
  65. package/lib/commonjs/handlers/customDirectEventTypes.js.map +1 -0
  66. package/lib/commonjs/handlers/customDirectEventTypes.native.js +14 -0
  67. package/lib/commonjs/handlers/customDirectEventTypes.native.js.map +1 -0
  68. package/lib/commonjs/handlers/gestureHandlerCommon.js +13 -2
  69. package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
  70. package/lib/commonjs/handlers/gestures/GestureDetector.js +25 -0
  71. package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
  72. package/lib/commonjs/handlers/gestures/flingGesture.js +13 -0
  73. package/lib/commonjs/handlers/gestures/flingGesture.js.map +1 -1
  74. package/lib/commonjs/handlers/gestures/forceTouchGesture.js +17 -0
  75. package/lib/commonjs/handlers/gestures/forceTouchGesture.js.map +1 -1
  76. package/lib/commonjs/handlers/gestures/gesture.js +135 -0
  77. package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
  78. package/lib/commonjs/handlers/gestures/gestureObjects.js +66 -0
  79. package/lib/commonjs/handlers/gestures/gestureObjects.js.map +1 -1
  80. package/lib/commonjs/handlers/gestures/gestureStateManager.web.js +1 -1
  81. package/lib/commonjs/handlers/gestures/gestureStateManager.web.js.map +1 -1
  82. package/lib/commonjs/handlers/gestures/hoverGesture.js +1 -1
  83. package/lib/commonjs/handlers/gestures/hoverGesture.js.map +1 -1
  84. package/lib/commonjs/handlers/gestures/longPressGesture.js +12 -0
  85. package/lib/commonjs/handlers/gestures/longPressGesture.js.map +1 -1
  86. package/lib/commonjs/handlers/gestures/nativeGesture.js +10 -0
  87. package/lib/commonjs/handlers/gestures/nativeGesture.js.map +1 -1
  88. package/lib/commonjs/handlers/gestures/panGesture.js +76 -0
  89. package/lib/commonjs/handlers/gestures/panGesture.js.map +1 -1
  90. package/lib/commonjs/handlers/gestures/tapGesture.js +42 -0
  91. package/lib/commonjs/handlers/gestures/tapGesture.js.map +1 -1
  92. package/lib/commonjs/index.js +8 -8
  93. package/lib/commonjs/index.js.map +1 -1
  94. package/lib/commonjs/mocks.js +2 -0
  95. package/lib/commonjs/mocks.js.map +1 -1
  96. package/lib/commonjs/specs/RNGestureHandlerButtonNativeComponent.js.map +1 -1
  97. package/lib/commonjs/utils.js +5 -1
  98. package/lib/commonjs/utils.js.map +1 -1
  99. package/lib/commonjs/web/Gestures.js +66 -0
  100. package/lib/commonjs/web/Gestures.js.map +1 -0
  101. package/lib/commonjs/web/constants.js +3 -8
  102. package/lib/commonjs/web/constants.js.map +1 -1
  103. package/lib/commonjs/web/handlers/FlingGestureHandler.js +36 -12
  104. package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
  105. package/lib/commonjs/web/handlers/GestureHandler.js +11 -9
  106. package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
  107. package/lib/commonjs/web/handlers/IGestureHandler.js +2 -0
  108. package/lib/commonjs/web/handlers/IGestureHandler.js.map +1 -0
  109. package/lib/commonjs/web/handlers/NativeViewGestureHandler.js +5 -6
  110. package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -1
  111. package/lib/commonjs/web/handlers/PanGestureHandler.js +3 -1
  112. package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
  113. package/lib/commonjs/web/interfaces.js +1 -13
  114. package/lib/commonjs/web/interfaces.js.map +1 -1
  115. package/lib/commonjs/web/tools/EventManager.js.map +1 -1
  116. package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js +114 -115
  117. package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js.map +1 -1
  118. package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js +10 -5
  119. package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js.map +1 -1
  120. package/lib/commonjs/web/tools/InteractionManager.js +12 -3
  121. package/lib/commonjs/web/tools/InteractionManager.js.map +1 -1
  122. package/lib/commonjs/web/tools/NodeManager.js.map +1 -1
  123. package/lib/commonjs/web/tools/PointerEventManager.js +55 -27
  124. package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
  125. package/lib/commonjs/web/tools/TouchEventManager.js +26 -5
  126. package/lib/commonjs/web/tools/TouchEventManager.js.map +1 -1
  127. package/lib/commonjs/web/tools/Vector.js +58 -0
  128. package/lib/commonjs/web/tools/Vector.js.map +1 -0
  129. package/lib/commonjs/web/utils.js +9 -1
  130. package/lib/commonjs/web/utils.js.map +1 -1
  131. package/lib/commonjs/web_hammer/NodeManager.js.map +1 -1
  132. package/lib/module/Directions.js +16 -4
  133. package/lib/module/Directions.js.map +1 -1
  134. package/lib/module/RNGestureHandlerModule.js +84 -4
  135. package/lib/module/RNGestureHandlerModule.js.map +1 -1
  136. package/lib/module/RNGestureHandlerModule.native.js +5 -0
  137. package/lib/module/RNGestureHandlerModule.native.js.map +1 -0
  138. package/lib/module/RNRenderer.js +3 -3
  139. package/lib/module/RNRenderer.js.map +1 -1
  140. package/lib/module/RNRenderer.native.js +4 -0
  141. package/lib/module/RNRenderer.native.js.map +1 -0
  142. package/lib/module/components/DrawerLayout.js.map +1 -1
  143. package/lib/module/components/GestureComponents.js +18 -80
  144. package/lib/module/components/GestureComponents.js.map +1 -1
  145. package/lib/module/components/GestureComponents.native.js +90 -0
  146. package/lib/module/components/GestureComponents.native.js.map +1 -0
  147. package/lib/module/components/GestureHandlerButton.js +8 -2
  148. package/lib/module/components/GestureHandlerButton.js.map +1 -1
  149. package/lib/module/components/GestureHandlerButton.native.js +3 -0
  150. package/lib/module/components/GestureHandlerButton.native.js.map +1 -0
  151. package/lib/module/components/GestureHandlerRootView.js +0 -5
  152. package/lib/module/components/GestureHandlerRootView.js.map +1 -1
  153. package/lib/module/components/{GestureHandlerRootView.web.js → GestureHandlerRootView.native.js} +6 -1
  154. package/lib/module/components/GestureHandlerRootView.native.js.map +1 -0
  155. package/lib/module/components/Swipeable.js +3 -1
  156. package/lib/module/components/Swipeable.js.map +1 -1
  157. package/lib/module/components/touchables/GenericTouchable.js +1 -0
  158. package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
  159. package/lib/module/getReactNativeVersion.js +1 -7
  160. package/lib/module/getReactNativeVersion.js.map +1 -1
  161. package/lib/module/getReactNativeVersion.native.js +10 -0
  162. package/lib/module/getReactNativeVersion.native.js.map +1 -0
  163. package/lib/module/getShadowNodeFromRef.js +4 -33
  164. package/lib/module/getShadowNodeFromRef.js.map +1 -1
  165. package/lib/module/getShadowNodeFromRef.native.js +37 -0
  166. package/lib/module/getShadowNodeFromRef.native.js.map +1 -0
  167. package/lib/module/handlers/PanGestureHandler.js.map +1 -1
  168. package/lib/module/handlers/PressabilityDebugView.js +4 -2
  169. package/lib/module/handlers/PressabilityDebugView.js.map +1 -1
  170. package/lib/module/handlers/PressabilityDebugView.native.js +3 -0
  171. package/lib/module/handlers/PressabilityDebugView.native.js.map +1 -0
  172. package/lib/module/handlers/createHandler.js +11 -6
  173. package/lib/module/handlers/createHandler.js.map +1 -1
  174. package/lib/module/handlers/customDirectEventTypes.js +5 -0
  175. package/lib/module/handlers/customDirectEventTypes.js.map +1 -0
  176. package/lib/module/handlers/customDirectEventTypes.native.js +3 -0
  177. package/lib/module/handlers/customDirectEventTypes.native.js.map +1 -0
  178. package/lib/module/handlers/gestureHandlerCommon.js +11 -1
  179. package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
  180. package/lib/module/handlers/gestures/GestureDetector.js +25 -0
  181. package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
  182. package/lib/module/handlers/gestures/flingGesture.js +13 -0
  183. package/lib/module/handlers/gestures/flingGesture.js.map +1 -1
  184. package/lib/module/handlers/gestures/forceTouchGesture.js +17 -0
  185. package/lib/module/handlers/gestures/forceTouchGesture.js.map +1 -1
  186. package/lib/module/handlers/gestures/gesture.js +135 -0
  187. package/lib/module/handlers/gestures/gesture.js.map +1 -1
  188. package/lib/module/handlers/gestures/gestureObjects.js +67 -0
  189. package/lib/module/handlers/gestures/gestureObjects.js.map +1 -1
  190. package/lib/module/handlers/gestures/gestureStateManager.web.js +1 -1
  191. package/lib/module/handlers/gestures/gestureStateManager.web.js.map +1 -1
  192. package/lib/module/handlers/gestures/hoverGesture.js +1 -1
  193. package/lib/module/handlers/gestures/hoverGesture.js.map +1 -1
  194. package/lib/module/handlers/gestures/longPressGesture.js +12 -0
  195. package/lib/module/handlers/gestures/longPressGesture.js.map +1 -1
  196. package/lib/module/handlers/gestures/nativeGesture.js +10 -0
  197. package/lib/module/handlers/gestures/nativeGesture.js.map +1 -1
  198. package/lib/module/handlers/gestures/panGesture.js +76 -0
  199. package/lib/module/handlers/gestures/panGesture.js.map +1 -1
  200. package/lib/module/handlers/gestures/tapGesture.js +42 -0
  201. package/lib/module/handlers/gestures/tapGesture.js.map +1 -1
  202. package/lib/module/index.js +1 -1
  203. package/lib/module/index.js.map +1 -1
  204. package/lib/module/mocks.js +2 -0
  205. package/lib/module/mocks.js.map +1 -1
  206. package/lib/module/specs/RNGestureHandlerButtonNativeComponent.js.map +1 -1
  207. package/lib/module/utils.js +5 -1
  208. package/lib/module/utils.js.map +1 -1
  209. package/lib/module/web/Gestures.js +39 -0
  210. package/lib/module/web/Gestures.js.map +1 -0
  211. package/lib/module/web/constants.js +1 -6
  212. package/lib/module/web/constants.js.map +1 -1
  213. package/lib/module/web/handlers/FlingGestureHandler.js +34 -12
  214. package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
  215. package/lib/module/web/handlers/GestureHandler.js +10 -9
  216. package/lib/module/web/handlers/GestureHandler.js.map +1 -1
  217. package/lib/module/web/handlers/IGestureHandler.js +2 -0
  218. package/lib/module/web/handlers/IGestureHandler.js.map +1 -0
  219. package/lib/module/web/handlers/NativeViewGestureHandler.js +5 -6
  220. package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
  221. package/lib/module/web/handlers/PanGestureHandler.js +3 -1
  222. package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
  223. package/lib/module/web/interfaces.js +0 -11
  224. package/lib/module/web/interfaces.js.map +1 -1
  225. package/lib/module/web/tools/EventManager.js.map +1 -1
  226. package/lib/module/web/tools/GestureHandlerOrchestrator.js +114 -115
  227. package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
  228. package/lib/module/web/tools/GestureHandlerWebDelegate.js +9 -4
  229. package/lib/module/web/tools/GestureHandlerWebDelegate.js.map +1 -1
  230. package/lib/module/web/tools/InteractionManager.js +9 -3
  231. package/lib/module/web/tools/InteractionManager.js.map +1 -1
  232. package/lib/module/web/tools/NodeManager.js.map +1 -1
  233. package/lib/module/web/tools/PointerEventManager.js +53 -26
  234. package/lib/module/web/tools/PointerEventManager.js.map +1 -1
  235. package/lib/module/web/tools/TouchEventManager.js +26 -5
  236. package/lib/module/web/tools/TouchEventManager.js.map +1 -1
  237. package/lib/module/web/tools/Vector.js +47 -0
  238. package/lib/module/web/tools/Vector.js.map +1 -0
  239. package/lib/module/web/utils.js +2 -0
  240. package/lib/module/web/utils.js.map +1 -1
  241. package/lib/module/web_hammer/NodeManager.js.map +1 -1
  242. package/lib/typescript/Directions.d.ts +7 -0
  243. package/lib/typescript/RNGestureHandlerModule.d.ts +15 -2
  244. package/lib/typescript/RNGestureHandlerModule.native.d.ts +2 -0
  245. package/lib/typescript/RNRenderer.d.ts +3 -1
  246. package/lib/typescript/RNRenderer.native.d.ts +1 -0
  247. package/lib/typescript/components/DrawerLayout.d.ts +1 -2
  248. package/lib/typescript/components/GestureComponents.d.ts +7 -21
  249. package/lib/typescript/components/GestureComponents.native.d.ts +22 -0
  250. package/lib/typescript/components/GestureHandlerButton.d.ts +3 -3
  251. package/lib/typescript/components/GestureHandlerButton.native.d.ts +4 -0
  252. package/lib/typescript/components/touchables/GenericTouchable.d.ts +2 -1
  253. package/lib/typescript/getReactNativeVersion.d.ts +1 -4
  254. package/lib/typescript/getReactNativeVersion.native.d.ts +4 -0
  255. package/lib/typescript/getShadowNodeFromRef.d.ts +1 -1
  256. package/lib/typescript/getShadowNodeFromRef.native.d.ts +1 -0
  257. package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +1 -1
  258. package/lib/typescript/handlers/PanGestureHandler.d.ts +4 -4
  259. package/lib/typescript/handlers/PressabilityDebugView.d.ts +1 -1
  260. package/lib/typescript/handlers/PressabilityDebugView.native.d.ts +1 -0
  261. package/lib/typescript/handlers/customDirectEventTypes.d.ts +2 -0
  262. package/lib/typescript/handlers/customDirectEventTypes.native.d.ts +1 -0
  263. package/lib/typescript/handlers/gestureHandlerCommon.d.ts +11 -2
  264. package/lib/typescript/handlers/gestures/GestureDetector.d.ts +38 -1
  265. package/lib/typescript/handlers/gestures/flingGesture.d.ts +11 -0
  266. package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +14 -0
  267. package/lib/typescript/handlers/gestures/gesture.d.ts +114 -2
  268. package/lib/typescript/handlers/gestures/gestureObjects.d.ts +57 -0
  269. package/lib/typescript/handlers/gestures/hoverGesture.d.ts +1 -1
  270. package/lib/typescript/handlers/gestures/longPressGesture.d.ts +10 -0
  271. package/lib/typescript/handlers/gestures/nativeGesture.d.ts +8 -0
  272. package/lib/typescript/handlers/gestures/panGesture.d.ts +67 -4
  273. package/lib/typescript/handlers/gestures/tapGesture.d.ts +35 -0
  274. package/lib/typescript/index.d.ts +1 -1
  275. package/lib/typescript/mocks.d.ts +1 -0
  276. package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts +4 -1
  277. package/lib/typescript/web/Gestures.d.ts +36 -0
  278. package/lib/typescript/web/constants.d.ts +1 -6
  279. package/lib/typescript/web/handlers/FlingGestureHandler.d.ts +3 -3
  280. package/lib/typescript/web/handlers/GestureHandler.d.ts +13 -11
  281. package/lib/typescript/web/handlers/IGestureHandler.d.ts +38 -0
  282. package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +1 -0
  283. package/lib/typescript/web/interfaces.d.ts +8 -10
  284. package/lib/typescript/web/tools/EventManager.d.ts +15 -12
  285. package/lib/typescript/web/tools/GestureHandlerDelegate.d.ts +3 -4
  286. package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts +7 -5
  287. package/lib/typescript/web/tools/GestureHandlerWebDelegate.d.ts +3 -3
  288. package/lib/typescript/web/tools/InteractionManager.d.ts +6 -6
  289. package/lib/typescript/web/tools/NodeManager.d.ts +4 -3
  290. package/lib/typescript/web/tools/PointerEventManager.d.ts +11 -2
  291. package/lib/typescript/web/tools/TouchEventManager.d.ts +6 -1
  292. package/lib/typescript/web/tools/Vector.d.ts +15 -0
  293. package/lib/typescript/web/utils.d.ts +4 -4
  294. package/lib/typescript/web_hammer/NodeManager.d.ts +1 -1
  295. package/package.json +4 -2
  296. package/src/Directions.ts +21 -4
  297. package/src/RNGestureHandlerModule.native.ts +5 -0
  298. package/src/RNGestureHandlerModule.ts +104 -4
  299. package/src/RNRenderer.native.ts +3 -0
  300. package/src/RNRenderer.ts +3 -3
  301. package/src/components/DrawerLayout.tsx +1 -1
  302. package/src/components/GestureComponents.native.tsx +148 -0
  303. package/src/components/GestureComponents.tsx +24 -131
  304. package/src/components/GestureHandlerButton.native.tsx +5 -0
  305. package/src/components/GestureHandlerButton.tsx +5 -4
  306. package/src/components/{GestureHandlerRootView.web.tsx → GestureHandlerRootView.native.tsx} +6 -0
  307. package/src/components/GestureHandlerRootView.tsx +0 -6
  308. package/src/components/Swipeable.tsx +2 -0
  309. package/src/components/touchables/GenericTouchable.tsx +3 -0
  310. package/src/getReactNativeVersion.native.ts +11 -0
  311. package/src/getReactNativeVersion.ts +1 -9
  312. package/src/getShadowNodeFromRef.native.ts +44 -0
  313. package/src/getShadowNodeFromRef.ts +4 -41
  314. package/src/handlers/PanGestureHandler.ts +8 -4
  315. package/src/handlers/PressabilityDebugView.native.tsx +2 -0
  316. package/src/handlers/PressabilityDebugView.tsx +4 -2
  317. package/src/handlers/createHandler.tsx +24 -14
  318. package/src/handlers/customDirectEventTypes.native.ts +2 -0
  319. package/src/handlers/customDirectEventTypes.ts +5 -0
  320. package/src/handlers/gestureHandlerCommon.ts +28 -1
  321. package/src/handlers/gestures/GestureDetector.tsx +62 -4
  322. package/src/handlers/gestures/flingGesture.ts +11 -0
  323. package/src/handlers/gestures/forceTouchGesture.ts +14 -0
  324. package/src/handlers/gestures/gesture.ts +114 -1
  325. package/src/handlers/gestures/gestureObjects.ts +57 -0
  326. package/src/handlers/gestures/gestureStateManager.web.ts +1 -1
  327. package/src/handlers/gestures/hoverGesture.ts +1 -1
  328. package/src/handlers/gestures/longPressGesture.ts +10 -0
  329. package/src/handlers/gestures/nativeGesture.ts +8 -0
  330. package/src/handlers/gestures/panGesture.ts +75 -4
  331. package/src/handlers/gestures/tapGesture.ts +35 -0
  332. package/src/index.ts +1 -1
  333. package/src/mocks.ts +2 -0
  334. package/src/specs/RNGestureHandlerButtonNativeComponent.ts +4 -0
  335. package/src/utils.ts +9 -2
  336. package/src/web/Gestures.ts +41 -0
  337. package/src/web/constants.ts +1 -7
  338. package/src/web/handlers/FlingGestureHandler.ts +54 -24
  339. package/src/web/handlers/GestureHandler.ts +23 -19
  340. package/src/web/handlers/IGestureHandler.ts +50 -0
  341. package/src/web/handlers/NativeViewGestureHandler.ts +5 -6
  342. package/src/web/handlers/PanGestureHandler.ts +4 -0
  343. package/src/web/interfaces.ts +14 -10
  344. package/src/web/tools/EventManager.ts +16 -14
  345. package/src/web/tools/GestureHandlerDelegate.ts +3 -4
  346. package/src/web/tools/GestureHandlerOrchestrator.ts +160 -145
  347. package/src/web/tools/GestureHandlerWebDelegate.ts +14 -9
  348. package/src/web/tools/InteractionManager.ts +18 -12
  349. package/src/web/tools/NodeManager.ts +4 -3
  350. package/src/web/tools/PointerEventManager.ts +181 -166
  351. package/src/web/tools/TouchEventManager.ts +126 -114
  352. package/src/web/tools/Vector.ts +60 -0
  353. package/src/web/utils.ts +7 -4
  354. package/src/web_hammer/NodeManager.ts +1 -1
  355. package/lib/commonjs/RNGestureHandlerModule.web.js +0 -163
  356. package/lib/commonjs/RNGestureHandlerModule.web.js.map +0 -1
  357. package/lib/commonjs/RNRenderer.web.js +0 -11
  358. package/lib/commonjs/RNRenderer.web.js.map +0 -1
  359. package/lib/commonjs/components/GestureComponents.web.js +0 -52
  360. package/lib/commonjs/components/GestureComponents.web.js.map +0 -1
  361. package/lib/commonjs/components/GestureHandlerButton.web.js +0 -24
  362. package/lib/commonjs/components/GestureHandlerButton.web.js.map +0 -1
  363. package/lib/commonjs/components/GestureHandlerRootView.web.js.map +0 -1
  364. package/lib/commonjs/getReactNativeVersion.web.js +0 -11
  365. package/lib/commonjs/getReactNativeVersion.web.js.map +0 -1
  366. package/lib/commonjs/getShadowNodeFromRef.web.js +0 -15
  367. package/lib/commonjs/getShadowNodeFromRef.web.js.map +0 -1
  368. package/lib/commonjs/handlers/PressabilityDebugView.web.js +0 -12
  369. package/lib/commonjs/handlers/PressabilityDebugView.web.js.map +0 -1
  370. package/lib/module/RNGestureHandlerModule.web.js +0 -122
  371. package/lib/module/RNGestureHandlerModule.web.js.map +0 -1
  372. package/lib/module/RNRenderer.web.js +0 -4
  373. package/lib/module/RNRenderer.web.js.map +0 -1
  374. package/lib/module/components/GestureComponents.web.js +0 -28
  375. package/lib/module/components/GestureComponents.web.js.map +0 -1
  376. package/lib/module/components/GestureHandlerButton.web.js +0 -9
  377. package/lib/module/components/GestureHandlerButton.web.js.map +0 -1
  378. package/lib/module/components/GestureHandlerRootView.web.js.map +0 -1
  379. package/lib/module/getReactNativeVersion.web.js +0 -4
  380. package/lib/module/getReactNativeVersion.web.js.map +0 -1
  381. package/lib/module/getShadowNodeFromRef.web.js +0 -8
  382. package/lib/module/getShadowNodeFromRef.web.js.map +0 -1
  383. package/lib/module/handlers/PressabilityDebugView.web.js +0 -5
  384. package/lib/module/handlers/PressabilityDebugView.web.js.map +0 -1
  385. package/lib/typescript/RNGestureHandlerModule.web.d.ts +0 -50
  386. package/lib/typescript/RNRenderer.web.d.ts +0 -3
  387. package/lib/typescript/components/GestureComponents.web.d.ts +0 -8
  388. package/lib/typescript/components/GestureHandlerButton.web.d.ts +0 -4
  389. package/lib/typescript/getReactNativeVersion.web.d.ts +0 -1
  390. package/lib/typescript/getShadowNodeFromRef.web.d.ts +0 -1
  391. package/lib/typescript/handlers/PressabilityDebugView.web.d.ts +0 -1
  392. package/src/RNGestureHandlerModule.web.ts +0 -146
  393. package/src/RNRenderer.web.ts +0 -3
  394. package/src/components/GestureComponents.web.tsx +0 -41
  395. package/src/components/GestureHandlerButton.web.tsx +0 -6
  396. package/src/getReactNativeVersion.web.ts +0 -3
  397. package/src/getShadowNodeFromRef.web.ts +0 -7
  398. package/src/handlers/PressabilityDebugView.web.tsx +0 -4
  399. /package/lib/typescript/components/{GestureHandlerRootView.web.d.ts → GestureHandlerRootView.native.d.ts} +0 -0
@@ -23,6 +23,8 @@ class GestureHandlerOrchestrator {
23
23
 
24
24
  _defineProperty(this, "awaitingHandlers", []);
25
25
 
26
+ _defineProperty(this, "awaitingHandlersTags", new Set());
27
+
26
28
  _defineProperty(this, "handlingChangeSemaphore", 0);
27
29
 
28
30
  _defineProperty(this, "activationIndex", 0);
@@ -42,72 +44,103 @@ class GestureHandlerOrchestrator {
42
44
  }
43
45
 
44
46
  removeHandlerFromOrchestrator(handler) {
45
- this.gestureHandlers.splice(this.gestureHandlers.indexOf(handler), 1);
46
- this.awaitingHandlers.splice(this.awaitingHandlers.indexOf(handler), 1);
47
+ const indexInGestureHandlers = this.gestureHandlers.indexOf(handler);
48
+ const indexInAwaitingHandlers = this.awaitingHandlers.indexOf(handler);
49
+
50
+ if (indexInGestureHandlers >= 0) {
51
+ this.gestureHandlers.splice(indexInGestureHandlers, 1);
52
+ }
53
+
54
+ if (indexInAwaitingHandlers >= 0) {
55
+ this.awaitingHandlers.splice(indexInAwaitingHandlers, 1);
56
+ this.awaitingHandlersTags.delete(handler.getTag());
57
+ }
47
58
  }
48
59
 
49
60
  cleanupFinishedHandlers() {
61
+ const handlersToRemove = new Set();
62
+
50
63
  for (let i = this.gestureHandlers.length - 1; i >= 0; --i) {
51
64
  const handler = this.gestureHandlers[i];
52
65
 
53
- if (!handler) {
54
- continue;
55
- }
56
-
57
66
  if (this.isFinished(handler.getState()) && !handler.isAwaiting()) {
58
- this.gestureHandlers.splice(i, 1);
59
67
  this.cleanHandler(handler);
68
+ handlersToRemove.add(handler);
60
69
  }
61
70
  }
71
+
72
+ this.gestureHandlers = this.gestureHandlers.filter(handler => !handlersToRemove.has(handler));
62
73
  }
63
74
 
64
75
  hasOtherHandlerToWaitFor(handler) {
65
- let hasToWait = false;
66
- this.gestureHandlers.forEach(otherHandler => {
67
- if (otherHandler && !this.isFinished(otherHandler.getState()) && this.shouldHandlerWaitForOther(handler, otherHandler)) {
68
- hasToWait = true;
69
- return;
70
- }
71
- });
72
- return hasToWait;
76
+ const hasToWaitFor = otherHandler => {
77
+ return !this.isFinished(otherHandler.getState()) && this.shouldHandlerWaitForOther(handler, otherHandler);
78
+ };
79
+
80
+ return this.gestureHandlers.some(hasToWaitFor);
81
+ }
82
+
83
+ shouldBeCancelledByFinishedHandler(handler) {
84
+ const shouldBeCancelled = otherHandler => {
85
+ return this.shouldHandlerWaitForOther(handler, otherHandler) && otherHandler.getState() === _State.State.END;
86
+ };
87
+
88
+ return this.gestureHandlers.some(shouldBeCancelled);
73
89
  }
74
90
 
75
91
  tryActivate(handler) {
92
+ if (this.shouldBeCancelledByFinishedHandler(handler)) {
93
+ handler.cancel();
94
+ return;
95
+ }
96
+
76
97
  if (this.hasOtherHandlerToWaitFor(handler)) {
77
98
  this.addAwaitingHandler(handler);
78
- } else if (handler.getState() !== _State.State.CANCELLED && handler.getState() !== _State.State.FAILED) {
79
- if (this.shouldActivate(handler)) {
80
- this.makeActive(handler);
81
- } else {
82
- switch (handler.getState()) {
83
- case _State.State.ACTIVE:
84
- handler.fail();
85
- break;
99
+ return;
100
+ }
86
101
 
87
- case _State.State.BEGAN:
88
- handler.cancel();
89
- }
90
- }
102
+ const handlerState = handler.getState();
103
+
104
+ if (handlerState === _State.State.CANCELLED || handlerState === _State.State.FAILED) {
105
+ return;
106
+ }
107
+
108
+ if (this.shouldActivate(handler)) {
109
+ this.makeActive(handler);
110
+ return;
111
+ }
112
+
113
+ if (handlerState === _State.State.ACTIVE) {
114
+ handler.fail();
115
+ return;
116
+ }
117
+
118
+ if (handlerState === _State.State.BEGAN) {
119
+ handler.cancel();
91
120
  }
92
121
  }
93
122
 
94
123
  shouldActivate(handler) {
95
- for (const otherHandler of this.gestureHandlers) {
96
- if (this.shouldHandlerBeCancelledBy(handler, otherHandler)) {
97
- return false;
98
- }
99
- }
124
+ const shouldBeCancelledBy = otherHandler => {
125
+ return this.shouldHandlerBeCancelledBy(handler, otherHandler);
126
+ };
100
127
 
101
- return true;
128
+ return !this.gestureHandlers.some(shouldBeCancelledBy);
102
129
  }
103
130
 
104
131
  cleanupAwaitingHandlers(handler) {
105
- for (let i = 0; i < this.awaitingHandlers.length; ++i) {
106
- if (!this.awaitingHandlers[i].isAwaiting() && this.shouldHandlerWaitForOther(this.awaitingHandlers[i], handler)) {
107
- this.cleanHandler(this.awaitingHandlers[i]);
108
- this.awaitingHandlers.splice(i, 1);
132
+ const shouldWait = otherHandler => {
133
+ return !otherHandler.isAwaiting() && this.shouldHandlerWaitForOther(otherHandler, handler);
134
+ };
135
+
136
+ for (const otherHandler of this.awaitingHandlers) {
137
+ if (shouldWait(otherHandler)) {
138
+ this.cleanHandler(otherHandler);
139
+ this.awaitingHandlersTags.delete(otherHandler.getTag());
109
140
  }
110
141
  }
142
+
143
+ this.awaitingHandlers = this.awaitingHandlers.filter(otherHandler => this.awaitingHandlersTags.has(otherHandler.getTag()));
111
144
  }
112
145
 
113
146
  onHandlerStateChange(handler, newState, oldState, sendIfDisabled) {
@@ -118,25 +151,28 @@ class GestureHandlerOrchestrator {
118
151
  this.handlingChangeSemaphore += 1;
119
152
 
120
153
  if (this.isFinished(newState)) {
121
- this.awaitingHandlers.forEach(otherHandler => {
122
- if (this.shouldHandlerWaitForOther(otherHandler, handler)) {
123
- if (newState === _State.State.END) {
124
- otherHandler === null || otherHandler === void 0 ? void 0 : otherHandler.cancel();
125
-
126
- if (otherHandler.getState() === _State.State.END) {
127
- // Handle edge case, where discrete gestures end immediately after activation thus
128
- // their state is set to END and when the gesture they are waiting for activates they
129
- // should be cancelled, however `cancel` was never sent as gestures were already in the END state.
130
- // Send synthetic BEGAN -> CANCELLED to properly handle JS logic
131
- otherHandler.sendEvent(_State.State.CANCELLED, _State.State.BEGAN);
132
- }
133
-
134
- otherHandler === null || otherHandler === void 0 ? void 0 : otherHandler.setAwaiting(false);
135
- } else {
136
- this.tryActivate(otherHandler);
137
- }
154
+ for (const otherHandler of this.awaitingHandlers) {
155
+ if (!this.shouldHandlerWaitForOther(otherHandler, handler) || !this.awaitingHandlersTags.has(otherHandler.getTag())) {
156
+ continue;
157
+ }
158
+
159
+ if (newState !== _State.State.END) {
160
+ this.tryActivate(otherHandler);
161
+ continue;
162
+ }
163
+
164
+ otherHandler.cancel();
165
+
166
+ if (otherHandler.getState() === _State.State.END) {
167
+ // Handle edge case, where discrete gestures end immediately after activation thus
168
+ // their state is set to END and when the gesture they are waiting for activates they
169
+ // should be cancelled, however `cancel` was never sent as gestures were already in the END state.
170
+ // Send synthetic BEGAN -> CANCELLED to properly handle JS logic
171
+ otherHandler.sendEvent(_State.State.CANCELLED, _State.State.BEGAN);
138
172
  }
139
- });
173
+
174
+ otherHandler.setAwaiting(false);
175
+ }
140
176
  }
141
177
 
142
178
  if (newState === _State.State.ACTIVE) {
@@ -154,7 +190,7 @@ class GestureHandlerOrchestrator {
154
190
  this.handlingChangeSemaphore -= 1;
155
191
  this.scheduleFinishedHandlersCleanup();
156
192
 
157
- if (this.awaitingHandlers.indexOf(handler) < 0) {
193
+ if (!this.awaitingHandlers.includes(handler)) {
158
194
  this.cleanupAwaitingHandlers(handler);
159
195
  }
160
196
  }
@@ -171,12 +207,12 @@ class GestureHandlerOrchestrator {
171
207
  }
172
208
  }
173
209
 
174
- this.awaitingHandlers.forEach(otherHandler => {
210
+ for (const otherHandler of this.awaitingHandlers) {
175
211
  if (this.shouldHandlerBeCancelledBy(otherHandler, handler)) {
176
- otherHandler === null || otherHandler === void 0 ? void 0 : otherHandler.cancel();
177
- otherHandler === null || otherHandler === void 0 ? void 0 : otherHandler.setAwaiting(true);
212
+ otherHandler.setAwaiting(false);
178
213
  }
179
- });
214
+ }
215
+
180
216
  handler.sendEvent(_State.State.ACTIVE, _State.State.BEGAN);
181
217
 
182
218
  if (currentState !== _State.State.ACTIVE) {
@@ -187,45 +223,27 @@ class GestureHandlerOrchestrator {
187
223
  }
188
224
  }
189
225
 
190
- if (handler.isAwaiting()) {
191
- handler.setAwaiting(false);
192
-
193
- for (let i = 0; i < this.awaitingHandlers.length; ++i) {
194
- if (this.awaitingHandlers[i] === handler) {
195
- this.awaitingHandlers.splice(i, 1);
196
- }
197
- }
226
+ if (!handler.isAwaiting()) {
227
+ return;
198
228
  }
229
+
230
+ handler.setAwaiting(false);
231
+ this.awaitingHandlers = this.awaitingHandlers.filter(otherHandler => otherHandler !== handler);
199
232
  }
200
233
 
201
234
  addAwaitingHandler(handler) {
202
- let alreadyExists = false;
203
- this.awaitingHandlers.forEach(otherHandler => {
204
- if (otherHandler === handler) {
205
- alreadyExists = true;
206
- return;
207
- }
208
- });
209
-
210
- if (alreadyExists) {
235
+ if (this.awaitingHandlers.includes(handler)) {
211
236
  return;
212
237
  }
213
238
 
214
239
  this.awaitingHandlers.push(handler);
240
+ this.awaitingHandlersTags.add(handler.getTag());
215
241
  handler.setAwaiting(true);
216
242
  handler.setActivationIndex(this.activationIndex++);
217
243
  }
218
244
 
219
245
  recordHandlerIfNotPresent(handler) {
220
- let alreadyExists = false;
221
- this.gestureHandlers.forEach(otherHandler => {
222
- if (otherHandler === handler) {
223
- alreadyExists = true;
224
- return;
225
- }
226
- });
227
-
228
- if (alreadyExists) {
246
+ if (this.gestureHandlers.includes(handler)) {
229
247
  return;
230
248
  }
231
249
 
@@ -248,7 +266,7 @@ class GestureHandlerOrchestrator {
248
266
  return false;
249
267
  }
250
268
 
251
- if (handler !== otherHandler && (handler.isAwaiting() || handler.getState() === _State.State.ACTIVE)) {
269
+ if (handler.isAwaiting() || handler.getState() === _State.State.ACTIVE) {
252
270
  // For now it always returns false
253
271
  return handler.shouldBeCancelledByOther(otherHandler);
254
272
  }
@@ -268,38 +286,19 @@ class GestureHandlerOrchestrator {
268
286
  // However, if at least on pointer overlaps with both handlers, we return true
269
287
  // This solves issue in overlapping parents example
270
288
  // TODO: Find better way to handle that issue, for example by activation order and handler cancelling
271
- const handlerPointers = handler.getTrackedPointersID();
272
- const otherPointers = otherHandler.getTrackedPointersID();
273
- let overlap = false;
274
- handlerPointers.forEach(pointer => {
289
+ const isPointerWithinBothBounds = pointer => {
275
290
  const handlerX = handler.getTracker().getLastX(pointer);
276
291
  const handlerY = handler.getTracker().getLastY(pointer);
277
-
278
- if (handler.getDelegate().isPointerInBounds({
292
+ const point = {
279
293
  x: handlerX,
280
294
  y: handlerY
281
- }) && otherHandler.getDelegate().isPointerInBounds({
282
- x: handlerX,
283
- y: handlerY
284
- })) {
285
- overlap = true;
286
- }
287
- });
288
- otherPointers.forEach(pointer => {
289
- const otherX = otherHandler.getTracker().getLastX(pointer);
290
- const otherY = otherHandler.getTracker().getLastY(pointer);
291
-
292
- if (handler.getDelegate().isPointerInBounds({
293
- x: otherX,
294
- y: otherY
295
- }) && otherHandler.getDelegate().isPointerInBounds({
296
- x: otherX,
297
- y: otherY
298
- })) {
299
- overlap = true;
300
- }
301
- });
302
- return overlap;
295
+ };
296
+ return handler.getDelegate().isPointerInBounds(point) && otherHandler.getDelegate().isPointerInBounds(point);
297
+ };
298
+
299
+ const handlerPointers = handler.getTrackedPointersID();
300
+ const otherPointers = otherHandler.getTrackedPointersID();
301
+ return handlerPointers.some(isPointerWithinBothBounds) || otherPointers.some(isPointerWithinBothBounds);
303
302
  }
304
303
 
305
304
  isFinished(state) {
@@ -1 +1 @@
1
- {"version":3,"sources":["GestureHandlerOrchestrator.ts"],"names":["GestureHandlerOrchestrator","constructor","scheduleFinishedHandlersCleanup","handlingChangeSemaphore","cleanupFinishedHandlers","cleanHandler","handler","reset","setActive","setAwaiting","setActivationIndex","Number","MAX_VALUE","removeHandlerFromOrchestrator","gestureHandlers","splice","indexOf","awaitingHandlers","i","length","isFinished","getState","isAwaiting","hasOtherHandlerToWaitFor","hasToWait","forEach","otherHandler","shouldHandlerWaitForOther","tryActivate","addAwaitingHandler","State","CANCELLED","FAILED","shouldActivate","makeActive","ACTIVE","fail","BEGAN","cancel","shouldHandlerBeCancelledBy","cleanupAwaitingHandlers","onHandlerStateChange","newState","oldState","sendIfDisabled","isEnabled","END","sendEvent","isActive","UNDETERMINED","currentState","setShouldResetProgress","activationIndex","alreadyExists","push","recordHandlerIfNotPresent","MAX_SAFE_INTEGER","shouldWaitForHandlerFailure","shouldRequireToWaitForFailure","canRunSimultaneously","gh1","gh2","shouldRecognizeSimultaneously","shouldBeCancelledByOther","handlerPointers","getTrackedPointersID","otherPointers","PointerTracker","shareCommonPointers","getDelegate","getView","checkOverlap","overlap","pointer","handlerX","getTracker","getLastX","handlerY","getLastY","isPointerInBounds","x","y","otherX","otherY","state","cancelMouseAndPenGestures","currentHandler","getPointerType","PointerType","MOUS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;AACOsD,EAAAA,yBAAyB,CAACC,cAAD,EAAuC;AACrE,SAAKxE,eAAL,CAAqBW,OAArB,CAA8BnB,OAAD,IAA6B;AACxD,UACEA,OAAO,CAACiF,cAAR,OAA6BC,yBAAYC,KAAzC,IACAnF,OAAO,CAACiF,cAAR,OAA6BC,yBAAYE,MAF3C,EAGE;AACA;AACD;;AAED,UAAIpF,OAAO,KAAKgF,cAAhB,EAAgC;AAC9BhF,QAAAA,OAAO,CAACgC,MAAR;AACD,OAFD,MAEO;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACAhC,QAAAA,OAAO,CAACqE,UAAR,GAAqBgB,YAArB;AACD;AACF,KApBD;AAqBD;;AAEwB,SAAXC,WAAW,GAA+B;AACtD,QAAI,CAAC5F,0BAA0B,CAAC6F,QAAhC,EAA0C;AACxC7F,MAAAA,0BAA0B,CAAC6F,QAA3B,GAAsC,IAAI7F,0BAAJ,EAAtC;AACD;;AAED,WAAOA,0BAA0B,CAAC6F,QAAlC;AACD;;AA7X6C;;;;gBAA3B7F,0B","sourcesContent":["import { PointerType } from '../../PointerType';\nimport { State } from '../../State';\n\nimport GestureHandler from '../handlers/GestureHandler';\nimport PointerTracker from './PointerTracker';\n\nexport default class GestureHandlerOrchestrator {\n private static instance: GestureHandlerOrchestrator;\n\n private gestureHandlers: GestureHandler[] = [];\n private awaitingHandlers: GestureHandler[] = [];\n\n private handlingChangeSemaphore = 0;\n private activationIndex = 0;\n\n // Private beacuse of Singleton\n // eslint-disable-next-line no-useless-constructor, @typescript-eslint/no-empty-function\n private constructor() {}\n\n private scheduleFinishedHandlersCleanup(): void {\n if (this.handlingChangeSemaphore === 0) {\n this.cleanupFinishedHandlers();\n }\n }\n\n private cleanHandler(handler: GestureHandler): void {\n handler.reset();\n handler.setActive(false);\n handler.setAwaiting(false);\n handler.setActivationIndex(Number.MAX_VALUE);\n }\n\n public removeHandlerFromOrchestrator(handler: GestureHandler): void {\n this.gestureHandlers.splice(this.gestureHandlers.indexOf(handler), 1);\n this.awaitingHandlers.splice(this.awaitingHandlers.indexOf(handler), 1);\n }\n\n private cleanupFinishedHandlers(): void {\n for (let i = this.gestureHandlers.length - 1; i >= 0; --i) {\n const handler = this.gestureHandlers[i];\n\n if (!handler) {\n continue;\n }\n if (this.isFinished(handler.getState()) && !handler.isAwaiting()) {\n this.gestureHandlers.splice(i, 1);\n\n this.cleanHandler(handler);\n }\n }\n }\n\n private hasOtherHandlerToWaitFor(handler: GestureHandler): boolean {\n let hasToWait = false;\n this.gestureHandlers.forEach((otherHandler) => {\n if (\n otherHandler &&\n !this.isFinished(otherHandler.getState()) &&\n this.shouldHandlerWaitForOther(handler, otherHandler)\n ) {\n hasToWait = true;\n return;\n }\n });\n\n return hasToWait;\n }\n\n private tryActivate(handler: GestureHandler): void {\n if (this.hasOtherHandlerToWaitFor(handler)) {\n this.addAwaitingHandler(handler);\n } else if (\n handler.getState() !== State.CANCELLED &&\n handler.getState() !== State.FAILED\n ) {\n if (this.shouldActivate(handler)) {\n this.makeActive(handler);\n } else {\n switch (handler.getState()) {\n case State.ACTIVE:\n handler.fail();\n break;\n case State.BEGAN:\n handler.cancel();\n }\n }\n }\n }\n\n private shouldActivate(handler: GestureHandler): boolean {\n for (const otherHandler of this.gestureHandlers) {\n if (this.shouldHandlerBeCancelledBy(handler, otherHandler)) {\n return false;\n }\n }\n\n return true;\n }\n\n private cleanupAwaitingHandlers(handler: GestureHandler): void {\n for (let i = 0; i < this.awaitingHandlers.length; ++i) {\n if (\n !this.awaitingHandlers[i].isAwaiting() &&\n this.shouldHandlerWaitForOther(this.awaitingHandlers[i], handler)\n ) {\n this.cleanHandler(this.awaitingHandlers[i]);\n this.awaitingHandlers.splice(i, 1);\n }\n }\n }\n\n public onHandlerStateChange(\n handler: GestureHandler,\n newState: State,\n oldState: State,\n sendIfDisabled?: boolean\n ): void {\n if (!handler.isEnabled() && !sendIfDisabled) {\n return;\n }\n\n this.handlingChangeSemaphore += 1;\n\n if (this.isFinished(newState)) {\n this.awaitingHandlers.forEach((otherHandler) => {\n if (this.shouldHandlerWaitForOther(otherHandler, handler)) {\n if (newState === State.END) {\n otherHandler?.cancel();\n if (otherHandler.getState() === State.END) {\n // Handle edge case, where discrete gestures end immediately after activation thus\n // their state is set to END and when the gesture they are waiting for activates they\n // should be cancelled, however `cancel` was never sent as gestures were already in the END state.\n // Send synthetic BEGAN -> CANCELLED to properly handle JS logic\n otherHandler.sendEvent(State.CANCELLED, State.BEGAN);\n }\n otherHandler?.setAwaiting(false);\n } else {\n this.tryActivate(otherHandler);\n }\n }\n });\n }\n\n if (newState === State.ACTIVE) {\n this.tryActivate(handler);\n } else if (oldState === State.ACTIVE || oldState === State.END) {\n if (handler.isActive()) {\n handler.sendEvent(newState, oldState);\n } else if (\n oldState === State.ACTIVE &&\n (newState === State.CANCELLED || newState === State.FAILED)\n ) {\n handler.sendEvent(newState, State.BEGAN);\n }\n } else if (\n oldState !== State.UNDETERMINED ||\n newState !== State.CANCELLED\n ) {\n handler.sendEvent(newState, oldState);\n }\n\n this.handlingChangeSemaphore -= 1;\n\n this.scheduleFinishedHandlersCleanup();\n\n if (this.awaitingHandlers.indexOf(handler) < 0) {\n this.cleanupAwaitingHandlers(handler);\n }\n }\n\n private makeActive(handler: GestureHandler): void {\n const currentState = handler.getState();\n\n handler.setActive(true);\n handler.setShouldResetProgress(true);\n handler.setActivationIndex(this.activationIndex++);\n\n for (let i = this.gestureHandlers.length - 1; i >= 0; --i) {\n if (this.shouldHandlerBeCancelledBy(this.gestureHandlers[i], handler)) {\n this.gestureHandlers[i].cancel();\n }\n }\n\n this.awaitingHandlers.forEach((otherHandler) => {\n if (this.shouldHandlerBeCancelledBy(otherHandler, handler)) {\n otherHandler?.cancel();\n otherHandler?.setAwaiting(true);\n }\n });\n\n handler.sendEvent(State.ACTIVE, State.BEGAN);\n\n if (currentState !== State.ACTIVE) {\n handler.sendEvent(State.END, State.ACTIVE);\n if (currentState !== State.END) {\n handler.sendEvent(State.UNDETERMINED, State.END);\n }\n }\n\n if (handler.isAwaiting()) {\n handler.setAwaiting(false);\n for (let i = 0; i < this.awaitingHandlers.length; ++i) {\n if (this.awaitingHandlers[i] === handler) {\n this.awaitingHandlers.splice(i, 1);\n }\n }\n }\n }\n\n private addAwaitingHandler(handler: GestureHandler): void {\n let alreadyExists = false;\n\n this.awaitingHandlers.forEach((otherHandler) => {\n if (otherHandler === handler) {\n alreadyExists = true;\n return;\n }\n });\n\n if (alreadyExists) {\n return;\n }\n\n this.awaitingHandlers.push(handler);\n\n handler.setAwaiting(true);\n handler.setActivationIndex(this.activationIndex++);\n }\n\n public recordHandlerIfNotPresent(handler: GestureHandler): void {\n let alreadyExists = false;\n\n this.gestureHandlers.forEach((otherHandler) => {\n if (otherHandler === handler) {\n alreadyExists = true;\n return;\n }\n });\n\n if (alreadyExists) {\n return;\n }\n\n this.gestureHandlers.push(handler);\n\n handler.setActive(false);\n handler.setAwaiting(false);\n handler.setActivationIndex(Number.MAX_SAFE_INTEGER);\n }\n\n private shouldHandlerWaitForOther(\n handler: GestureHandler,\n otherHandler: GestureHandler\n ): boolean {\n return (\n handler !== otherHandler &&\n (handler.shouldWaitForHandlerFailure(otherHandler) ||\n otherHandler.shouldRequireToWaitForFailure(handler))\n );\n }\n\n private canRunSimultaneously(\n gh1: GestureHandler,\n gh2: GestureHandler\n ): boolean {\n return (\n gh1 === gh2 ||\n gh1.shouldRecognizeSimultaneously(gh2) ||\n gh2.shouldRecognizeSimultaneously(gh1)\n );\n }\n\n private shouldHandlerBeCancelledBy(\n handler: GestureHandler,\n otherHandler: GestureHandler\n ): boolean {\n if (this.canRunSimultaneously(handler, otherHandler)) {\n return false;\n }\n\n if (\n handler !== otherHandler &&\n (handler.isAwaiting() || handler.getState() === State.ACTIVE)\n ) {\n // For now it always returns false\n return handler.shouldBeCancelledByOther(otherHandler);\n }\n\n const handlerPointers: number[] = handler.getTrackedPointersID();\n const otherPointers: number[] = otherHandler.getTrackedPointersID();\n\n if (\n !PointerTracker.shareCommonPointers(handlerPointers, otherPointers) &&\n handler.getDelegate().getView() !== otherHandler.getDelegate().getView()\n ) {\n return this.checkOverlap(handler, otherHandler);\n }\n\n return true;\n }\n\n private checkOverlap(\n handler: GestureHandler,\n otherHandler: GestureHandler\n ): boolean {\n // If handlers don't have common pointers, default return value is false.\n // However, if at least on pointer overlaps with both handlers, we return true\n // This solves issue in overlapping parents example\n\n // TODO: Find better way to handle that issue, for example by activation order and handler cancelling\n\n const handlerPointers: number[] = handler.getTrackedPointersID();\n const otherPointers: number[] = otherHandler.getTrackedPointersID();\n\n let overlap = false;\n\n handlerPointers.forEach((pointer: number) => {\n const handlerX: number = handler.getTracker().getLastX(pointer);\n const handlerY: number = handler.getTracker().getLastY(pointer);\n\n if (\n handler.getDelegate().isPointerInBounds({ x: handlerX, y: handlerY }) &&\n otherHandler\n .getDelegate()\n .isPointerInBounds({ x: handlerX, y: handlerY })\n ) {\n overlap = true;\n }\n });\n\n otherPointers.forEach((pointer: number) => {\n const otherX: number = otherHandler.getTracker().getLastX(pointer);\n const otherY: number = otherHandler.getTracker().getLastY(pointer);\n\n if (\n handler.getDelegate().isPointerInBounds({ x: otherX, y: otherY }) &&\n otherHandler.getDelegate().isPointerInBounds({ x: otherX, y: otherY })\n ) {\n overlap = true;\n }\n });\n\n return overlap;\n }\n\n private isFinished(state: State): boolean {\n return (\n state === State.END || state === State.FAILED || state === State.CANCELLED\n );\n }\n\n // This function is called when handler receives touchdown event\n // If handler is using mouse or pen as a pointer and any handler receives touch event,\n // mouse/pen event dissappears - it doesn't send onPointerCancel nor onPointerUp (and others)\n // This became a problem because handler was left at active state without any signal to end or fail\n // To handle this, when new touch event is received, we loop through active handlers and check which type of\n // pointer they're using. If there are any handler with mouse/pen as a pointer, we cancel them\n public cancelMouseAndPenGestures(currentHandler: GestureHandler): void {\n this.gestureHandlers.forEach((handler: GestureHandler) => {\n if (\n handler.getPointerType() !== PointerType.MOUSE &&\n handler.getPointerType() !== PointerType.STYLUS\n ) {\n return;\n }\n\n if (handler !== currentHandler) {\n handler.cancel();\n } else {\n // Handler that received touch event should have its pointer tracker reset\n // This allows handler to smoothly change from mouse/pen to touch\n // The drawback is, that when we try to use mouse/pen one more time, it doesn't send onPointerDown at the first time\n // so it is required to click two times to get handler to work\n //\n // However, handler will receive manually created onPointerEnter that is triggered in EventManager in onPointerMove method.\n // There may be possibility to use that fact to make handler respond properly to first mouse click\n handler.getTracker().resetTracker();\n }\n });\n }\n\n public static getInstance(): GestureHandlerOrchestrator {\n if (!GestureHandlerOrchestrator.instance) {\n GestureHandlerOrchestrator.instance = new GestureHandlerOrchestrator();\n }\n\n return GestureHandlerOrchestrator.instance;\n }\n}\n"]}
1
+ {"version":3,"sources":["GestureHandlerOrchestrator.ts"],"names":["GestureHandlerOrchestrator","constructor","Set","scheduleFinishedHandlersCleanup","handlingChangeSemaphore","cleanupFinishedHandlers","cleanHandler","handler","reset","setActive","setAwaiting","setActivationIndex","Number","MAX_VALUE","removeHandlerFromOrchestrator","indexInGestureHandlers","gestureHandlers","indexOf","indexInAwaitingHandlers","awaitingHandlers","splice","awaitingHandlersTags","delete","getTag","handlersToRemove","i","length","isFinished","getState","isAwaiting","add","filter","has","hasOtherHandlerToWaitFor","hasToWaitFor","otherHandler","shouldHandlerWaitForOther","some","shouldBeCancelledByFinishedHandler","shouldBeCancelled","State","END","tryActivate","cancel","addAwaitingHandler","handlerState","CANCELLED","FAILED","shouldActivate","makeActive","ACTIVE","fail","BEGAN","shouldBeCancelledBy","shouldHandlerBeCancelledBy","cleanupAwaitingHandlers","shouldWait","onHandlerStateChange","newState","oldState","sendIfDisabled","isEnabled","sendEvent","isActive","UNDETERMINED","includes","currentState","setShouldResetProgress","activationIndex","push","recordHandlerIfNotPresent","MAX_SAFE_INTEGER","shouldWaitForHandlerFailure","shouldRequireToWaitForFailure","canRunSimultaneously","gh1","gh2","shouldRecognizeSimultaneously","shouldBeCancelledByOther","handlerPointers","getTrackedPointersID","otherPointers","PointerTracker","shareCommonPointers","getDelegate","getView","checkOverlap","isPointerWithinBothBounds","pointer","handlerX","getTracker","getLastX","handlerY","getLastY","point","x","y","isPointerInBounds","state","cancelMouseAndPenGestures","currentHandler","forEach","getPointerType","PointerType","MOUSE","STYLUS","resetTracker","getInstance","instance"],"mappings":";;;;;;;AAAA;;AACA;;AAGA;;;;;;AAEe,MAAMA,0BAAN,CAAiC;AAU9C;AACA;AACQC,EAAAA,WAAW,GAAG;AAAA,6CATuB,EASvB;;AAAA,8CARwB,EAQxB;;AAAA,kDAPsB,IAAIC,GAAJ,EAOtB;;AAAA,qDALY,CAKZ;;AAAA,6CAJI,CAIJ;AAAE;;AAEhBC,EAAAA,+BAA+B,GAAS;AAC9C,QAAI,KAAKC,uBAAL,KAAiC,CAArC,EAAwC;AACtC,WAAKC,uBAAL;AACD;AACF;;AAEOC,EAAAA,YAAY,CAACC,OAAD,EAAiC;AACnDA,IAAAA,OAAO,CAACC,KAAR;AACAD,IAAAA,OAAO,CAACE,SAAR,CAAkB,KAAlB;AACAF,IAAAA,OAAO,CAACG,WAAR,CAAoB,KAApB;AACAH,IAAAA,OAAO,CAACI,kBAAR,CAA2BC,MAAM,CAACC,SAAlC;AACD;;AAEMC,EAAAA,6BAA6B,CAACP,OAAD,EAAiC;AACnE,UAAMQ,sBAAsB,GAAG,KAAKC,eAAL,CAAqBC,OAArB,CAA6BV,OAA7B,CAA/B;AACA,UAAMW,uBAAuB,GAAG,KAAKC,gBAAL,CAAsBF,OAAtB,CAA8BV,OAA9B,CAAhC;;AAEA,QAAIQ,sBAAsB,IAAI,CAA9B,EAAiC;AAC/B,WAAKC,eAAL,CAAqBI,MAArB,CAA4BL,sBAA5B,EAAoD,CAApD;AACD;;AAED,QAAIG,uBAAuB,IAAI,CAA/B,EAAkC;AAChC,WAAKC,gBAAL,CAAsBC,MAAtB,CAA6BF,uBAA7B,EAAsD,CAAtD;AACA,WAAKG,oBAAL,CAA0BC,MAA1B,CAAiCf,OAAO,CAACgB,MAAR,EA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,CAAqBqF,OAArB,CAA8B9F,OAAD,IAA8B;AACzD,UACEA,OAAO,CAAC+F,cAAR,OAA6BC,yBAAYC,KAAzC,IACAjG,OAAO,CAAC+F,cAAR,OAA6BC,yBAAYE,MAF3C,EAGE;AACA;AACD;;AAED,UAAIlG,OAAO,KAAK6F,cAAhB,EAAgC;AAC9B7F,QAAAA,OAAO,CAACoC,MAAR;AACD,OAFD,MAEO;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACApC,QAAAA,OAAO,CAACmF,UAAR,GAAqBgB,YAArB;AACD;AACF,KApBD;AAqBD;;AAEwB,SAAXC,WAAW,GAA+B;AACtD,QAAI,CAAC3G,0BAA0B,CAAC4G,QAAhC,EAA0C;AACxC5G,MAAAA,0BAA0B,CAAC4G,QAA3B,GAAsC,IAAI5G,0BAAJ,EAAtC;AACD;;AAED,WAAOA,0BAA0B,CAAC4G,QAAlC;AACD;;AA5Y6C;;;;gBAA3B5G,0B","sourcesContent":["import { PointerType } from '../../PointerType';\nimport { State } from '../../State';\n\nimport type IGestureHandler from '../handlers/IGestureHandler';\nimport PointerTracker from './PointerTracker';\n\nexport default class GestureHandlerOrchestrator {\n private static instance: GestureHandlerOrchestrator;\n\n private gestureHandlers: IGestureHandler[] = [];\n private awaitingHandlers: IGestureHandler[] = [];\n private awaitingHandlersTags: Set<number> = new Set();\n\n private handlingChangeSemaphore = 0;\n private activationIndex = 0;\n\n // Private beacuse of Singleton\n // eslint-disable-next-line no-useless-constructor, @typescript-eslint/no-empty-function\n private constructor() {}\n\n private scheduleFinishedHandlersCleanup(): void {\n if (this.handlingChangeSemaphore === 0) {\n this.cleanupFinishedHandlers();\n }\n }\n\n private cleanHandler(handler: IGestureHandler): void {\n handler.reset();\n handler.setActive(false);\n handler.setAwaiting(false);\n handler.setActivationIndex(Number.MAX_VALUE);\n }\n\n public removeHandlerFromOrchestrator(handler: IGestureHandler): void {\n const indexInGestureHandlers = this.gestureHandlers.indexOf(handler);\n const indexInAwaitingHandlers = this.awaitingHandlers.indexOf(handler);\n\n if (indexInGestureHandlers >= 0) {\n this.gestureHandlers.splice(indexInGestureHandlers, 1);\n }\n\n if (indexInAwaitingHandlers >= 0) {\n this.awaitingHandlers.splice(indexInAwaitingHandlers, 1);\n this.awaitingHandlersTags.delete(handler.getTag());\n }\n }\n\n private cleanupFinishedHandlers(): void {\n const handlersToRemove = new Set<IGestureHandler>();\n\n for (let i = this.gestureHandlers.length - 1; i >= 0; --i) {\n const handler = this.gestureHandlers[i];\n\n if (this.isFinished(handler.getState()) && !handler.isAwaiting()) {\n this.cleanHandler(handler);\n handlersToRemove.add(handler);\n }\n }\n\n this.gestureHandlers = this.gestureHandlers.filter(\n (handler) => !handlersToRemove.has(handler)\n );\n }\n\n private hasOtherHandlerToWaitFor(handler: IGestureHandler): boolean {\n const hasToWaitFor = (otherHandler: IGestureHandler) => {\n return (\n !this.isFinished(otherHandler.getState()) &&\n this.shouldHandlerWaitForOther(handler, otherHandler)\n );\n };\n\n return this.gestureHandlers.some(hasToWaitFor);\n }\n\n private shouldBeCancelledByFinishedHandler(\n handler: IGestureHandler\n ): boolean {\n const shouldBeCancelled = (otherHandler: IGestureHandler) => {\n return (\n this.shouldHandlerWaitForOther(handler, otherHandler) &&\n otherHandler.getState() === State.END\n );\n };\n\n return this.gestureHandlers.some(shouldBeCancelled);\n }\n\n private tryActivate(handler: IGestureHandler): void {\n if (this.shouldBeCancelledByFinishedHandler(handler)) {\n handler.cancel();\n return;\n }\n\n if (this.hasOtherHandlerToWaitFor(handler)) {\n this.addAwaitingHandler(handler);\n return;\n }\n\n const handlerState = handler.getState();\n\n if (handlerState === State.CANCELLED || handlerState === State.FAILED) {\n return;\n }\n\n if (this.shouldActivate(handler)) {\n this.makeActive(handler);\n return;\n }\n\n if (handlerState === State.ACTIVE) {\n handler.fail();\n return;\n }\n\n if (handlerState === State.BEGAN) {\n handler.cancel();\n }\n }\n\n private shouldActivate(handler: IGestureHandler): boolean {\n const shouldBeCancelledBy = (otherHandler: IGestureHandler) => {\n return this.shouldHandlerBeCancelledBy(handler, otherHandler);\n };\n\n return !this.gestureHandlers.some(shouldBeCancelledBy);\n }\n\n private cleanupAwaitingHandlers(handler: IGestureHandler): void {\n const shouldWait = (otherHandler: IGestureHandler) => {\n return (\n !otherHandler.isAwaiting() &&\n this.shouldHandlerWaitForOther(otherHandler, handler)\n );\n };\n\n for (const otherHandler of this.awaitingHandlers) {\n if (shouldWait(otherHandler)) {\n this.cleanHandler(otherHandler);\n this.awaitingHandlersTags.delete(otherHandler.getTag());\n }\n }\n\n this.awaitingHandlers = this.awaitingHandlers.filter((otherHandler) =>\n this.awaitingHandlersTags.has(otherHandler.getTag())\n );\n }\n\n public onHandlerStateChange(\n handler: IGestureHandler,\n newState: State,\n oldState: State,\n sendIfDisabled?: boolean\n ): void {\n if (!handler.isEnabled() && !sendIfDisabled) {\n return;\n }\n\n this.handlingChangeSemaphore += 1;\n\n if (this.isFinished(newState)) {\n for (const otherHandler of this.awaitingHandlers) {\n if (\n !this.shouldHandlerWaitForOther(otherHandler, handler) ||\n !this.awaitingHandlersTags.has(otherHandler.getTag())\n ) {\n continue;\n }\n\n if (newState !== State.END) {\n this.tryActivate(otherHandler);\n continue;\n }\n\n otherHandler.cancel();\n\n if (otherHandler.getState() === State.END) {\n // Handle edge case, where discrete gestures end immediately after activation thus\n // their state is set to END and when the gesture they are waiting for activates they\n // should be cancelled, however `cancel` was never sent as gestures were already in the END state.\n // Send synthetic BEGAN -> CANCELLED to properly handle JS logic\n otherHandler.sendEvent(State.CANCELLED, State.BEGAN);\n }\n\n otherHandler.setAwaiting(false);\n }\n }\n\n if (newState === State.ACTIVE) {\n this.tryActivate(handler);\n } else if (oldState === State.ACTIVE || oldState === State.END) {\n if (handler.isActive()) {\n handler.sendEvent(newState, oldState);\n } else if (\n oldState === State.ACTIVE &&\n (newState === State.CANCELLED || newState === State.FAILED)\n ) {\n handler.sendEvent(newState, State.BEGAN);\n }\n } else if (\n oldState !== State.UNDETERMINED ||\n newState !== State.CANCELLED\n ) {\n handler.sendEvent(newState, oldState);\n }\n\n this.handlingChangeSemaphore -= 1;\n\n this.scheduleFinishedHandlersCleanup();\n\n if (!this.awaitingHandlers.includes(handler)) {\n this.cleanupAwaitingHandlers(handler);\n }\n }\n\n private makeActive(handler: IGestureHandler): void {\n const currentState = handler.getState();\n\n handler.setActive(true);\n handler.setShouldResetProgress(true);\n handler.setActivationIndex(this.activationIndex++);\n\n for (let i = this.gestureHandlers.length - 1; i >= 0; --i) {\n if (this.shouldHandlerBeCancelledBy(this.gestureHandlers[i], handler)) {\n this.gestureHandlers[i].cancel();\n }\n }\n\n for (const otherHandler of this.awaitingHandlers) {\n if (this.shouldHandlerBeCancelledBy(otherHandler, handler)) {\n otherHandler.setAwaiting(false);\n }\n }\n\n handler.sendEvent(State.ACTIVE, State.BEGAN);\n\n if (currentState !== State.ACTIVE) {\n handler.sendEvent(State.END, State.ACTIVE);\n if (currentState !== State.END) {\n handler.sendEvent(State.UNDETERMINED, State.END);\n }\n }\n\n if (!handler.isAwaiting()) {\n return;\n }\n\n handler.setAwaiting(false);\n\n this.awaitingHandlers = this.awaitingHandlers.filter(\n (otherHandler) => otherHandler !== handler\n );\n }\n\n private addAwaitingHandler(handler: IGestureHandler): void {\n if (this.awaitingHandlers.includes(handler)) {\n return;\n }\n\n this.awaitingHandlers.push(handler);\n this.awaitingHandlersTags.add(handler.getTag());\n\n handler.setAwaiting(true);\n handler.setActivationIndex(this.activationIndex++);\n }\n\n public recordHandlerIfNotPresent(handler: IGestureHandler): void {\n if (this.gestureHandlers.includes(handler)) {\n return;\n }\n\n this.gestureHandlers.push(handler);\n\n handler.setActive(false);\n handler.setAwaiting(false);\n handler.setActivationIndex(Number.MAX_SAFE_INTEGER);\n }\n\n private shouldHandlerWaitForOther(\n handler: IGestureHandler,\n otherHandler: IGestureHandler\n ): boolean {\n return (\n handler !== otherHandler &&\n (handler.shouldWaitForHandlerFailure(otherHandler) ||\n otherHandler.shouldRequireToWaitForFailure(handler))\n );\n }\n\n private canRunSimultaneously(\n gh1: IGestureHandler,\n gh2: IGestureHandler\n ): boolean {\n return (\n gh1 === gh2 ||\n gh1.shouldRecognizeSimultaneously(gh2) ||\n gh2.shouldRecognizeSimultaneously(gh1)\n );\n }\n\n private shouldHandlerBeCancelledBy(\n handler: IGestureHandler,\n otherHandler: IGestureHandler\n ): boolean {\n if (this.canRunSimultaneously(handler, otherHandler)) {\n return false;\n }\n\n if (handler.isAwaiting() || handler.getState() === State.ACTIVE) {\n // For now it always returns false\n return handler.shouldBeCancelledByOther(otherHandler);\n }\n\n const handlerPointers: number[] = handler.getTrackedPointersID();\n const otherPointers: number[] = otherHandler.getTrackedPointersID();\n\n if (\n !PointerTracker.shareCommonPointers(handlerPointers, otherPointers) &&\n handler.getDelegate().getView() !== otherHandler.getDelegate().getView()\n ) {\n return this.checkOverlap(handler, otherHandler);\n }\n\n return true;\n }\n\n private checkOverlap(\n handler: IGestureHandler,\n otherHandler: IGestureHandler\n ): boolean {\n // If handlers don't have common pointers, default return value is false.\n // However, if at least on pointer overlaps with both handlers, we return true\n // This solves issue in overlapping parents example\n\n // TODO: Find better way to handle that issue, for example by activation order and handler cancelling\n\n const isPointerWithinBothBounds = (pointer: number) => {\n const handlerX: number = handler.getTracker().getLastX(pointer);\n const handlerY: number = handler.getTracker().getLastY(pointer);\n\n const point = {\n x: handlerX,\n y: handlerY,\n };\n\n return (\n handler.getDelegate().isPointerInBounds(point) &&\n otherHandler.getDelegate().isPointerInBounds(point)\n );\n };\n\n const handlerPointers: number[] = handler.getTrackedPointersID();\n const otherPointers: number[] = otherHandler.getTrackedPointersID();\n\n return (\n handlerPointers.some(isPointerWithinBothBounds) ||\n otherPointers.some(isPointerWithinBothBounds)\n );\n }\n\n private isFinished(state: State): boolean {\n return (\n state === State.END || state === State.FAILED || state === State.CANCELLED\n );\n }\n\n // This function is called when handler receives touchdown event\n // If handler is using mouse or pen as a pointer and any handler receives touch event,\n // mouse/pen event dissappears - it doesn't send onPointerCancel nor onPointerUp (and others)\n // This became a problem because handler was left at active state without any signal to end or fail\n // To handle this, when new touch event is received, we loop through active handlers and check which type of\n // pointer they're using. If there are any handler with mouse/pen as a pointer, we cancel them\n public cancelMouseAndPenGestures(currentHandler: IGestureHandler): void {\n this.gestureHandlers.forEach((handler: IGestureHandler) => {\n if (\n handler.getPointerType() !== PointerType.MOUSE &&\n handler.getPointerType() !== PointerType.STYLUS\n ) {\n return;\n }\n\n if (handler !== currentHandler) {\n handler.cancel();\n } else {\n // Handler that received touch event should have its pointer tracker reset\n // This allows handler to smoothly change from mouse/pen to touch\n // The drawback is, that when we try to use mouse/pen one more time, it doesn't send onPointerDown at the first time\n // so it is required to click two times to get handler to work\n //\n // However, handler will receive manually created onPointerEnter that is triggered in EventManager in onPointerMove method.\n // There may be possibility to use that fact to make handler respond properly to first mouse click\n handler.getTracker().resetTracker();\n }\n });\n }\n\n public static getInstance(): GestureHandlerOrchestrator {\n if (!GestureHandlerOrchestrator.instance) {\n GestureHandlerOrchestrator.instance = new GestureHandlerOrchestrator();\n }\n\n return GestureHandlerOrchestrator.instance;\n }\n}\n"]}
@@ -15,7 +15,7 @@ var _State = require("../../State");
15
15
 
16
16
  var _utils = require("../utils");
17
17
 
18
- var _interfaces = require("../interfaces");
18
+ var _gestureHandlerCommon = require("../../handlers/gestureHandlerCommon");
19
19
 
20
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
21
 
@@ -35,15 +35,14 @@ class GestureHandlerWebDelegate {
35
35
  }
36
36
 
37
37
  init(viewRef, handler) {
38
+ var _config$touchAction;
39
+
38
40
  if (!viewRef) {
39
41
  throw new Error(`Cannot find HTML Element for handler ${handler.getTag()}`);
40
42
  }
41
43
 
42
44
  this.gestureHandler = handler;
43
45
  this.view = (0, _reactNative.findNodeHandle)(viewRef);
44
- this.view.style['touchAction'] = 'none'; //@ts-ignore This one disables default events on Safari
45
-
46
- this.view.style['WebkitTouchCallout'] = 'none';
47
46
  const config = handler.getConfig();
48
47
  this.addContextMenuListeners(config);
49
48
 
@@ -55,6 +54,9 @@ class GestureHandlerWebDelegate {
55
54
  this.view.style['userSelect'] = config.userSelect;
56
55
  }
57
56
 
57
+ this.view.style['touchAction'] = (_config$touchAction = config.touchAction) !== null && _config$touchAction !== void 0 ? _config$touchAction : 'none'; //@ts-ignore This one disables default events on Safari
58
+
59
+ this.view.style['WebkitTouchCallout'] = 'none';
58
60
  this.eventManagers.push(new _PointerEventManager.default(this.view));
59
61
  this.eventManagers.push(new _TouchEventManager.default(this.view));
60
62
  this.eventManagers.forEach(manager => this.gestureHandler.attachEventManager(manager));
@@ -93,7 +95,7 @@ class GestureHandlerWebDelegate {
93
95
  }
94
96
 
95
97
  shouldDisableContextMenu(config) {
96
- return config.enableContextMenu === undefined && this.gestureHandler.isButtonInConfig(_interfaces.MouseButton.RIGHT) || config.enableContextMenu === false;
98
+ return config.enableContextMenu === undefined && this.gestureHandler.isButtonInConfig(_gestureHandlerCommon.MouseButton.RIGHT) || config.enableContextMenu === false;
97
99
  }
98
100
 
99
101
  addContextMenuListeners(config) {
@@ -145,6 +147,9 @@ class GestureHandlerWebDelegate {
145
147
 
146
148
  destroy(config) {
147
149
  this.removeContextMenuListeners(config);
150
+ this.eventManagers.forEach(manager => {
151
+ manager.unregisterListeners();
152
+ });
148
153
  }
149
154
 
150
155
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["GestureHandlerWebDelegate.ts"],"names":["GestureHandlerWebDelegate","getView","view","init","viewRef","handler","Error","getTag","gestureHandler","style","config","getConfig","addContextMenuListeners","userSelect","eventManagers","push","PointerEventManager","TouchEventManager","forEach","manager","attachEventManager","isPointerInBounds","x","y","measureView","rect","getBoundingClientRect","pageX","left","pageY","top","width","height","reset","resetManager","tryResetCursor","activeCursor","getState","State","ACTIVE","cursor","shouldDisableContextMenu","enableContextMenu","undefined","isButtonInConfig","MouseButton","RIGHT","addEventListener","disableContextMenu","removeContextMenuListeners","removeE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Q,GAAS;AACf,SAAKtB,cAAL;AACD;;AAEDuB,EAAAA,MAAM,GAAS;AACb,SAAKvB,cAAL;AACD;;AAEMwB,EAAAA,OAAO,CAACjD,MAAD,EAAuB;AACnC,SAAKuC,0BAAL,CAAgCvC,MAAhC;AACD;;AAzIH","sourcesContent":["import { findNodeHandle } from 'react-native';\nimport type GestureHandler from '../handlers/GestureHandler';\nimport {\n GestureHandlerDelegate,\n MeasureResult,\n} from './GestureHandlerDelegate';\nimport PointerEventManager from './PointerEventManager';\nimport TouchEventManager from './TouchEventManager';\nimport { State } from '../../State';\nimport { isPointerInBounds } from '../utils';\nimport EventManager from './EventManager';\nimport { Config, MouseButton } from '../interfaces';\n\nexport class GestureHandlerWebDelegate\n implements GestureHandlerDelegate<HTMLElement>\n{\n private view!: HTMLElement;\n private gestureHandler!: GestureHandler;\n private eventManagers: EventManager<unknown>[] = [];\n\n getView(): HTMLElement {\n return this.view;\n }\n\n init(viewRef: number, handler: GestureHandler): void {\n if (!viewRef) {\n throw new Error(\n `Cannot find HTML Element for handler ${handler.getTag()}`\n );\n }\n\n this.gestureHandler = handler;\n this.view = findNodeHandle(viewRef) as unknown as HTMLElement;\n\n this.view.style['touchAction'] = 'none';\n //@ts-ignore This one disables default events on Safari\n this.view.style['WebkitTouchCallout'] = 'none';\n\n const config = handler.getConfig();\n\n this.addContextMenuListeners(config);\n\n if (!config.userSelect) {\n this.view.style['webkitUserSelect'] = 'none';\n this.view.style['userSelect'] = 'none';\n } else {\n this.view.style['webkitUserSelect'] = config.userSelect;\n this.view.style['userSelect'] = config.userSelect;\n }\n\n this.eventManagers.push(new PointerEventManager(this.view));\n this.eventManagers.push(new TouchEventManager(this.view));\n\n this.eventManagers.forEach((manager) =>\n this.gestureHandler.attachEventManager(manager)\n );\n }\n\n isPointerInBounds({ x, y }: { x: number; y: number }): boolean {\n return isPointerInBounds(this.view, { x, y });\n }\n\n measureView(): MeasureResult {\n const rect = this.view.getBoundingClientRect();\n\n return {\n pageX: rect.left,\n pageY: rect.top,\n width: rect.width,\n height: rect.height,\n };\n }\n\n reset(): void {\n this.eventManagers.forEach((manager: EventManager<unknown>) =>\n manager.resetManager()\n );\n }\n\n tryResetCursor() {\n const config = this.gestureHandler.getConfig();\n\n if (\n config.activeCursor &&\n config.activeCursor !== 'auto' &&\n this.gestureHandler.getState() === State.ACTIVE\n ) {\n this.view.style.cursor = 'auto';\n }\n }\n\n private shouldDisableContextMenu(config: Config) {\n return (\n (config.enableContextMenu === undefined &&\n this.gestureHandler.isButtonInConfig(MouseButton.RIGHT)) ||\n config.enableContextMenu === false\n );\n }\n\n private addContextMenuListeners(config: Config): void {\n if (this.shouldDisableContextMenu(config)) {\n this.view.addEventListener('contextmenu', this.disableContextMenu);\n } else if (config.enableContextMenu) {\n this.view.addEventListener('contextmenu', this.enableContextMenu);\n }\n }\n\n private removeContextMenuListeners(config: Config): void {\n if (this.shouldDisableContextMenu(config)) {\n this.view.removeEventListener('contextmenu', this.disableContextMenu);\n } else if (config.enableContextMenu) {\n this.view.removeEventListener('contextmenu', this.enableContextMenu);\n }\n }\n\n private disableContextMenu(this: void, e: MouseEvent): void {\n e.preventDefault();\n }\n\n private enableContextMenu(this: void, e: MouseEvent): void {\n e.stopPropagation();\n }\n\n onBegin(): void {\n // no-op for now\n }\n\n onActivate(): void {\n const config = this.gestureHandler.getConfig();\n\n if (\n (!this.view.style.cursor || this.view.style.cursor === 'auto') &&\n config.activeCursor\n ) {\n this.view.style.cursor = config.activeCursor;\n }\n }\n\n onEnd(): void {\n this.tryResetCursor();\n }\n\n onCancel(): void {\n this.tryResetCursor();\n }\n\n onFail(): void {\n this.tryResetCursor();\n }\n\n public destroy(config: Config): void {\n this.removeContextMenuListeners(config);\n }\n}\n"]}
1
+ {"version":3,"sources":["GestureHandlerWebDelegate.ts"],"names":["GestureHandlerWebDelegate","getView","view","init","viewRef","handler","Error","getTag","gestureHandler","config","getConfig","addContextMenuListeners","userSelect","style","touchAction","eventManagers","push","PointerEventManager","TouchEventManager","forEach","manager","attachEventManager","isPointerInBounds","x","y","measureView","rect","getBoundingClientRect","pageX","left","pageY","top","width","height","reset","resetManager","tryResetCursor","activeCursor","getState","State","ACTIVE","cursor","shouldDisableContextMenu","enableContextMenu","undefined","isButtonInConfig","MouseButton","RIGHT","addEventListener","disableContextMenu","removeContextMenuListeners","removeEventListener","e","preventDefault","stopPropagation","onBegin","onActivate","onEnd","onCancel","onFail","destroy","unregisterListeners"],"mappings":";;;;;;;AAAA;;AAMA;;AACA;;AACA;;AACA;;AAGA;;;;;;AAEO,MAAMA,yBAAN,CAEP;AAAA;AAAA;;AAAA;;AAAA,2CAGmD,EAHnD;AAAA;;AAKEC,EAAAA,OAAO,GAAgB;AACrB,WAAO,KAAKC,IAAZ;AACD;;AAEDC,EAAAA,IAAI,CAACC,OAAD,EAAkBC,OAAlB,EAAkD;AAAA;;AACpD,QAAI,CAACD,OAAL,EAAc;AACZ,YAAM,IAAIE,KAAJ,CACH,wCAAuCD,OAAO,CAACE,MAAR,EAAiB,EADrD,CAAN;AAGD;;AAED,SAAKC,cAAL,GAAsBH,OAAtB;AACA,SAAKH,IAAL,GAAY,iCAAeE,OAAf,CAAZ;AAEA,UAAMK,MAAM,GAAGJ,OAAO,CAACK,SAAR,EAAf;AAEA,SAAKC,uBAAL,CAA6BF,MAA7B;;AAEA,QAAI,CAACA,MAAM,CAACG,UAAZ,EAAwB;AACtB,WAAKV,IAAL,CAAUW,KAAV,CAAgB,kBAAhB,IAAsC,MAAtC;AACA,WAAKX,IAAL,CAAUW,KAAV,CAAgB,YAAhB,IAAgC,MAAhC;AACD,KAHD,MAGO;AACL,WAAKX,IAAL,CAAUW,KAAV,CAAgB,kBAAhB,IAAsCJ,MAAM,CAACG,UAA7C;AACA,WAAKV,IAAL,CAAUW,KAAV,CAAgB,YAAhB,IAAgCJ,MAAM,CAACG,UAAvC;AACD;;AAED,SAAKV,IAAL,CAAUW,KAAV,CAAgB,aAAhB,2BAAiCJ,MAAM,CAAC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B4B,MAAjB,IAA2B,KAAKvC,IAAL,CAAUW,KAAV,CAAgB4B,MAAhB,KAA2B,MAAvD,KACAhC,MAAM,CAAC4B,YAFT,EAGE;AACA,WAAKnC,IAAL,CAAUW,KAAV,CAAgB4B,MAAhB,GAAyBhC,MAAM,CAAC4B,YAAhC;AACD;AACF;;AAEDoB,EAAAA,KAAK,GAAS;AACZ,SAAKrB,cAAL;AACD;;AAEDsB,EAAAA,QAAQ,GAAS;AACf,SAAKtB,cAAL;AACD;;AAEDuB,EAAAA,MAAM,GAAS;AACb,SAAKvB,cAAL;AACD;;AAEMwB,EAAAA,OAAO,CAACnD,MAAD,EAAuB;AACnC,SAAKyC,0BAAL,CAAgCzC,MAAhC;AAEA,SAAKM,aAAL,CAAmBI,OAAnB,CAA4BC,OAAD,IAAa;AACtCA,MAAAA,OAAO,CAACyC,mBAAR;AACD,KAFD;AAGD;;AA7IH","sourcesContent":["import { findNodeHandle } from 'react-native';\nimport type IGestureHandler from '../handlers/IGestureHandler';\nimport {\n GestureHandlerDelegate,\n MeasureResult,\n} from './GestureHandlerDelegate';\nimport PointerEventManager from './PointerEventManager';\nimport TouchEventManager from './TouchEventManager';\nimport { State } from '../../State';\nimport { isPointerInBounds } from '../utils';\nimport EventManager from './EventManager';\nimport { Config } from '../interfaces';\nimport { MouseButton } from '../../handlers/gestureHandlerCommon';\n\nexport class GestureHandlerWebDelegate\n implements GestureHandlerDelegate<HTMLElement, IGestureHandler>\n{\n private view!: HTMLElement;\n private gestureHandler!: IGestureHandler;\n private eventManagers: EventManager<unknown>[] = [];\n\n getView(): HTMLElement {\n return this.view;\n }\n\n init(viewRef: number, handler: IGestureHandler): void {\n if (!viewRef) {\n throw new Error(\n `Cannot find HTML Element for handler ${handler.getTag()}`\n );\n }\n\n this.gestureHandler = handler;\n this.view = findNodeHandle(viewRef) as unknown as HTMLElement;\n\n const config = handler.getConfig();\n\n this.addContextMenuListeners(config);\n\n if (!config.userSelect) {\n this.view.style['webkitUserSelect'] = 'none';\n this.view.style['userSelect'] = 'none';\n } else {\n this.view.style['webkitUserSelect'] = config.userSelect;\n this.view.style['userSelect'] = config.userSelect;\n }\n\n this.view.style['touchAction'] = config.touchAction ?? 'none';\n //@ts-ignore This one disables default events on Safari\n this.view.style['WebkitTouchCallout'] = 'none';\n\n this.eventManagers.push(new PointerEventManager(this.view));\n this.eventManagers.push(new TouchEventManager(this.view));\n\n this.eventManagers.forEach((manager) =>\n this.gestureHandler.attachEventManager(manager)\n );\n }\n\n isPointerInBounds({ x, y }: { x: number; y: number }): boolean {\n return isPointerInBounds(this.view, { x, y });\n }\n\n measureView(): MeasureResult {\n const rect = this.view.getBoundingClientRect();\n\n return {\n pageX: rect.left,\n pageY: rect.top,\n width: rect.width,\n height: rect.height,\n };\n }\n\n reset(): void {\n this.eventManagers.forEach((manager: EventManager<unknown>) =>\n manager.resetManager()\n );\n }\n\n tryResetCursor() {\n const config = this.gestureHandler.getConfig();\n\n if (\n config.activeCursor &&\n config.activeCursor !== 'auto' &&\n this.gestureHandler.getState() === State.ACTIVE\n ) {\n this.view.style.cursor = 'auto';\n }\n }\n\n private shouldDisableContextMenu(config: Config) {\n return (\n (config.enableContextMenu === undefined &&\n this.gestureHandler.isButtonInConfig(MouseButton.RIGHT)) ||\n config.enableContextMenu === false\n );\n }\n\n private addContextMenuListeners(config: Config): void {\n if (this.shouldDisableContextMenu(config)) {\n this.view.addEventListener('contextmenu', this.disableContextMenu);\n } else if (config.enableContextMenu) {\n this.view.addEventListener('contextmenu', this.enableContextMenu);\n }\n }\n\n private removeContextMenuListeners(config: Config): void {\n if (this.shouldDisableContextMenu(config)) {\n this.view.removeEventListener('contextmenu', this.disableContextMenu);\n } else if (config.enableContextMenu) {\n this.view.removeEventListener('contextmenu', this.enableContextMenu);\n }\n }\n\n private disableContextMenu(this: void, e: MouseEvent): void {\n e.preventDefault();\n }\n\n private enableContextMenu(this: void, e: MouseEvent): void {\n e.stopPropagation();\n }\n\n onBegin(): void {\n // no-op for now\n }\n\n onActivate(): void {\n const config = this.gestureHandler.getConfig();\n\n if (\n (!this.view.style.cursor || this.view.style.cursor === 'auto') &&\n config.activeCursor\n ) {\n this.view.style.cursor = config.activeCursor;\n }\n }\n\n onEnd(): void {\n this.tryResetCursor();\n }\n\n onCancel(): void {\n this.tryResetCursor();\n }\n\n onFail(): void {\n this.tryResetCursor();\n }\n\n public destroy(config: Config): void {\n this.removeContextMenuListeners(config);\n\n this.eventManagers.forEach((manager) => {\n manager.unregisterListeners();\n });\n }\n}\n"]}
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
+ var _State = require("../../State");
9
+
8
10
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
11
 
10
12
  class InteractionManager {
@@ -81,9 +83,16 @@ class InteractionManager {
81
83
  })) !== undefined;
82
84
  }
83
85
 
84
- shouldHandlerBeCancelledBy(_handler, _otherHandler) {
85
- //TODO: Implement logic
86
- return false;
86
+ shouldHandlerBeCancelledBy(_handler, otherHandler) {
87
+ var _otherHandler$isButto;
88
+
89
+ // We check constructor name instead of using `instanceof` in order do avoid circular dependencies
90
+ const isNativeHandler = otherHandler.constructor.name === 'NativeViewGestureHandler';
91
+
92
+ const isActive = otherHandler.getState() === _State.State.ACTIVE;
93
+
94
+ const isButton = ((_otherHandler$isButto = otherHandler.isButton) === null || _otherHandler$isButto === void 0 ? void 0 : _otherHandler$isButto.call(otherHandler)) === true;
95
+ return isNativeHandler && isActive && !isButton;
87
96
  }
88
97
 
89
98
  dropRelationsForHandlerWithTag(handlerTag) {
@@ -1 +1 @@
1
- {"version":3,"sources":["InteractionManager.ts"],"names":["InteractionManager","constructor","Map","configureInteractions","handler","config","dropRelationsForHandlerWithTag","getTag","waitFor","forEach","otherHandler","push","handlerTag","waitForRelations","set","simultaneousHandlers","simultaneousRelations","blocksHandlers","blocksHandlersRelations","shouldWaitForHandlerFailure","get","find","tag","undefined","shouldRecognizeSimultaneously","shouldRequireHandlerToWaitForFailure","shouldHandlerBeCancelledBy","_handler","_otherHandler","delete","reset","clear","getInstance","instance"],"mappings":";;;;;;;;;AAGe,MAAMA,kBAAN,CAAyB;AAMtC;AACA;AACQC,EAAAA,WAAW,GAAG;AAAA,8CANqC,IAAIC,GAAJ,EAMrC;;AAAA,mDAL0C,IAAIA,GAAJ,EAK1C;;AAAA,qDAJ4C,IAAIA,GAAJ,EAI5C;AAAE;;AAEjBC,EAAAA,qBAAqB,CAACC,OAAD,EAA0BC,MAA1B,EAA0C;AACpE,SAAKC,8BAAL,CAAoCF,OAAO,CAACG,MAAR,EAApC;;AAEA,QAAIF,MAAM,CAACG,OAAX,EAAoB;AAClB,YAAMA,OAAiB,GAAG,EAA1B;AACAH,MAAAA,MAAM,CAACG,OAAP,CAAeC,OAAf,CAAwBC,YAAD,IAAiC;AACtD;AACA,YAAI,OAAOA,YAAP,KAAwB,QAA5B,EAAsC;AACpCF,UAAAA,OAAO,CAACG,IAAR,CAAaD,YAAb;AACD,SAFD,MAEO;AACL;AACAF,UAAAA,OAAO,CAACG,IAAR,CAAaD,YAAY,CAACE,UAA1B;AACD;AACF,OARD;AAUA,WAAKC,gBAAL,CAAsBC,GAAtB,CAA0BV,OAAO,CAACG,MAAR,EAA1B,EAA4CC,OAA5C;AACD;;AAED,QAAIH,MAAM,CAACU,oBAAX,EAAiC;AAC/B,YAAMA,oBAA8B,GAAG,EAAvC;AACAV,MAAAA,MAAM,CAACU,oBAAP,CAA4BN,OAA5B,CAAqCC,YAAD,IAAiC;AACnE,YAAI,OAAOA,YAAP,KAAwB,QAA5B,EAAsC;AACpCK,UAAAA,oBAAoB,CAACJ,IAArB,CAA0BD,YAA1B;AACD,SAFD,MAEO;AACLK,UAAAA,oBAAoB,CAACJ,IAArB,CAA0BD,YAAY,CAACE,UAAvC;AACD;AACF,OAND;AAQA,WAAKI,qBAAL,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AGhC;AACT,UAAMF,OAA6B,GAAG,KAAKU,uBAAL,CAA6BE,GAA7B,CACpChB,OAAO,CAACG,MAAR,EADoC,CAAtC;AAIA,WACE,CAAAC,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEa,IAAT,CAAeC,GAAD,IAAiB;AAC7B,aAAOA,GAAG,KAAKZ,YAAY,CAACH,MAAb,EAAf;AACD,KAFD,OAEOgB,SAHT;AAKD;;AAEMG,EAAAA,0BAA0B,CAC/BC,QAD+B,EAE/BC,aAF+B,EAGtB;AACT;AACA,WAAO,KAAP;AACD;;AAEMtB,EAAAA,8BAA8B,CAACM,UAAD,EAA2B;AAC9D,SAAKC,gBAAL,CAAsBgB,MAAtB,CAA6BjB,UAA7B;AACA,SAAKI,qBAAL,CAA2Ba,MAA3B,CAAkCjB,UAAlC;AACA,SAAKM,uBAAL,CAA6BW,MAA7B,CAAoCjB,UAApC;AACD;;AAEMkB,EAAAA,KAAK,GAAG;AACb,SAAKjB,gBAAL,CAAsBkB,KAAtB;AACA,SAAKf,qBAAL,CAA2Be,KAA3B;AACA,SAAKb,uBAAL,CAA6Ba,KAA7B;AACD;;AAEwB,SAAXC,WAAW,GAAuB;AAC9C,QAAI,CAAC,KAAKC,QAAV,EAAoB;AAClB,WAAKA,QAAL,GAAgB,IAAIjC,kBAAJ,EAAhB;AACD;;AAED,WAAO,KAAKiC,QAAZ;AACD;;AA7HqC;;;;gBAAnBjC,kB","sourcesContent":["import GestureHandler from '../handlers/GestureHandler';\nimport { Config, Handler } from '../interfaces';\n\nexport default class InteractionManager {\n private static instance: InteractionManager;\n private readonly waitForRelations: Map<number, number[]> = new Map();\n private readonly simultaneousRelations: Map<number, number[]> = new Map();\n private readonly blocksHandlersRelations: Map<number, number[]> = new Map();\n\n // Private becaues of singleton\n // eslint-disable-next-line no-useless-constructor, @typescript-eslint/no-empty-function\n private constructor() {}\n\n public configureInteractions(handler: GestureHandler, config: Config) {\n this.dropRelationsForHandlerWithTag(handler.getTag());\n\n if (config.waitFor) {\n const waitFor: number[] = [];\n config.waitFor.forEach((otherHandler: Handler): void => {\n // New API reference\n if (typeof otherHandler === 'number') {\n waitFor.push(otherHandler);\n } else {\n // Old API reference\n waitFor.push(otherHandler.handlerTag);\n }\n });\n\n this.waitForRelations.set(handler.getTag(), waitFor);\n }\n\n if (config.simultaneousHandlers) {\n const simultaneousHandlers: number[] = [];\n config.simultaneousHandlers.forEach((otherHandler: Handler): void => {\n if (typeof otherHandler === 'number') {\n simultaneousHandlers.push(otherHandler);\n } else {\n simultaneousHandlers.push(otherHandler.handlerTag);\n }\n });\n\n this.simultaneousRelations.set(handler.getTag(), simultaneousHandlers);\n }\n\n if (config.blocksHandlers) {\n const blocksHandlers: number[] = [];\n config.blocksHandlers.forEach((otherHandler: Handler): void => {\n if (typeof otherHandler === 'number') {\n blocksHandlers.push(otherHandler);\n } else {\n blocksHandlers.push(otherHandler.handlerTag);\n }\n });\n\n this.blocksHandlersRelations.set(handler.getTag(), blocksHandlers);\n }\n }\n\n public shouldWaitForHandlerFailure(\n handler: GestureHandler,\n otherHandler: GestureHandler\n ): boolean {\n const waitFor: number[] | undefined = this.waitForRelations.get(\n handler.getTag()\n );\n\n return (\n waitFor?.find((tag: number) => {\n return tag === otherHandler.getTag();\n }) !== undefined\n );\n }\n\n public shouldRecognizeSimultaneously(\n handler: GestureHandler,\n otherHandler: GestureHandler\n ): boolean {\n const simultaneousHandlers: number[] | undefined =\n this.simultaneousRelations.get(handler.getTag());\n\n return (\n simultaneousHandlers?.find((tag: number) => {\n return tag === otherHandler.getTag();\n }) !== undefined\n );\n }\n\n public shouldRequireHandlerToWaitForFailure(\n handler: GestureHandler,\n otherHandler: GestureHandler\n ): boolean {\n const waitFor: number[] | undefined = this.blocksHandlersRelations.get(\n handler.getTag()\n );\n\n return (\n waitFor?.find((tag: number) => {\n return tag === otherHandler.getTag();\n }) !== undefined\n );\n }\n\n public shouldHandlerBeCancelledBy(\n _handler: GestureHandler,\n _otherHandler: GestureHandler\n ): boolean {\n //TODO: Implement logic\n return false;\n }\n\n public dropRelationsForHandlerWithTag(handlerTag: number): void {\n this.waitForRelations.delete(handlerTag);\n this.simultaneousRelations.delete(handlerTag);\n this.blocksHandlersRelations.delete(handlerTag);\n }\n\n public reset() {\n this.waitForRelations.clear();\n this.simultaneousRelations.clear();\n this.blocksHandlersRelations.clear();\n }\n\n public static getInstance(): InteractionManager {\n if (!this.instance) {\n this.instance = new InteractionManager();\n }\n\n return this.instance;\n }\n}\n"]}
1
+ {"version":3,"sources":["InteractionManager.ts"],"names":["InteractionManager","constructor","Map","configureInteractions","handler","config","dropRelationsForHandlerWithTag","getTag","waitFor","forEach","otherHandler","push","handlerTag","waitForRelations","set","simultaneousHandlers","simultaneousRelations","blocksHandlers","blocksHandlersRelations","shouldWaitForHandlerFailure","get","find","tag","undefined","shouldRecognizeSimultaneously","shouldRequireHandlerToWaitForFailure","shouldHandlerBeCancelledBy","_handler","isNativeHandler","name","isActive","getState","State","ACTIVE","isButton","delete","reset","clear","getInstance","instance"],"mappings":";;;;;;;AACA;;;;AAGe,MAAMA,kBAAN,CAAyB;AAMtC;AACA;AACQC,EAAAA,WAAW,GAAG;AAAA,8CANqC,IAAIC,GAAJ,EAMrC;;AAAA,mDAL0C,IAAIA,GAAJ,EAK1C;;AAAA,qDAJ4C,IAAIA,GAAJ,EAI5C;AAAE;;AAEjBC,EAAAA,qBAAqB,CAACC,OAAD,EAA2BC,MAA3B,EAA2C;AACrE,SAAKC,8BAAL,CAAoCF,OAAO,CAACG,MAAR,EAApC;;AAEA,QAAIF,MAAM,CAACG,OAAX,EAAoB;AAClB,YAAMA,OAAiB,GAAG,EAA1B;AACAH,MAAAA,MAAM,CAACG,OAAP,CAAeC,OAAf,CAAwBC,YAAD,IAAiC;AACtD;AACA,YAAI,OAAOA,YAAP,KAAwB,QAA5B,EAAsC;AACpCF,UAAAA,OAAO,CAACG,IAAR,CAAaD,YAAb;AACD,SAFD,MAEO;AACL;A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AAL,CAAsBsB,MAAtB,CAA6BvB,UAA7B;AACA,SAAKI,qBAAL,CAA2BmB,MAA3B,CAAkCvB,UAAlC;AACA,SAAKM,uBAAL,CAA6BiB,MAA7B,CAAoCvB,UAApC;AACD;;AAEMwB,EAAAA,KAAK,GAAG;AACb,SAAKvB,gBAAL,CAAsBwB,KAAtB;AACA,SAAKrB,qBAAL,CAA2BqB,KAA3B;AACA,SAAKnB,uBAAL,CAA6BmB,KAA7B;AACD;;AAEwB,SAAXC,WAAW,GAAuB;AAC9C,QAAI,CAAC,KAAKC,QAAV,EAAoB;AAClB,WAAKA,QAAL,GAAgB,IAAIvC,kBAAJ,EAAhB;AACD;;AAED,WAAO,KAAKuC,QAAZ;AACD;;AAlIqC;;;;gBAAnBvC,kB","sourcesContent":["import type IGestureHandler from '../handlers/IGestureHandler';\nimport { State } from '../../State';\nimport { Config, Handler } from '../interfaces';\n\nexport default class InteractionManager {\n private static instance: InteractionManager;\n private readonly waitForRelations: Map<number, number[]> = new Map();\n private readonly simultaneousRelations: Map<number, number[]> = new Map();\n private readonly blocksHandlersRelations: Map<number, number[]> = new Map();\n\n // Private becaues of singleton\n // eslint-disable-next-line no-useless-constructor, @typescript-eslint/no-empty-function\n private constructor() {}\n\n public configureInteractions(handler: IGestureHandler, config: Config) {\n this.dropRelationsForHandlerWithTag(handler.getTag());\n\n if (config.waitFor) {\n const waitFor: number[] = [];\n config.waitFor.forEach((otherHandler: Handler): void => {\n // New API reference\n if (typeof otherHandler === 'number') {\n waitFor.push(otherHandler);\n } else {\n // Old API reference\n waitFor.push(otherHandler.handlerTag);\n }\n });\n\n this.waitForRelations.set(handler.getTag(), waitFor);\n }\n\n if (config.simultaneousHandlers) {\n const simultaneousHandlers: number[] = [];\n config.simultaneousHandlers.forEach((otherHandler: Handler): void => {\n if (typeof otherHandler === 'number') {\n simultaneousHandlers.push(otherHandler);\n } else {\n simultaneousHandlers.push(otherHandler.handlerTag);\n }\n });\n\n this.simultaneousRelations.set(handler.getTag(), simultaneousHandlers);\n }\n\n if (config.blocksHandlers) {\n const blocksHandlers: number[] = [];\n config.blocksHandlers.forEach((otherHandler: Handler): void => {\n if (typeof otherHandler === 'number') {\n blocksHandlers.push(otherHandler);\n } else {\n blocksHandlers.push(otherHandler.handlerTag);\n }\n });\n\n this.blocksHandlersRelations.set(handler.getTag(), blocksHandlers);\n }\n }\n\n public shouldWaitForHandlerFailure(\n handler: IGestureHandler,\n otherHandler: IGestureHandler\n ): boolean {\n const waitFor: number[] | undefined = this.waitForRelations.get(\n handler.getTag()\n );\n\n return (\n waitFor?.find((tag: number) => {\n return tag === otherHandler.getTag();\n }) !== undefined\n );\n }\n\n public shouldRecognizeSimultaneously(\n handler: IGestureHandler,\n otherHandler: IGestureHandler\n ): boolean {\n const simultaneousHandlers: number[] | undefined =\n this.simultaneousRelations.get(handler.getTag());\n\n return (\n simultaneousHandlers?.find((tag: number) => {\n return tag === otherHandler.getTag();\n }) !== undefined\n );\n }\n\n public shouldRequireHandlerToWaitForFailure(\n handler: IGestureHandler,\n otherHandler: IGestureHandler\n ): boolean {\n const waitFor: number[] | undefined = this.blocksHandlersRelations.get(\n handler.getTag()\n );\n\n return (\n waitFor?.find((tag: number) => {\n return tag === otherHandler.getTag();\n }) !== undefined\n );\n }\n\n public shouldHandlerBeCancelledBy(\n _handler: IGestureHandler,\n otherHandler: IGestureHandler\n ): boolean {\n // We check constructor name instead of using `instanceof` in order do avoid circular dependencies\n const isNativeHandler =\n otherHandler.constructor.name === 'NativeViewGestureHandler';\n const isActive = otherHandler.getState() === State.ACTIVE;\n const isButton = otherHandler.isButton?.() === true;\n\n return isNativeHandler && isActive && !isButton;\n }\n\n public dropRelationsForHandlerWithTag(handlerTag: number): void {\n this.waitForRelations.delete(handlerTag);\n this.simultaneousRelations.delete(handlerTag);\n this.blocksHandlersRelations.delete(handlerTag);\n }\n\n public reset() {\n this.waitForRelations.clear();\n this.simultaneousRelations.clear();\n this.blocksHandlersRelations.clear();\n }\n\n public static getInstance(): InteractionManager {\n if (!this.instance) {\n this.instance = new InteractionManager();\n }\n\n return this.instance;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["NodeManager.ts"],"names":["NodeManager","getHandler","tag","gestures","Error","createGestureHandler","handlerTag","handler","setTag","dropGestureHandler","onDestroy","getNodes"],"mappings":";;;;;;;;;AAGA;AACe,MAAeA,WAAf,CAA2B;AAMhB,SAAVC,UAAU,CAACC,GAAD,EAAc;AACpC,QAAIA,GAAG,IAAI,KAAKC,QAAhB,EAA0B;AACxB,aAAO,KAAKA,QAAL,CAAcD,GAAd,CAAP;AACD;;AAED,UAAM,IAAIE,KAAJ,CAAW,sBAAqBF,GAAI,EAApC,CAAN;AACD;;AAEiC,SAApBG,oBAAoB,CAChCC,UADgC,EAEhCC,OAFgC,EAG1B;AACN,QAAID,UAAU,IAAI,KAAKH,QAAvB,EAAiC;AAC/B,YAAM,IAAIC,KAAJ,CACH,oBAAmBE,UAAW,mGAD3B,CAAN;AAGD;;AAED,SAAKH,QAAL,CAAcG,UAAd,IAA4BC,OAA5B;AACA,SAAKJ,QAAL,CAAcG,UAAd,EAA0BE,MAA1B,CAAiCF,UAAjC;AACD;;AAE+B,SAAlBG,kBAAkB,CAACH,UAAD,EAA2B;AACzD,QAAI,EAAEA,UAAU,IAAI,KAAKH,QAArB,CAAJ,EAAoC;AAClC;AACD;;AAED,SAAKA,QAAL,CAAcG,UAAd,EAA0BI,SAA1B,GALyD,CAOzD;;AACA,WAAO,KAAKP,QAAL,CAAcG,UAAd,CAAP;AACD;;AAEqB,SAARK,QAAQ,GAAG;AACvB,WAAO,EAAE,GAAG,KAAKR;AAAV,KAAP;AACD;;AAzCuC;;;;gBAAZH,W,cAIxB,E","sourcesContent":["import { ValueOf } from '../../typeUtils';\nimport { Gestures } from '../../RNGestureHandlerModule.web';\n\n// eslint-disable-next-line @typescript-eslint/no-extraneous-class\nexport default abstract class NodeManager {\n private static gestures: Record<\n number,\n InstanceType<ValueOf<typeof Gestures>>\n > = {};\n\n public static getHandler(tag: number) {\n if (tag in this.gestures) {\n return this.gestures[tag];\n }\n\n throw new Error(`No handler for tag ${tag}`);\n }\n\n public static createGestureHandler(\n handlerTag: number,\n handler: InstanceType<ValueOf<typeof Gestures>>\n ): void {\n if (handlerTag in this.gestures) {\n throw new Error(\n `Handler with tag ${handlerTag} already exists. Please ensure that no Gesture instance is used across multiple GestureDetectors.`\n );\n }\n\n this.gestures[handlerTag] = handler;\n this.gestures[handlerTag].setTag(handlerTag);\n }\n\n public static dropGestureHandler(handlerTag: number): void {\n if (!(handlerTag in this.gestures)) {\n return;\n }\n\n this.gestures[handlerTag].onDestroy();\n\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this.gestures[handlerTag];\n }\n\n public static getNodes() {\n return { ...this.gestures };\n }\n}\n"]}
1
+ {"version":3,"sources":["NodeManager.ts"],"names":["NodeManager","getHandler","tag","gestures","Error","createGestureHandler","handlerTag","handler","setTag","dropGestureHandler","onDestroy","getNodes"],"mappings":";;;;;;;;;AAIA;AACe,MAAeA,WAAf,CAA2B;AAMhB,SAAVC,UAAU,CAACC,GAAD,EAA+B;AACrD,QAAIA,GAAG,IAAI,KAAKC,QAAhB,EAA0B;AACxB,aAAO,KAAKA,QAAL,CAAcD,GAAd,CAAP;AACD;;AAED,UAAM,IAAIE,KAAJ,CAAW,sBAAqBF,GAAI,EAApC,CAAN;AACD;;AAEiC,SAApBG,oBAAoB,CAChCC,UADgC,EAEhCC,OAFgC,EAG1B;AACN,QAAID,UAAU,IAAI,KAAKH,QAAvB,EAAiC;AAC/B,YAAM,IAAIC,KAAJ,CACH,oBAAmBE,UAAW,mGAD3B,CAAN;AAGD;;AAED,SAAKH,QAAL,CAAcG,UAAd,IAA4BC,OAA5B;AACA,SAAKJ,QAAL,CAAcG,UAAd,EAA0BE,MAA1B,CAAiCF,UAAjC;AACD;;AAE+B,SAAlBG,kBAAkB,CAACH,UAAD,EAA2B;AACzD,QAAI,EAAEA,UAAU,IAAI,KAAKH,QAArB,CAAJ,EAAoC;AAClC;AACD;;AAED,SAAKA,QAAL,CAAcG,UAAd,EAA0BI,SAA1B,GALyD,CAOzD;;AACA,WAAO,KAAKP,QAAL,CAAcG,UAAd,CAAP;AACD;;AAEqB,SAARK,QAAQ,GAAG;AACvB,WAAO,EAAE,GAAG,KAAKR;AAAV,KAAP;AACD;;AAzCuC;;;;gBAAZH,W,cAIxB,E","sourcesContent":["import { ValueOf } from '../../typeUtils';\nimport { Gestures } from '../Gestures';\nimport type IGestureHandler from '../handlers/IGestureHandler';\n\n// eslint-disable-next-line @typescript-eslint/no-extraneous-class\nexport default abstract class NodeManager {\n private static gestures: Record<\n number,\n InstanceType<ValueOf<typeof Gestures>>\n > = {};\n\n public static getHandler(tag: number): IGestureHandler {\n if (tag in this.gestures) {\n return this.gestures[tag] as IGestureHandler;\n }\n\n throw new Error(`No handler for tag ${tag}`);\n }\n\n public static createGestureHandler(\n handlerTag: number,\n handler: InstanceType<ValueOf<typeof Gestures>>\n ): void {\n if (handlerTag in this.gestures) {\n throw new Error(\n `Handler with tag ${handlerTag} already exists. Please ensure that no Gesture instance is used across multiple GestureDetectors.`\n );\n }\n\n this.gestures[handlerTag] = handler;\n this.gestures[handlerTag].setTag(handlerTag);\n }\n\n public static dropGestureHandler(handlerTag: number): void {\n if (!(handlerTag in this.gestures)) {\n return;\n }\n\n this.gestures[handlerTag].onDestroy();\n\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete this.gestures[handlerTag];\n }\n\n public static getNodes() {\n return { ...this.gestures };\n }\n}\n"]}