react-native-gesture-handler 2.26.0 → 2.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (415) hide show
  1. package/README.md +69 -0
  2. package/android/src/main/jni/CMakeLists.txt +7 -26
  3. package/lib/commonjs/components/Pressable/Pressable.js +139 -188
  4. package/lib/commonjs/components/Pressable/Pressable.js.map +1 -1
  5. package/lib/commonjs/components/Pressable/StateMachine.js +38 -0
  6. package/lib/commonjs/components/Pressable/StateMachine.js.map +1 -0
  7. package/lib/commonjs/components/Pressable/stateDefinitions.js +88 -0
  8. package/lib/commonjs/components/Pressable/stateDefinitions.js.map +1 -0
  9. package/lib/commonjs/components/Pressable/utils.js +1 -1
  10. package/lib/commonjs/components/Pressable/utils.js.map +1 -1
  11. package/lib/commonjs/handlers/gestures/forceTouchGesture.js +12 -0
  12. package/lib/commonjs/handlers/gestures/forceTouchGesture.js.map +1 -1
  13. package/lib/commonjs/handlers/gestures/gestureObjects.js +3 -1
  14. package/lib/commonjs/handlers/gestures/gestureObjects.js.map +1 -1
  15. package/lib/commonjs/web/detectors/RotationGestureDetector.js +3 -0
  16. package/lib/commonjs/web/detectors/RotationGestureDetector.js.map +1 -1
  17. package/lib/commonjs/web/handlers/FlingGestureHandler.js +3 -0
  18. package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
  19. package/lib/commonjs/web/handlers/GestureHandler.js +6 -6
  20. package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
  21. package/lib/commonjs/web/handlers/PanGestureHandler.js +24 -33
  22. package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
  23. package/lib/commonjs/web/handlers/TapGestureHandler.js +15 -17
  24. package/lib/commonjs/web/handlers/TapGestureHandler.js.map +1 -1
  25. package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js +1 -1
  26. package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js.map +1 -1
  27. package/lib/commonjs/web/tools/PointerEventManager.js +1 -1
  28. package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
  29. package/lib/commonjs/web/tools/PointerTracker.js +12 -11
  30. package/lib/commonjs/web/tools/PointerTracker.js.map +1 -1
  31. package/lib/commonjs/web/tools/Vector.js +1 -1
  32. package/lib/commonjs/web/tools/Vector.js.map +1 -1
  33. package/lib/module/components/Pressable/Pressable.js +141 -190
  34. package/lib/module/components/Pressable/Pressable.js.map +1 -1
  35. package/lib/module/components/Pressable/StateMachine.js +34 -0
  36. package/lib/module/components/Pressable/StateMachine.js.map +1 -0
  37. package/lib/module/components/Pressable/stateDefinitions.js +83 -0
  38. package/lib/module/components/Pressable/stateDefinitions.js.map +1 -0
  39. package/lib/module/components/Pressable/utils.js +1 -1
  40. package/lib/module/components/Pressable/utils.js.map +1 -1
  41. package/lib/module/handlers/gestures/forceTouchGesture.js +13 -0
  42. package/lib/module/handlers/gestures/forceTouchGesture.js.map +1 -1
  43. package/lib/module/handlers/gestures/gestureObjects.js +3 -1
  44. package/lib/module/handlers/gestures/gestureObjects.js.map +1 -1
  45. package/lib/module/web/detectors/RotationGestureDetector.js +3 -0
  46. package/lib/module/web/detectors/RotationGestureDetector.js.map +1 -1
  47. package/lib/module/web/handlers/FlingGestureHandler.js +3 -0
  48. package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
  49. package/lib/module/web/handlers/GestureHandler.js +6 -6
  50. package/lib/module/web/handlers/GestureHandler.js.map +1 -1
  51. package/lib/module/web/handlers/PanGestureHandler.js +24 -33
  52. package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
  53. package/lib/module/web/handlers/TapGestureHandler.js +15 -17
  54. package/lib/module/web/handlers/TapGestureHandler.js.map +1 -1
  55. package/lib/module/web/tools/GestureHandlerOrchestrator.js +1 -1
  56. package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
  57. package/lib/module/web/tools/PointerEventManager.js +1 -1
  58. package/lib/module/web/tools/PointerEventManager.js.map +1 -1
  59. package/lib/module/web/tools/PointerTracker.js +12 -11
  60. package/lib/module/web/tools/PointerTracker.js.map +1 -1
  61. package/lib/module/web/tools/Vector.js +1 -1
  62. package/lib/module/web/tools/Vector.js.map +1 -1
  63. package/lib/typescript/ActionType.d.ts +0 -1
  64. package/lib/typescript/ActionType.js +6 -0
  65. package/lib/typescript/Directions.d.ts +0 -1
  66. package/lib/typescript/Directions.js +18 -0
  67. package/lib/typescript/EnableNewWebImplementation.d.ts +0 -1
  68. package/lib/typescript/EnableNewWebImplementation.js +30 -0
  69. package/lib/typescript/GestureHandlerRootViewContext.d.ts +0 -1
  70. package/lib/typescript/GestureHandlerRootViewContext.js +2 -0
  71. package/lib/typescript/PlatformConstants.d.ts +0 -1
  72. package/lib/typescript/PlatformConstants.js +3 -0
  73. package/lib/typescript/PlatformConstants.web.d.ts +0 -1
  74. package/lib/typescript/PlatformConstants.web.js +5 -0
  75. package/lib/typescript/PointerType.d.ts +0 -1
  76. package/lib/typescript/PointerType.js +8 -0
  77. package/lib/typescript/RNGestureHandlerModule.d.ts +0 -1
  78. package/lib/typescript/RNGestureHandlerModule.js +4 -0
  79. package/lib/typescript/RNGestureHandlerModule.web.d.ts +0 -1
  80. package/lib/typescript/RNGestureHandlerModule.web.js +92 -0
  81. package/lib/typescript/RNGestureHandlerModule.windows.d.ts +0 -1
  82. package/lib/typescript/RNGestureHandlerModule.windows.js +47 -0
  83. package/lib/typescript/RNRenderer.d.ts +0 -1
  84. package/lib/typescript/RNRenderer.js +3 -0
  85. package/lib/typescript/RNRenderer.web.d.ts +0 -1
  86. package/lib/typescript/RNRenderer.web.js +3 -0
  87. package/lib/typescript/State.d.ts +0 -1
  88. package/lib/typescript/State.js +9 -0
  89. package/lib/typescript/TouchEventType.d.ts +0 -1
  90. package/lib/typescript/TouchEventType.js +7 -0
  91. package/lib/typescript/components/DrawerLayout.d.ts +0 -1
  92. package/lib/typescript/components/DrawerLayout.js +417 -0
  93. package/lib/typescript/components/GestureButtons.d.ts +0 -1
  94. package/lib/typescript/components/GestureButtons.js +165 -0
  95. package/lib/typescript/components/GestureButtonsProps.d.ts +0 -1
  96. package/lib/typescript/components/GestureButtonsProps.js +1 -0
  97. package/lib/typescript/components/GestureComponents.d.ts +0 -1
  98. package/lib/typescript/components/GestureComponents.js +67 -0
  99. package/lib/typescript/components/GestureComponents.web.d.ts +0 -1
  100. package/lib/typescript/components/GestureComponents.web.js +21 -0
  101. package/lib/typescript/components/GestureHandlerButton.d.ts +0 -1
  102. package/lib/typescript/components/GestureHandlerButton.js +2 -0
  103. package/lib/typescript/components/GestureHandlerButton.web.d.ts +0 -1
  104. package/lib/typescript/components/GestureHandlerButton.web.js +3 -0
  105. package/lib/typescript/components/GestureHandlerRootView.android.d.ts +0 -1
  106. package/lib/typescript/components/GestureHandlerRootView.android.js +17 -0
  107. package/lib/typescript/components/GestureHandlerRootView.d.ts +0 -1
  108. package/lib/typescript/components/GestureHandlerRootView.js +16 -0
  109. package/lib/typescript/components/GestureHandlerRootView.web.d.ts +0 -1
  110. package/lib/typescript/components/GestureHandlerRootView.web.js +11 -0
  111. package/lib/typescript/components/Pressable/Pressable.d.ts +1 -3
  112. package/lib/typescript/components/Pressable/Pressable.d.ts.map +1 -1
  113. package/lib/typescript/components/Pressable/Pressable.js +231 -0
  114. package/lib/typescript/components/Pressable/PressableProps.d.ts +15 -2
  115. package/lib/typescript/components/Pressable/PressableProps.d.ts.map +1 -1
  116. package/lib/typescript/components/Pressable/PressableProps.js +1 -0
  117. package/lib/typescript/components/Pressable/StateMachine.d.ts +14 -0
  118. package/lib/typescript/components/Pressable/StateMachine.d.ts.map +1 -0
  119. package/lib/typescript/components/Pressable/StateMachine.js +34 -0
  120. package/lib/typescript/components/Pressable/index.d.ts +0 -1
  121. package/lib/typescript/components/Pressable/index.js +1 -0
  122. package/lib/typescript/components/Pressable/stateDefinitions.d.ts +9 -0
  123. package/lib/typescript/components/Pressable/stateDefinitions.d.ts.map +1 -0
  124. package/lib/typescript/components/Pressable/stateDefinitions.js +104 -0
  125. package/lib/typescript/components/Pressable/utils.d.ts +3 -7
  126. package/lib/typescript/components/Pressable/utils.d.ts.map +1 -1
  127. package/lib/typescript/components/Pressable/utils.js +80 -0
  128. package/lib/typescript/components/ReanimatedDrawerLayout.d.ts +0 -1
  129. package/lib/typescript/components/ReanimatedDrawerLayout.js +364 -0
  130. package/lib/typescript/components/ReanimatedSwipeable.d.ts +0 -1
  131. package/lib/typescript/components/ReanimatedSwipeable.js +400 -0
  132. package/lib/typescript/components/Swipeable.d.ts +0 -1
  133. package/lib/typescript/components/Swipeable.js +287 -0
  134. package/lib/typescript/components/Text.d.ts +0 -1
  135. package/lib/typescript/components/Text.js +38 -0
  136. package/lib/typescript/components/gestureHandlerRootHOC.d.ts +0 -1
  137. package/lib/typescript/components/gestureHandlerRootHOC.js +18 -0
  138. package/lib/typescript/components/touchables/ExtraButtonProps.d.ts +0 -1
  139. package/lib/typescript/components/touchables/ExtraButtonProps.js +1 -0
  140. package/lib/typescript/components/touchables/GenericTouchable.d.ts +0 -1
  141. package/lib/typescript/components/touchables/GenericTouchable.js +221 -0
  142. package/lib/typescript/components/touchables/GenericTouchableProps.d.ts +0 -1
  143. package/lib/typescript/components/touchables/GenericTouchableProps.js +1 -0
  144. package/lib/typescript/components/touchables/TouchableHighlight.d.ts +0 -1
  145. package/lib/typescript/components/touchables/TouchableHighlight.js +75 -0
  146. package/lib/typescript/components/touchables/TouchableNativeFeedback.android.d.ts +0 -1
  147. package/lib/typescript/components/touchables/TouchableNativeFeedback.android.js +65 -0
  148. package/lib/typescript/components/touchables/TouchableNativeFeedback.d.ts +0 -1
  149. package/lib/typescript/components/touchables/TouchableNativeFeedback.js +6 -0
  150. package/lib/typescript/components/touchables/TouchableNativeFeedbackProps.d.ts +0 -1
  151. package/lib/typescript/components/touchables/TouchableNativeFeedbackProps.js +1 -0
  152. package/lib/typescript/components/touchables/TouchableOpacity.d.ts +0 -1
  153. package/lib/typescript/components/touchables/TouchableOpacity.js +51 -0
  154. package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts +0 -1
  155. package/lib/typescript/components/touchables/TouchableWithoutFeedback.js +10 -0
  156. package/lib/typescript/components/touchables/index.d.ts +0 -1
  157. package/lib/typescript/components/touchables/index.js +4 -0
  158. package/lib/typescript/components/utils.d.ts +0 -1
  159. package/lib/typescript/components/utils.js +11 -0
  160. package/lib/typescript/findNodeHandle.d.ts +0 -1
  161. package/lib/typescript/findNodeHandle.js +2 -0
  162. package/lib/typescript/findNodeHandle.web.d.ts +0 -1
  163. package/lib/typescript/findNodeHandle.web.js +31 -0
  164. package/lib/typescript/getShadowNodeFromRef.d.ts +0 -1
  165. package/lib/typescript/getShadowNodeFromRef.js +45 -0
  166. package/lib/typescript/getShadowNodeFromRef.web.d.ts +0 -1
  167. package/lib/typescript/getShadowNodeFromRef.web.js +7 -0
  168. package/lib/typescript/ghQueueMicrotask.d.ts +0 -1
  169. package/lib/typescript/ghQueueMicrotask.js +7 -0
  170. package/lib/typescript/handlers/FlingGestureHandler.d.ts +0 -1
  171. package/lib/typescript/handlers/FlingGestureHandler.js +19 -0
  172. package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +0 -1
  173. package/lib/typescript/handlers/ForceTouchGestureHandler.js +37 -0
  174. package/lib/typescript/handlers/GestureHandlerEventPayload.d.ts +3 -1
  175. package/lib/typescript/handlers/GestureHandlerEventPayload.d.ts.map +1 -1
  176. package/lib/typescript/handlers/GestureHandlerEventPayload.js +1 -0
  177. package/lib/typescript/handlers/LongPressGestureHandler.d.ts +0 -1
  178. package/lib/typescript/handlers/LongPressGestureHandler.js +22 -0
  179. package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +0 -1
  180. package/lib/typescript/handlers/NativeViewGestureHandler.js +20 -0
  181. package/lib/typescript/handlers/PanGestureHandler.d.ts +0 -1
  182. package/lib/typescript/handlers/PanGestureHandler.js +128 -0
  183. package/lib/typescript/handlers/PinchGestureHandler.d.ts +0 -1
  184. package/lib/typescript/handlers/PinchGestureHandler.js +12 -0
  185. package/lib/typescript/handlers/PressabilityDebugView.d.ts +0 -1
  186. package/lib/typescript/handlers/PressabilityDebugView.js +2 -0
  187. package/lib/typescript/handlers/PressabilityDebugView.web.d.ts +0 -1
  188. package/lib/typescript/handlers/PressabilityDebugView.web.js +4 -0
  189. package/lib/typescript/handlers/RotationGestureHandler.d.ts +0 -1
  190. package/lib/typescript/handlers/RotationGestureHandler.js +12 -0
  191. package/lib/typescript/handlers/TapGestureHandler.d.ts +0 -1
  192. package/lib/typescript/handlers/TapGestureHandler.js +26 -0
  193. package/lib/typescript/handlers/createHandler.d.ts +0 -1
  194. package/lib/typescript/handlers/createHandler.js +375 -0
  195. package/lib/typescript/handlers/createNativeWrapper.d.ts +0 -1
  196. package/lib/typescript/handlers/createNativeWrapper.js +67 -0
  197. package/lib/typescript/handlers/customDirectEventTypes.d.ts +0 -1
  198. package/lib/typescript/handlers/customDirectEventTypes.js +2 -0
  199. package/lib/typescript/handlers/customDirectEventTypes.web.d.ts +0 -1
  200. package/lib/typescript/handlers/customDirectEventTypes.web.js +4 -0
  201. package/lib/typescript/handlers/gestureHandlerCommon.d.ts +0 -1
  202. package/lib/typescript/handlers/gestureHandlerCommon.js +42 -0
  203. package/lib/typescript/handlers/gestureHandlerTypesCompat.d.ts +9 -1
  204. package/lib/typescript/handlers/gestureHandlerTypesCompat.d.ts.map +1 -1
  205. package/lib/typescript/handlers/gestureHandlerTypesCompat.js +1 -0
  206. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.d.ts +0 -1
  207. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.js +22 -0
  208. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.web.d.ts +0 -1
  209. package/lib/typescript/handlers/gestures/GestureDetector/Wrap.web.js +24 -0
  210. package/lib/typescript/handlers/gestures/GestureDetector/attachHandlers.d.ts +0 -1
  211. package/lib/typescript/handlers/gestures/GestureDetector/attachHandlers.js +55 -0
  212. package/lib/typescript/handlers/gestures/GestureDetector/dropHandlers.d.ts +0 -1
  213. package/lib/typescript/handlers/gestures/GestureDetector/dropHandlers.js +12 -0
  214. package/lib/typescript/handlers/gestures/GestureDetector/index.d.ts +0 -1
  215. package/lib/typescript/handlers/gestures/GestureDetector/index.js +114 -0
  216. package/lib/typescript/handlers/gestures/GestureDetector/needsToReattach.d.ts +0 -1
  217. package/lib/typescript/handlers/gestures/GestureDetector/needsToReattach.js +18 -0
  218. package/lib/typescript/handlers/gestures/GestureDetector/types.d.ts +0 -1
  219. package/lib/typescript/handlers/gestures/GestureDetector/types.js +1 -0
  220. package/lib/typescript/handlers/gestures/GestureDetector/updateHandlers.d.ts +0 -1
  221. package/lib/typescript/handlers/gestures/GestureDetector/updateHandlers.js +54 -0
  222. package/lib/typescript/handlers/gestures/GestureDetector/useAnimatedGesture.d.ts +0 -1
  223. package/lib/typescript/handlers/gestures/GestureDetector/useAnimatedGesture.js +137 -0
  224. package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.d.ts +0 -1
  225. package/lib/typescript/handlers/gestures/GestureDetector/useDetectorUpdater.js +48 -0
  226. package/lib/typescript/handlers/gestures/GestureDetector/useMountReactions.d.ts +0 -1
  227. package/lib/typescript/handlers/gestures/GestureDetector/useMountReactions.js +35 -0
  228. package/lib/typescript/handlers/gestures/GestureDetector/useViewRefHandler.d.ts +0 -1
  229. package/lib/typescript/handlers/gestures/GestureDetector/useViewRefHandler.js +32 -0
  230. package/lib/typescript/handlers/gestures/GestureDetector/utils.d.ts +0 -1
  231. package/lib/typescript/handlers/gestures/GestureDetector/utils.js +140 -0
  232. package/lib/typescript/handlers/gestures/eventReceiver.d.ts +0 -1
  233. package/lib/typescript/handlers/gestures/eventReceiver.js +105 -0
  234. package/lib/typescript/handlers/gestures/flingGesture.d.ts +0 -1
  235. package/lib/typescript/handlers/gestures/flingGesture.js +27 -0
  236. package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +9 -1
  237. package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts.map +1 -1
  238. package/lib/typescript/handlers/gestures/forceTouchGesture.js +57 -0
  239. package/lib/typescript/handlers/gestures/gesture.d.ts +0 -1
  240. package/lib/typescript/handlers/gestures/gesture.js +303 -0
  241. package/lib/typescript/handlers/gestures/gestureComposition.d.ts +0 -1
  242. package/lib/typescript/handlers/gestures/gestureComposition.js +78 -0
  243. package/lib/typescript/handlers/gestures/gestureObjects.d.ts +3 -2
  244. package/lib/typescript/handlers/gestures/gestureObjects.d.ts.map +1 -1
  245. package/lib/typescript/handlers/gestures/gestureObjects.js +125 -0
  246. package/lib/typescript/handlers/gestures/gestureStateManager.d.ts +0 -1
  247. package/lib/typescript/handlers/gestures/gestureStateManager.js +60 -0
  248. package/lib/typescript/handlers/gestures/gestureStateManager.web.d.ts +0 -1
  249. package/lib/typescript/handlers/gestures/gestureStateManager.web.js +19 -0
  250. package/lib/typescript/handlers/gestures/hoverGesture.d.ts +0 -1
  251. package/lib/typescript/handlers/gestures/hoverGesture.js +45 -0
  252. package/lib/typescript/handlers/gestures/longPressGesture.d.ts +0 -1
  253. package/lib/typescript/handlers/gestures/longPressGesture.js +35 -0
  254. package/lib/typescript/handlers/gestures/manualGesture.d.ts +0 -1
  255. package/lib/typescript/handlers/gestures/manualGesture.js +16 -0
  256. package/lib/typescript/handlers/gestures/nativeGesture.d.ts +0 -1
  257. package/lib/typescript/handlers/gestures/nativeGesture.js +24 -0
  258. package/lib/typescript/handlers/gestures/panGesture.d.ts +0 -1
  259. package/lib/typescript/handlers/gestures/panGesture.js +181 -0
  260. package/lib/typescript/handlers/gestures/pinchGesture.d.ts +0 -1
  261. package/lib/typescript/handlers/gestures/pinchGesture.js +27 -0
  262. package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts +0 -1
  263. package/lib/typescript/handlers/gestures/reanimatedWrapper.js +23 -0
  264. package/lib/typescript/handlers/gestures/rotationGesture.d.ts +0 -1
  265. package/lib/typescript/handlers/gestures/rotationGesture.js +27 -0
  266. package/lib/typescript/handlers/gestures/tapGesture.d.ts +0 -1
  267. package/lib/typescript/handlers/gestures/tapGesture.js +72 -0
  268. package/lib/typescript/handlers/getNextHandlerTag.d.ts +0 -1
  269. package/lib/typescript/handlers/getNextHandlerTag.js +4 -0
  270. package/lib/typescript/handlers/handlersRegistry.d.ts +0 -1
  271. package/lib/typescript/handlers/handlersRegistry.js +36 -0
  272. package/lib/typescript/handlers/utils.d.ts +0 -1
  273. package/lib/typescript/handlers/utils.js +58 -0
  274. package/lib/typescript/index.d.ts +0 -1
  275. package/lib/typescript/index.js +28 -0
  276. package/lib/typescript/init.d.ts +0 -1
  277. package/lib/typescript/init.js +15 -0
  278. package/lib/typescript/jestUtils/index.d.ts +0 -1
  279. package/lib/typescript/jestUtils/index.js +1 -0
  280. package/lib/typescript/jestUtils/jestUtils.d.ts +0 -1
  281. package/lib/typescript/jestUtils/jestUtils.js +290 -0
  282. package/lib/typescript/mocks.d.ts +0 -1
  283. package/lib/typescript/mocks.js +59 -0
  284. package/lib/typescript/mountRegistry.d.ts +0 -1
  285. package/lib/typescript/mountRegistry.js +29 -0
  286. package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts +0 -1
  287. package/lib/typescript/specs/NativeRNGestureHandlerModule.js +2 -0
  288. package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.d.ts +0 -1
  289. package/lib/typescript/specs/RNGestureHandlerButtonNativeComponent.js +2 -0
  290. package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.d.ts +0 -1
  291. package/lib/typescript/specs/RNGestureHandlerRootViewNativeComponent.js +2 -0
  292. package/lib/typescript/typeUtils.d.ts +0 -1
  293. package/lib/typescript/typeUtils.js +1 -0
  294. package/lib/typescript/utils.d.ts +0 -1
  295. package/lib/typescript/utils.js +80 -0
  296. package/lib/typescript/web/Gestures.d.ts +0 -1
  297. package/lib/typescript/web/Gestures.js +38 -0
  298. package/lib/typescript/web/constants.d.ts +0 -1
  299. package/lib/typescript/web/constants.js +2 -0
  300. package/lib/typescript/web/detectors/RotationGestureDetector.d.ts +0 -1
  301. package/lib/typescript/web/detectors/RotationGestureDetector.d.ts.map +1 -1
  302. package/lib/typescript/web/detectors/RotationGestureDetector.js +122 -0
  303. package/lib/typescript/web/detectors/ScaleGestureDetector.d.ts +0 -1
  304. package/lib/typescript/web/detectors/ScaleGestureDetector.js +117 -0
  305. package/lib/typescript/web/handlers/FlingGestureHandler.d.ts +0 -1
  306. package/lib/typescript/web/handlers/FlingGestureHandler.d.ts.map +1 -1
  307. package/lib/typescript/web/handlers/FlingGestureHandler.js +133 -0
  308. package/lib/typescript/web/handlers/GestureHandler.d.ts +0 -1
  309. package/lib/typescript/web/handlers/GestureHandler.d.ts.map +1 -1
  310. package/lib/typescript/web/handlers/GestureHandler.js +656 -0
  311. package/lib/typescript/web/handlers/HoverGestureHandler.d.ts +0 -1
  312. package/lib/typescript/web/handlers/HoverGestureHandler.js +37 -0
  313. package/lib/typescript/web/handlers/IGestureHandler.d.ts +0 -1
  314. package/lib/typescript/web/handlers/IGestureHandler.js +1 -0
  315. package/lib/typescript/web/handlers/LongPressGestureHandler.d.ts +0 -1
  316. package/lib/typescript/web/handlers/LongPressGestureHandler.js +136 -0
  317. package/lib/typescript/web/handlers/ManualGestureHandler.d.ts +0 -1
  318. package/lib/typescript/web/handlers/ManualGestureHandler.js +29 -0
  319. package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +0 -1
  320. package/lib/typescript/web/handlers/NativeViewGestureHandler.js +133 -0
  321. package/lib/typescript/web/handlers/PanGestureHandler.d.ts +2 -1
  322. package/lib/typescript/web/handlers/PanGestureHandler.d.ts.map +1 -1
  323. package/lib/typescript/web/handlers/PanGestureHandler.js +420 -0
  324. package/lib/typescript/web/handlers/PinchGestureHandler.d.ts +0 -1
  325. package/lib/typescript/web/handlers/PinchGestureHandler.js +117 -0
  326. package/lib/typescript/web/handlers/RotationGestureHandler.d.ts +0 -1
  327. package/lib/typescript/web/handlers/RotationGestureHandler.js +122 -0
  328. package/lib/typescript/web/handlers/TapGestureHandler.d.ts +1 -1
  329. package/lib/typescript/web/handlers/TapGestureHandler.d.ts.map +1 -1
  330. package/lib/typescript/web/handlers/TapGestureHandler.js +202 -0
  331. package/lib/typescript/web/interfaces.d.ts +0 -1
  332. package/lib/typescript/web/interfaces.js +25 -0
  333. package/lib/typescript/web/tools/CircularBuffer.d.ts +0 -1
  334. package/lib/typescript/web/tools/CircularBuffer.js +37 -0
  335. package/lib/typescript/web/tools/EventManager.d.ts +0 -1
  336. package/lib/typescript/web/tools/EventManager.js +85 -0
  337. package/lib/typescript/web/tools/GestureHandlerDelegate.d.ts +0 -1
  338. package/lib/typescript/web/tools/GestureHandlerDelegate.js +1 -0
  339. package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts +0 -1
  340. package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts.map +1 -1
  341. package/lib/typescript/web/tools/GestureHandlerOrchestrator.js +273 -0
  342. package/lib/typescript/web/tools/GestureHandlerWebDelegate.d.ts +0 -1
  343. package/lib/typescript/web/tools/GestureHandlerWebDelegate.js +169 -0
  344. package/lib/typescript/web/tools/InteractionManager.d.ts +0 -1
  345. package/lib/typescript/web/tools/InteractionManager.js +91 -0
  346. package/lib/typescript/web/tools/KeyboardEventManager.d.ts +0 -1
  347. package/lib/typescript/web/tools/KeyboardEventManager.js +73 -0
  348. package/lib/typescript/web/tools/LeastSquareSolver.d.ts +0 -1
  349. package/lib/typescript/web/tools/LeastSquareSolver.js +147 -0
  350. package/lib/typescript/web/tools/NodeManager.d.ts +0 -1
  351. package/lib/typescript/web/tools/NodeManager.js +28 -0
  352. package/lib/typescript/web/tools/PointerEventManager.d.ts +0 -1
  353. package/lib/typescript/web/tools/PointerEventManager.js +179 -0
  354. package/lib/typescript/web/tools/PointerTracker.d.ts +3 -4
  355. package/lib/typescript/web/tools/PointerTracker.d.ts.map +1 -1
  356. package/lib/typescript/web/tools/PointerTracker.js +161 -0
  357. package/lib/typescript/web/tools/Vector.d.ts +1 -2
  358. package/lib/typescript/web/tools/Vector.js +43 -0
  359. package/lib/typescript/web/tools/VelocityTracker.d.ts +0 -1
  360. package/lib/typescript/web/tools/VelocityTracker.js +76 -0
  361. package/lib/typescript/web/tools/WheelEventManager.d.ts +0 -1
  362. package/lib/typescript/web/tools/WheelEventManager.js +40 -0
  363. package/lib/typescript/web/utils.d.ts +0 -1
  364. package/lib/typescript/web/utils.js +233 -0
  365. package/lib/typescript/web_hammer/DiscreteGestureHandler.d.ts +0 -1
  366. package/lib/typescript/web_hammer/DiscreteGestureHandler.js +48 -0
  367. package/lib/typescript/web_hammer/DraggingGestureHandler.d.ts +0 -1
  368. package/lib/typescript/web_hammer/DraggingGestureHandler.js +25 -0
  369. package/lib/typescript/web_hammer/Errors.d.ts +0 -1
  370. package/lib/typescript/web_hammer/Errors.js +5 -0
  371. package/lib/typescript/web_hammer/FlingGestureHandler.d.ts +0 -1
  372. package/lib/typescript/web_hammer/FlingGestureHandler.js +119 -0
  373. package/lib/typescript/web_hammer/GestureHandler.d.ts +0 -1
  374. package/lib/typescript/web_hammer/GestureHandler.js +469 -0
  375. package/lib/typescript/web_hammer/IndiscreteGestureHandler.d.ts +0 -1
  376. package/lib/typescript/web_hammer/IndiscreteGestureHandler.js +26 -0
  377. package/lib/typescript/web_hammer/LongPressGestureHandler.d.ts +0 -1
  378. package/lib/typescript/web_hammer/LongPressGestureHandler.js +46 -0
  379. package/lib/typescript/web_hammer/NativeViewGestureHandler.d.ts +0 -1
  380. package/lib/typescript/web_hammer/NativeViewGestureHandler.js +40 -0
  381. package/lib/typescript/web_hammer/NodeManager.d.ts +0 -1
  382. package/lib/typescript/web_hammer/NodeManager.js +28 -0
  383. package/lib/typescript/web_hammer/PanGestureHandler.d.ts +0 -1
  384. package/lib/typescript/web_hammer/PanGestureHandler.js +151 -0
  385. package/lib/typescript/web_hammer/PinchGestureHandler.d.ts +0 -1
  386. package/lib/typescript/web_hammer/PinchGestureHandler.js +19 -0
  387. package/lib/typescript/web_hammer/PressGestureHandler.d.ts +0 -1
  388. package/lib/typescript/web_hammer/PressGestureHandler.js +133 -0
  389. package/lib/typescript/web_hammer/RotationGestureHandler.d.ts +0 -1
  390. package/lib/typescript/web_hammer/RotationGestureHandler.js +20 -0
  391. package/lib/typescript/web_hammer/TapGestureHandler.d.ts +0 -1
  392. package/lib/typescript/web_hammer/TapGestureHandler.js +142 -0
  393. package/lib/typescript/web_hammer/constants.d.ts +0 -1
  394. package/lib/typescript/web_hammer/constants.js +42 -0
  395. package/lib/typescript/web_hammer/utils.d.ts +0 -1
  396. package/lib/typescript/web_hammer/utils.js +15 -0
  397. package/package.json +4 -2
  398. package/src/components/Pressable/Pressable.tsx +357 -445
  399. package/src/components/Pressable/PressableProps.tsx +15 -0
  400. package/src/components/Pressable/StateMachine.tsx +49 -0
  401. package/src/components/Pressable/stateDefinitions.ts +125 -0
  402. package/src/components/Pressable/utils.ts +11 -7
  403. package/src/handlers/GestureHandlerEventPayload.ts +3 -0
  404. package/src/handlers/gestureHandlerTypesCompat.ts +9 -0
  405. package/src/handlers/gestures/forceTouchGesture.ts +9 -0
  406. package/src/handlers/gestures/gestureObjects.ts +3 -1
  407. package/src/web/detectors/RotationGestureDetector.ts +4 -0
  408. package/src/web/handlers/FlingGestureHandler.ts +4 -0
  409. package/src/web/handlers/GestureHandler.ts +9 -3
  410. package/src/web/handlers/PanGestureHandler.ts +25 -36
  411. package/src/web/handlers/TapGestureHandler.ts +14 -19
  412. package/src/web/tools/GestureHandlerOrchestrator.ts +1 -0
  413. package/src/web/tools/PointerEventManager.ts +1 -1
  414. package/src/web/tools/PointerTracker.ts +17 -15
  415. package/src/web/tools/Vector.ts +1 -1
@@ -0,0 +1,122 @@
1
+ import { EventTypes } from '../interfaces';
2
+ export default class RotationGestureDetector {
3
+ onRotationBegin;
4
+ onRotation;
5
+ onRotationEnd;
6
+ currentTime = 0;
7
+ previousTime = 0;
8
+ previousAngle = 0;
9
+ _rotation = 0;
10
+ _anchorX = 0;
11
+ _anchorY = 0;
12
+ isInProgress = false;
13
+ keyPointers = [NaN, NaN];
14
+ constructor(callbacks) {
15
+ this.onRotationBegin = callbacks.onRotationBegin;
16
+ this.onRotation = callbacks.onRotation;
17
+ this.onRotationEnd = callbacks.onRotationEnd;
18
+ }
19
+ updateCurrent(event, tracker) {
20
+ this.previousTime = this.currentTime;
21
+ this.currentTime = event.time;
22
+ const [firstPointerID, secondPointerID] = this.keyPointers;
23
+ const firstPointerCoords = tracker.getLastAbsoluteCoords(firstPointerID);
24
+ const secondPointerCoords = tracker.getLastAbsoluteCoords(secondPointerID);
25
+ if (!firstPointerCoords || !secondPointerCoords) {
26
+ return;
27
+ }
28
+ const vectorX = secondPointerCoords.x - firstPointerCoords.x;
29
+ const vectorY = secondPointerCoords.y - firstPointerCoords.y;
30
+ this._anchorX = (firstPointerCoords.x + secondPointerCoords.x) / 2;
31
+ this._anchorY = (firstPointerCoords.y + secondPointerCoords.y) / 2;
32
+ // Angle diff should be positive when rotating in clockwise direction
33
+ const angle = -Math.atan2(vectorY, vectorX);
34
+ this._rotation = Number.isNaN(this.previousAngle)
35
+ ? 0
36
+ : this.previousAngle - angle;
37
+ this.previousAngle = angle;
38
+ if (this.rotation > Math.PI) {
39
+ this._rotation -= Math.PI;
40
+ }
41
+ else if (this.rotation < -Math.PI) {
42
+ this._rotation += Math.PI;
43
+ }
44
+ if (this.rotation > Math.PI / 2) {
45
+ this._rotation -= Math.PI;
46
+ }
47
+ else if (this.rotation < -Math.PI / 2) {
48
+ this._rotation += Math.PI;
49
+ }
50
+ }
51
+ finish() {
52
+ if (!this.isInProgress) {
53
+ return;
54
+ }
55
+ this.isInProgress = false;
56
+ this.keyPointers = [NaN, NaN];
57
+ this.onRotationEnd(this);
58
+ }
59
+ setKeyPointers(tracker) {
60
+ if (this.keyPointers[0] && this.keyPointers[1]) {
61
+ return;
62
+ }
63
+ const pointerIDs = tracker.trackedPointers.keys();
64
+ this.keyPointers[0] = pointerIDs.next().value;
65
+ this.keyPointers[1] = pointerIDs.next().value;
66
+ }
67
+ onTouchEvent(event, tracker) {
68
+ switch (event.eventType) {
69
+ case EventTypes.DOWN:
70
+ this.isInProgress = false;
71
+ break;
72
+ case EventTypes.ADDITIONAL_POINTER_DOWN:
73
+ if (this.isInProgress) {
74
+ break;
75
+ }
76
+ this.isInProgress = true;
77
+ this.previousTime = event.time;
78
+ this.previousAngle = NaN;
79
+ this.setKeyPointers(tracker);
80
+ this.updateCurrent(event, tracker);
81
+ this.onRotationBegin(this);
82
+ break;
83
+ case EventTypes.MOVE:
84
+ if (!this.isInProgress) {
85
+ break;
86
+ }
87
+ this.updateCurrent(event, tracker);
88
+ this.onRotation(this);
89
+ break;
90
+ case EventTypes.ADDITIONAL_POINTER_UP:
91
+ if (!this.isInProgress) {
92
+ break;
93
+ }
94
+ if (this.keyPointers.indexOf(event.pointerId) >= 0) {
95
+ this.finish();
96
+ }
97
+ break;
98
+ case EventTypes.UP:
99
+ if (this.isInProgress) {
100
+ this.finish();
101
+ }
102
+ break;
103
+ }
104
+ return true;
105
+ }
106
+ reset() {
107
+ this.keyPointers = [NaN, NaN];
108
+ this.isInProgress = false;
109
+ }
110
+ get anchorX() {
111
+ return this._anchorX;
112
+ }
113
+ get anchorY() {
114
+ return this._anchorY;
115
+ }
116
+ get rotation() {
117
+ return this._rotation;
118
+ }
119
+ get timeDelta() {
120
+ return this.currentTime + this.previousTime;
121
+ }
122
+ }
@@ -27,4 +27,3 @@ export default class ScaleGestureDetector implements ScaleGestureListener {
27
27
  get focusY(): number;
28
28
  get timeDelta(): number;
29
29
  }
30
- //# sourceMappingURL=ScaleGestureDetector.d.ts.map
@@ -0,0 +1,117 @@
1
+ import { DEFAULT_TOUCH_SLOP } from '../constants';
2
+ import { EventTypes } from '../interfaces';
3
+ export default class ScaleGestureDetector {
4
+ onScaleBegin;
5
+ onScale;
6
+ onScaleEnd;
7
+ _focusX;
8
+ _focusY;
9
+ _currentSpan;
10
+ prevSpan;
11
+ initialSpan;
12
+ currentTime;
13
+ prevTime;
14
+ inProgress = false;
15
+ spanSlop;
16
+ minSpan;
17
+ constructor(callbacks) {
18
+ this.onScaleBegin = callbacks.onScaleBegin;
19
+ this.onScale = callbacks.onScale;
20
+ this.onScaleEnd = callbacks.onScaleEnd;
21
+ this.spanSlop = DEFAULT_TOUCH_SLOP * 2;
22
+ this.minSpan = 0;
23
+ }
24
+ onTouchEvent(event, tracker) {
25
+ this.currentTime = event.time;
26
+ const action = event.eventType;
27
+ const numOfPointers = tracker.trackedPointersCount;
28
+ const streamComplete = action === EventTypes.UP ||
29
+ action === EventTypes.ADDITIONAL_POINTER_UP ||
30
+ action === EventTypes.CANCEL;
31
+ if (action === EventTypes.DOWN || streamComplete) {
32
+ if (this.inProgress) {
33
+ this.onScaleEnd(this);
34
+ this.inProgress = false;
35
+ this.initialSpan = 0;
36
+ }
37
+ if (streamComplete) {
38
+ return true;
39
+ }
40
+ }
41
+ const configChanged = action === EventTypes.DOWN ||
42
+ action === EventTypes.ADDITIONAL_POINTER_UP ||
43
+ action === EventTypes.ADDITIONAL_POINTER_DOWN;
44
+ const pointerUp = action === EventTypes.ADDITIONAL_POINTER_UP;
45
+ const ignoredPointer = pointerUp
46
+ ? event.pointerId
47
+ : undefined;
48
+ // Determine focal point
49
+ const div = pointerUp ? numOfPointers - 1 : numOfPointers;
50
+ const coordsSum = tracker.getAbsoluteCoordsSum();
51
+ const focusX = coordsSum.x / div;
52
+ const focusY = coordsSum.y / div;
53
+ // Determine average deviation from focal point
54
+ let devSumX = 0;
55
+ let devSumY = 0;
56
+ tracker.trackedPointers.forEach((value, key) => {
57
+ if (key === ignoredPointer) {
58
+ return;
59
+ }
60
+ devSumX += Math.abs(value.abosoluteCoords.x - focusX);
61
+ devSumY += Math.abs(value.abosoluteCoords.y - focusY);
62
+ });
63
+ const devX = devSumX / div;
64
+ const devY = devSumY / div;
65
+ const spanX = devX * 2;
66
+ const spanY = devY * 2;
67
+ const span = Math.hypot(spanX, spanY);
68
+ // Begin/end events
69
+ const wasInProgress = this.inProgress;
70
+ this._focusX = focusX;
71
+ this._focusY = focusY;
72
+ if (this.inProgress && (span < this.minSpan || configChanged)) {
73
+ this.onScaleEnd(this);
74
+ this.inProgress = false;
75
+ this.initialSpan = span;
76
+ }
77
+ if (configChanged) {
78
+ this.initialSpan = this.prevSpan = this._currentSpan = span;
79
+ }
80
+ if (!this.inProgress &&
81
+ span >= this.minSpan &&
82
+ (wasInProgress || Math.abs(span - this.initialSpan) > this.spanSlop)) {
83
+ this.prevSpan = this._currentSpan = span;
84
+ this.prevTime = this.currentTime;
85
+ this.inProgress = this.onScaleBegin(this);
86
+ }
87
+ // Handle motion
88
+ if (action !== EventTypes.MOVE) {
89
+ return true;
90
+ }
91
+ this._currentSpan = span;
92
+ if (this.inProgress && !this.onScale(this)) {
93
+ return true;
94
+ }
95
+ this.prevSpan = this.currentSpan;
96
+ this.prevTime = this.currentTime;
97
+ return true;
98
+ }
99
+ calculateScaleFactor(numOfPointers) {
100
+ if (numOfPointers < 2) {
101
+ return 1;
102
+ }
103
+ return this.prevSpan > 0 ? this.currentSpan / this.prevSpan : 1;
104
+ }
105
+ get currentSpan() {
106
+ return this._currentSpan;
107
+ }
108
+ get focusX() {
109
+ return this._focusX;
110
+ }
111
+ get focusY() {
112
+ return this._focusY;
113
+ }
114
+ get timeDelta() {
115
+ return this.currentTime - this.prevTime;
116
+ }
117
+ }
@@ -24,4 +24,3 @@ export default class FlingGestureHandler extends GestureHandler {
24
24
  activate(force?: boolean): void;
25
25
  protected resetConfig(): void;
26
26
  }
27
- //# sourceMappingURL=FlingGestureHandler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FlingGestureHandler.d.ts","sourceRoot":"","sources":["../../../../src/web/handlers/FlingGestureHandler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAa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;IAC7D,OAAO,CAAC,wBAAwB,CAAsC;IACtE,OAAO,CAAC,SAAS,CAAiC;IAElD,OAAO,CAAC,aAAa,CAA2B;IAChD,OAAO,CAAC,WAAW,CAAwB;IAC3C,OAAO,CAAC,YAAY,CAAU;IAE9B,OAAO,CAAC,iCAAiC,CAAK;IAC9C,OAAO,CAAC,UAAU,CAAO;IAElB,mBAAmB,CAAC,EAAE,OAAc,EAAE,GAAG,KAAK,EAAE,EAAE,MAAM,GAAG,IAAI;IAYtE,OAAO,CAAC,UAAU;IAQlB,OAAO,CAAC,WAAW;IAoDnB,OAAO,CAAC,QAAQ;IAMhB,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAclD,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAMjD,OAAO,CAAC,gBAAgB;IAmBxB,OAAO,CAAC,iBAAiB;IAUzB,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAKlD,SAAS,CAAC,oBAAoB,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAKzD,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAOhD,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAKpD,OAAO,CAAC,IAAI;IAQL,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI;IAKtC,SAAS,CAAC,WAAW,IAAI,IAAI;CAK9B"}
@@ -0,0 +1,133 @@
1
+ import { State } from '../../State';
2
+ import { DiagonalDirections, Directions } from '../../Directions';
3
+ import GestureHandler from './GestureHandler';
4
+ import Vector from '../tools/Vector';
5
+ import { coneToDeviation } from '../utils';
6
+ const DEFAULT_MAX_DURATION_MS = 800;
7
+ const DEFAULT_MIN_VELOCITY = 700;
8
+ const DEFAULT_ALIGNMENT_CONE = 30;
9
+ const DEFAULT_DIRECTION = Directions.RIGHT;
10
+ const DEFAULT_NUMBER_OF_TOUCHES_REQUIRED = 1;
11
+ const AXIAL_DEVIATION_COSINE = coneToDeviation(DEFAULT_ALIGNMENT_CONE);
12
+ const DIAGONAL_DEVIATION_COSINE = coneToDeviation(90 - DEFAULT_ALIGNMENT_CONE);
13
+ export default class FlingGestureHandler extends GestureHandler {
14
+ numberOfPointersRequired = DEFAULT_NUMBER_OF_TOUCHES_REQUIRED;
15
+ direction = DEFAULT_DIRECTION;
16
+ maxDurationMs = DEFAULT_MAX_DURATION_MS;
17
+ minVelocity = DEFAULT_MIN_VELOCITY;
18
+ delayTimeout;
19
+ maxNumberOfPointersSimultaneously = 0;
20
+ keyPointer = NaN;
21
+ updateGestureConfig({ enabled = true, ...props }) {
22
+ super.updateGestureConfig({ enabled: enabled, ...props });
23
+ if (this.config.direction) {
24
+ this.direction = this.config.direction;
25
+ }
26
+ if (this.config.numberOfPointers) {
27
+ this.numberOfPointersRequired = this.config.numberOfPointers;
28
+ }
29
+ }
30
+ startFling() {
31
+ this.begin();
32
+ this.maxNumberOfPointersSimultaneously = 1;
33
+ this.delayTimeout = setTimeout(() => this.fail(), this.maxDurationMs);
34
+ }
35
+ tryEndFling() {
36
+ const velocityVector = Vector.fromVelocity(this.tracker, this.keyPointer);
37
+ if (!velocityVector) {
38
+ return false;
39
+ }
40
+ const getAlignment = (direction, minimalAlignmentCosine) => {
41
+ return ((direction & this.direction) === direction &&
42
+ velocityVector.isSimilar(Vector.fromDirection(direction), minimalAlignmentCosine));
43
+ };
44
+ const axialDirectionsList = Object.values(Directions);
45
+ const diagonalDirectionsList = Object.values(DiagonalDirections);
46
+ // List of alignments to all activated directions
47
+ const axialAlignmentList = axialDirectionsList.map((direction) => getAlignment(direction, AXIAL_DEVIATION_COSINE));
48
+ const diagonalAlignmentList = diagonalDirectionsList.map((direction) => getAlignment(direction, DIAGONAL_DEVIATION_COSINE));
49
+ const isAligned = axialAlignmentList.some(Boolean) || diagonalAlignmentList.some(Boolean);
50
+ const isFast = velocityVector.magnitude > this.minVelocity;
51
+ if (this.maxNumberOfPointersSimultaneously ===
52
+ this.numberOfPointersRequired &&
53
+ isAligned &&
54
+ isFast) {
55
+ clearTimeout(this.delayTimeout);
56
+ this.activate();
57
+ return true;
58
+ }
59
+ return false;
60
+ }
61
+ endFling() {
62
+ if (!this.tryEndFling()) {
63
+ this.fail();
64
+ }
65
+ }
66
+ onPointerDown(event) {
67
+ if (!this.isButtonInConfig(event.button)) {
68
+ return;
69
+ }
70
+ this.tracker.addToTracker(event);
71
+ this.keyPointer = event.pointerId;
72
+ super.onPointerDown(event);
73
+ this.newPointerAction();
74
+ this.tryToSendTouchEvent(event);
75
+ }
76
+ onPointerAdd(event) {
77
+ this.tracker.addToTracker(event);
78
+ super.onPointerAdd(event);
79
+ this.newPointerAction();
80
+ }
81
+ newPointerAction() {
82
+ if (this.state === State.UNDETERMINED) {
83
+ this.startFling();
84
+ }
85
+ if (this.state !== State.BEGAN) {
86
+ return;
87
+ }
88
+ this.tryEndFling();
89
+ if (this.tracker.trackedPointersCount > this.maxNumberOfPointersSimultaneously) {
90
+ this.maxNumberOfPointersSimultaneously =
91
+ this.tracker.trackedPointersCount;
92
+ }
93
+ }
94
+ pointerMoveAction(event) {
95
+ this.tracker.track(event);
96
+ if (this.state !== State.BEGAN) {
97
+ return;
98
+ }
99
+ this.tryEndFling();
100
+ }
101
+ onPointerMove(event) {
102
+ this.pointerMoveAction(event);
103
+ super.onPointerMove(event);
104
+ }
105
+ onPointerOutOfBounds(event) {
106
+ this.pointerMoveAction(event);
107
+ super.onPointerOutOfBounds(event);
108
+ }
109
+ onPointerUp(event) {
110
+ super.onPointerUp(event);
111
+ this.onUp(event);
112
+ this.keyPointer = NaN;
113
+ }
114
+ onPointerRemove(event) {
115
+ super.onPointerRemove(event);
116
+ this.onUp(event);
117
+ }
118
+ onUp(event) {
119
+ if (this.state === State.BEGAN) {
120
+ this.endFling();
121
+ }
122
+ this.tracker.removeFromTracker(event.pointerId);
123
+ }
124
+ activate(force) {
125
+ super.activate(force);
126
+ this.end();
127
+ }
128
+ resetConfig() {
129
+ super.resetConfig();
130
+ this.numberOfPointersRequired = DEFAULT_NUMBER_OF_TOUCHES_REQUIRED;
131
+ this.direction = DEFAULT_DIRECTION;
132
+ }
133
+ }
@@ -100,4 +100,3 @@ export default abstract class GestureHandler implements IGestureHandler {
100
100
  getTrackedPointersID(): number[];
101
101
  private isFinished;
102
102
  }
103
- //# sourceMappingURL=GestureHandler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GestureHandler.d.ts","sourceRoot":"","sources":["../../../../src/web/handlers/GestureHandler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EACL,MAAM,EACN,YAAY,EAOb,MAAM,eAAe,CAAC;AACvB,OAAO,YAAY,MAAM,uBAAuB,CAAC;AAGjD,OAAO,cAAkC,MAAM,yBAAyB,CAAC;AACzE,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAEzE,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,cAAe,YAAW,eAAe;IACrE,OAAO,CAAC,aAAa,CAAsB;IAE3C,OAAO,CAAC,MAAM,CAA6B;IAE3C,OAAO,CAAC,wBAAwB,CAAS;IACzC,SAAS,CAAC,2BAA2B,UAAS;IAC9C,OAAO,CAAC,QAAQ,CAAS;IAEzB,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,QAAQ,CAA4B;IAC5C,OAAO,CAAC,WAAW,CAAU;IAC7B,OAAO,CAAC,OAAO,CAA8B;IAE7C,OAAO,CAAC,QAAQ,CAAwC;IAGxD,OAAO,CAAC,gBAAgB,CAAK;IAE7B,OAAO,CAAC,SAAS,CAAS;IAC1B,O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