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,420 @@
1
+ import { State } from '../../State';
2
+ import { DEFAULT_TOUCH_SLOP } from '../constants';
3
+ import { WheelDevice } from '../interfaces';
4
+ import GestureHandler from './GestureHandler';
5
+ const DEFAULT_MIN_POINTERS = 1;
6
+ const DEFAULT_MAX_POINTERS = 10;
7
+ const DEFAULT_MIN_DIST_SQ = DEFAULT_TOUCH_SLOP * DEFAULT_TOUCH_SLOP;
8
+ export default class PanGestureHandler extends GestureHandler {
9
+ customActivationProperties = [
10
+ 'activeOffsetXStart',
11
+ 'activeOffsetXEnd',
12
+ 'failOffsetXStart',
13
+ 'failOffsetXEnd',
14
+ 'activeOffsetYStart',
15
+ 'activeOffsetYEnd',
16
+ 'failOffsetYStart',
17
+ 'failOffsetYEnd',
18
+ 'minVelocityX',
19
+ 'minVelocityY',
20
+ 'minVelocity',
21
+ ];
22
+ velocityX = 0;
23
+ velocityY = 0;
24
+ minDistSq = DEFAULT_MIN_DIST_SQ;
25
+ activeOffsetXStart = -Number.MAX_SAFE_INTEGER;
26
+ activeOffsetXEnd = Number.MIN_SAFE_INTEGER;
27
+ failOffsetXStart = Number.MIN_SAFE_INTEGER;
28
+ failOffsetXEnd = Number.MAX_SAFE_INTEGER;
29
+ activeOffsetYStart = Number.MAX_SAFE_INTEGER;
30
+ activeOffsetYEnd = Number.MIN_SAFE_INTEGER;
31
+ failOffsetYStart = Number.MIN_SAFE_INTEGER;
32
+ failOffsetYEnd = Number.MAX_SAFE_INTEGER;
33
+ minVelocityX = Number.MAX_SAFE_INTEGER;
34
+ minVelocityY = Number.MAX_SAFE_INTEGER;
35
+ minVelocitySq = Number.MAX_SAFE_INTEGER;
36
+ minPointers = DEFAULT_MIN_POINTERS;
37
+ maxPointers = DEFAULT_MAX_POINTERS;
38
+ startX = 0;
39
+ startY = 0;
40
+ offsetX = 0;
41
+ offsetY = 0;
42
+ lastX = 0;
43
+ lastY = 0;
44
+ stylusData;
45
+ activateAfterLongPress = 0;
46
+ activationTimeout = 0;
47
+ enableTrackpadTwoFingerGesture = false;
48
+ endWheelTimeout = 0;
49
+ wheelDevice = WheelDevice.UNDETERMINED;
50
+ updateGestureConfig({ enabled = true, ...props }) {
51
+ this.resetConfig();
52
+ super.updateGestureConfig({ enabled: enabled, ...props });
53
+ this.checkCustomActivationCriteria(this.customActivationProperties);
54
+ if (this.config.minDist !== undefined) {
55
+ this.minDistSq = this.config.minDist * this.config.minDist;
56
+ }
57
+ else if (this.hasCustomActivationCriteria) {
58
+ this.minDistSq = Number.MAX_SAFE_INTEGER;
59
+ }
60
+ if (this.config.minPointers !== undefined) {
61
+ this.minPointers = this.config.minPointers;
62
+ }
63
+ if (this.config.maxPointers !== undefined) {
64
+ this.maxPointers = this.config.maxPointers;
65
+ }
66
+ if (this.config.minVelocity !== undefined) {
67
+ this.minVelocityX = this.config.minVelocity;
68
+ this.minVelocityY = this.config.minVelocity;
69
+ }
70
+ if (this.config.minVelocityX !== undefined) {
71
+ this.minVelocityX = this.config.minVelocityX;
72
+ }
73
+ if (this.config.minVelocityY !== undefined) {
74
+ this.minVelocityY = this.config.minVelocityY;
75
+ }
76
+ if (this.config.activateAfterLongPress !== undefined) {
77
+ this.activateAfterLongPress = this.config.activateAfterLongPress;
78
+ }
79
+ if (this.config.activeOffsetXStart !== undefined) {
80
+ this.activeOffsetXStart = this.config.activeOffsetXStart;
81
+ if (this.config.activeOffsetXEnd === undefined) {
82
+ this.activeOffsetXEnd = Number.MAX_SAFE_INTEGER;
83
+ }
84
+ }
85
+ if (this.config.activeOffsetXEnd !== undefined) {
86
+ this.activeOffsetXEnd = this.config.activeOffsetXEnd;
87
+ if (this.config.activeOffsetXStart === undefined) {
88
+ this.activeOffsetXStart = Number.MIN_SAFE_INTEGER;
89
+ }
90
+ }
91
+ if (this.config.failOffsetXStart !== undefined) {
92
+ this.failOffsetXStart = this.config.failOffsetXStart;
93
+ if (this.config.failOffsetXEnd === undefined) {
94
+ this.failOffsetXEnd = Number.MAX_SAFE_INTEGER;
95
+ }
96
+ }
97
+ if (this.config.failOffsetXEnd !== undefined) {
98
+ this.failOffsetXEnd = this.config.failOffsetXEnd;
99
+ if (this.config.failOffsetXStart === undefined) {
100
+ this.failOffsetXStart = Number.MIN_SAFE_INTEGER;
101
+ }
102
+ }
103
+ if (this.config.activeOffsetYStart !== undefined) {
104
+ this.activeOffsetYStart = this.config.activeOffsetYStart;
105
+ if (this.config.activeOffsetYEnd === undefined) {
106
+ this.activeOffsetYEnd = Number.MAX_SAFE_INTEGER;
107
+ }
108
+ }
109
+ if (this.config.activeOffsetYEnd !== undefined) {
110
+ this.activeOffsetYEnd = this.config.activeOffsetYEnd;
111
+ if (this.config.activeOffsetYStart === undefined) {
112
+ this.activeOffsetYStart = Number.MIN_SAFE_INTEGER;
113
+ }
114
+ }
115
+ if (this.config.failOffsetYStart !== undefined) {
116
+ this.failOffsetYStart = this.config.failOffsetYStart;
117
+ if (this.config.failOffsetYEnd === undefined) {
118
+ this.failOffsetYEnd = Number.MAX_SAFE_INTEGER;
119
+ }
120
+ }
121
+ if (this.config.failOffsetYEnd !== undefined) {
122
+ this.failOffsetYEnd = this.config.failOffsetYEnd;
123
+ if (this.config.failOffsetYStart === undefined) {
124
+ this.failOffsetYStart = Number.MIN_SAFE_INTEGER;
125
+ }
126
+ }
127
+ if (this.config.enableTrackpadTwoFingerGesture !== undefined) {
128
+ this.enableTrackpadTwoFingerGesture =
129
+ this.config.enableTrackpadTwoFingerGesture;
130
+ }
131
+ }
132
+ resetConfig() {
133
+ super.resetConfig();
134
+ this.activeOffsetXStart = -Number.MAX_SAFE_INTEGER;
135
+ this.activeOffsetXEnd = Number.MIN_SAFE_INTEGER;
136
+ this.failOffsetXStart = Number.MIN_SAFE_INTEGER;
137
+ this.failOffsetXEnd = Number.MAX_SAFE_INTEGER;
138
+ this.activeOffsetYStart = Number.MAX_SAFE_INTEGER;
139
+ this.activeOffsetYEnd = Number.MIN_SAFE_INTEGER;
140
+ this.failOffsetYStart = Number.MIN_SAFE_INTEGER;
141
+ this.failOffsetYEnd = Number.MAX_SAFE_INTEGER;
142
+ this.minVelocityX = Number.MAX_SAFE_INTEGER;
143
+ this.minVelocityY = Number.MAX_SAFE_INTEGER;
144
+ this.minVelocitySq = Number.MAX_SAFE_INTEGER;
145
+ this.minDistSq = DEFAULT_MIN_DIST_SQ;
146
+ this.minPointers = DEFAULT_MIN_POINTERS;
147
+ this.maxPointers = DEFAULT_MAX_POINTERS;
148
+ this.activateAfterLongPress = 0;
149
+ }
150
+ transformNativeEvent() {
151
+ const translationX = this.getTranslationX();
152
+ const translationY = this.getTranslationY();
153
+ return {
154
+ ...super.transformNativeEvent(),
155
+ translationX: isNaN(translationX) ? 0 : translationX,
156
+ translationY: isNaN(translationY) ? 0 : translationY,
157
+ velocityX: this.velocityX,
158
+ velocityY: this.velocityY,
159
+ stylusData: this.stylusData,
160
+ };
161
+ }
162
+ getTranslationX() {
163
+ return this.lastX - this.startX + this.offsetX;
164
+ }
165
+ getTranslationY() {
166
+ return this.lastY - this.startY + this.offsetY;
167
+ }
168
+ clearActivationTimeout() {
169
+ clearTimeout(this.activationTimeout);
170
+ }
171
+ updateLastCoords() {
172
+ const { x, y } = this.tracker.getAbsoluteCoordsAverage();
173
+ this.lastX = x;
174
+ this.lastY = y;
175
+ }
176
+ updateVelocity(pointerId) {
177
+ const velocities = this.tracker.getVelocity(pointerId);
178
+ this.velocityX = velocities?.x ?? 0;
179
+ this.velocityY = velocities?.y ?? 0;
180
+ }
181
+ // Events Handling
182
+ onPointerDown(event) {
183
+ if (!this.isButtonInConfig(event.button)) {
184
+ return;
185
+ }
186
+ this.tracker.addToTracker(event);
187
+ this.stylusData = event.stylusData;
188
+ super.onPointerDown(event);
189
+ this.updateLastCoords();
190
+ this.startX = this.lastX;
191
+ this.startY = this.lastY;
192
+ this.tryBegin(event);
193
+ this.checkBegan();
194
+ this.tryToSendTouchEvent(event);
195
+ }
196
+ onPointerAdd(event) {
197
+ this.tracker.addToTracker(event);
198
+ super.onPointerAdd(event);
199
+ this.tryBegin(event);
200
+ this.offsetX += this.lastX - this.startX;
201
+ this.offsetY += this.lastY - this.startY;
202
+ this.updateLastCoords();
203
+ this.startX = this.lastX;
204
+ this.startY = this.lastY;
205
+ if (this.tracker.trackedPointersCount > this.maxPointers) {
206
+ if (this.state === State.ACTIVE) {
207
+ this.cancel();
208
+ }
209
+ else {
210
+ this.fail();
211
+ }
212
+ }
213
+ else {
214
+ this.checkBegan();
215
+ }
216
+ }
217
+ onPointerUp(event) {
218
+ this.stylusData = event.stylusData;
219
+ super.onPointerUp(event);
220
+ if (this.state === State.ACTIVE) {
221
+ const lastCoords = this.tracker.getAbsoluteCoordsAverage();
222
+ this.lastX = lastCoords.x;
223
+ this.lastY = lastCoords.y;
224
+ }
225
+ this.tracker.removeFromTracker(event.pointerId);
226
+ if (this.tracker.trackedPointersCount === 0) {
227
+ this.clearActivationTimeout();
228
+ }
229
+ if (this.state === State.ACTIVE) {
230
+ this.end();
231
+ }
232
+ else {
233
+ this.resetProgress();
234
+ this.fail();
235
+ }
236
+ }
237
+ onPointerRemove(event) {
238
+ super.onPointerRemove(event);
239
+ this.tracker.removeFromTracker(event.pointerId);
240
+ this.offsetX += this.lastX - this.startX;
241
+ this.offsetY += this.lastY - this.startY;
242
+ this.updateLastCoords();
243
+ this.startX = this.lastX;
244
+ this.startY = this.lastY;
245
+ if (!(this.state === State.ACTIVE &&
246
+ this.tracker.trackedPointersCount < this.minPointers)) {
247
+ this.checkBegan();
248
+ }
249
+ }
250
+ onPointerMove(event) {
251
+ this.tracker.track(event);
252
+ this.stylusData = event.stylusData;
253
+ this.updateLastCoords();
254
+ this.updateVelocity(event.pointerId);
255
+ this.checkBegan();
256
+ super.onPointerMove(event);
257
+ }
258
+ onPointerOutOfBounds(event) {
259
+ if (this.shouldCancelWhenOutside) {
260
+ return;
261
+ }
262
+ this.tracker.track(event);
263
+ this.stylusData = event.stylusData;
264
+ this.updateLastCoords();
265
+ this.updateVelocity(event.pointerId);
266
+ this.checkBegan();
267
+ if (this.state === State.ACTIVE) {
268
+ super.onPointerOutOfBounds(event);
269
+ }
270
+ }
271
+ scheduleWheelEnd(event) {
272
+ clearTimeout(this.endWheelTimeout);
273
+ this.endWheelTimeout = setTimeout(() => {
274
+ if (this.state === State.ACTIVE) {
275
+ this.end();
276
+ this.tracker.removeFromTracker(event.pointerId);
277
+ this.state = State.UNDETERMINED;
278
+ }
279
+ this.wheelDevice = WheelDevice.UNDETERMINED;
280
+ }, 30);
281
+ }
282
+ onWheel(event) {
283
+ if (this.wheelDevice === WheelDevice.MOUSE ||
284
+ !this.enableTrackpadTwoFingerGesture) {
285
+ return;
286
+ }
287
+ if (this.state === State.UNDETERMINED) {
288
+ this.wheelDevice =
289
+ event.wheelDeltaY % 120 !== 0
290
+ ? WheelDevice.TOUCHPAD
291
+ : WheelDevice.MOUSE;
292
+ if (this.wheelDevice === WheelDevice.MOUSE) {
293
+ this.scheduleWheelEnd(event);
294
+ return;
295
+ }
296
+ this.tracker.addToTracker(event);
297
+ this.updateLastCoords();
298
+ this.startX = this.lastX;
299
+ this.startY = this.lastY;
300
+ this.begin();
301
+ this.activate();
302
+ }
303
+ this.tracker.track(event);
304
+ this.updateLastCoords();
305
+ this.updateVelocity(event.pointerId);
306
+ this.tryToSendMoveEvent(false, event);
307
+ this.scheduleWheelEnd(event);
308
+ }
309
+ shouldActivate() {
310
+ const dx = this.getTranslationX();
311
+ if (this.activeOffsetXStart !== Number.MAX_SAFE_INTEGER &&
312
+ dx < this.activeOffsetXStart) {
313
+ return true;
314
+ }
315
+ if (this.activeOffsetXEnd !== Number.MIN_SAFE_INTEGER &&
316
+ dx > this.activeOffsetXEnd) {
317
+ return true;
318
+ }
319
+ const dy = this.getTranslationY();
320
+ if (this.activeOffsetYStart !== Number.MAX_SAFE_INTEGER &&
321
+ dy < this.activeOffsetYStart) {
322
+ return true;
323
+ }
324
+ if (this.activeOffsetYEnd !== Number.MIN_SAFE_INTEGER &&
325
+ dy > this.activeOffsetYEnd) {
326
+ return true;
327
+ }
328
+ const distanceSq = dx * dx + dy * dy;
329
+ if (this.minDistSq !== Number.MAX_SAFE_INTEGER &&
330
+ distanceSq >= this.minDistSq) {
331
+ return true;
332
+ }
333
+ const vx = this.velocityX;
334
+ if (this.minVelocityX !== Number.MAX_SAFE_INTEGER &&
335
+ ((this.minVelocityX < 0 && vx <= this.minVelocityX) ||
336
+ (this.minVelocityX >= 0 && this.minVelocityX <= vx))) {
337
+ return true;
338
+ }
339
+ const vy = this.velocityY;
340
+ if (this.minVelocityY !== Number.MAX_SAFE_INTEGER &&
341
+ ((this.minVelocityY < 0 && vy <= this.minVelocityY) ||
342
+ (this.minVelocityY >= 0 && this.minVelocityY <= vy))) {
343
+ return true;
344
+ }
345
+ const velocitySq = vx * vx + vy * vy;
346
+ return (this.minVelocitySq !== Number.MAX_SAFE_INTEGER &&
347
+ velocitySq >= this.minVelocitySq);
348
+ }
349
+ shouldFail() {
350
+ const dx = this.getTranslationX();
351
+ const dy = this.getTranslationY();
352
+ const distanceSq = dx * dx + dy * dy;
353
+ if (this.activateAfterLongPress > 0 && distanceSq > DEFAULT_MIN_DIST_SQ) {
354
+ this.clearActivationTimeout();
355
+ return true;
356
+ }
357
+ if (this.failOffsetXStart !== Number.MIN_SAFE_INTEGER &&
358
+ dx < this.failOffsetXStart) {
359
+ return true;
360
+ }
361
+ if (this.failOffsetXEnd !== Number.MAX_SAFE_INTEGER &&
362
+ dx > this.failOffsetXEnd) {
363
+ return true;
364
+ }
365
+ if (this.failOffsetYStart !== Number.MIN_SAFE_INTEGER &&
366
+ dy < this.failOffsetYStart) {
367
+ return true;
368
+ }
369
+ return (this.failOffsetYEnd !== Number.MAX_SAFE_INTEGER &&
370
+ dy > this.failOffsetYEnd);
371
+ }
372
+ tryBegin(event) {
373
+ if (this.state === State.UNDETERMINED &&
374
+ this.tracker.trackedPointersCount >= this.minPointers) {
375
+ this.resetProgress();
376
+ this.offsetX = 0;
377
+ this.offsetY = 0;
378
+ this.velocityX = 0;
379
+ this.velocityY = 0;
380
+ this.begin();
381
+ if (this.activateAfterLongPress > 0) {
382
+ this.activationTimeout = setTimeout(() => {
383
+ this.activate();
384
+ }, this.activateAfterLongPress);
385
+ }
386
+ }
387
+ else {
388
+ this.updateVelocity(event.pointerId);
389
+ }
390
+ }
391
+ checkBegan() {
392
+ if (this.state === State.BEGAN) {
393
+ if (this.shouldFail()) {
394
+ this.fail();
395
+ }
396
+ else if (this.shouldActivate()) {
397
+ this.activate();
398
+ }
399
+ }
400
+ }
401
+ activate(force = false) {
402
+ if (this.state !== State.ACTIVE) {
403
+ this.resetProgress();
404
+ }
405
+ super.activate(force);
406
+ }
407
+ onCancel() {
408
+ this.clearActivationTimeout();
409
+ }
410
+ onReset() {
411
+ this.clearActivationTimeout();
412
+ }
413
+ resetProgress() {
414
+ if (this.state === State.ACTIVE) {
415
+ return;
416
+ }
417
+ this.startX = this.lastX;
418
+ this.startY = this.lastY;
419
+ }
420
+ }
@@ -25,4 +25,3 @@ export default class PinchGestureHandler extends GestureHandler {
25
25
  protected onReset(): void;
26
26
  protected resetProgress(): void;
27
27
  }
28
- //# sourceMappingURL=PinchGestureHandler.d.ts.map
@@ -0,0 +1,117 @@
1
+ import { State } from '../../State';
2
+ import { DEFAULT_TOUCH_SLOP } from '../constants';
3
+ import GestureHandler from './GestureHandler';
4
+ import ScaleGestureDetector from '../detectors/ScaleGestureDetector';
5
+ export default class PinchGestureHandler extends GestureHandler {
6
+ scale = 1;
7
+ velocity = 0;
8
+ startingSpan = 0;
9
+ spanSlop = DEFAULT_TOUCH_SLOP;
10
+ scaleDetectorListener = {
11
+ onScaleBegin: (detector) => {
12
+ this.startingSpan = detector.currentSpan;
13
+ return true;
14
+ },
15
+ onScale: (detector) => {
16
+ const prevScaleFactor = this.scale;
17
+ this.scale *= detector.calculateScaleFactor(this.tracker.trackedPointersCount);
18
+ const delta = detector.timeDelta;
19
+ if (delta > 0) {
20
+ this.velocity = (this.scale - prevScaleFactor) / delta;
21
+ }
22
+ if (Math.abs(this.startingSpan - detector.currentSpan) >= this.spanSlop &&
23
+ this.state === State.BEGAN) {
24
+ this.activate();
25
+ }
26
+ return true;
27
+ },
28
+ onScaleEnd: (_detector
29
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
30
+ ) => { },
31
+ };
32
+ scaleGestureDetector = new ScaleGestureDetector(this.scaleDetectorListener);
33
+ init(ref, propsRef) {
34
+ super.init(ref, propsRef);
35
+ this.shouldCancelWhenOutside = false;
36
+ }
37
+ transformNativeEvent() {
38
+ return {
39
+ focalX: this.scaleGestureDetector.focusX,
40
+ focalY: this.scaleGestureDetector.focusY,
41
+ velocity: this.velocity,
42
+ scale: this.scale,
43
+ };
44
+ }
45
+ onPointerDown(event) {
46
+ this.tracker.addToTracker(event);
47
+ super.onPointerDown(event);
48
+ this.tryToSendTouchEvent(event);
49
+ }
50
+ onPointerAdd(event) {
51
+ this.tracker.addToTracker(event);
52
+ super.onPointerAdd(event);
53
+ this.tryBegin();
54
+ this.scaleGestureDetector.onTouchEvent(event, this.tracker);
55
+ }
56
+ onPointerUp(event) {
57
+ super.onPointerUp(event);
58
+ this.tracker.removeFromTracker(event.pointerId);
59
+ if (this.state !== State.ACTIVE) {
60
+ return;
61
+ }
62
+ this.scaleGestureDetector.onTouchEvent(event, this.tracker);
63
+ if (this.state === State.ACTIVE) {
64
+ this.end();
65
+ }
66
+ else {
67
+ this.fail();
68
+ }
69
+ }
70
+ onPointerRemove(event) {
71
+ super.onPointerRemove(event);
72
+ this.scaleGestureDetector.onTouchEvent(event, this.tracker);
73
+ this.tracker.removeFromTracker(event.pointerId);
74
+ if (this.state === State.ACTIVE && this.tracker.trackedPointersCount < 2) {
75
+ this.end();
76
+ }
77
+ }
78
+ onPointerMove(event) {
79
+ if (this.tracker.trackedPointersCount < 2) {
80
+ return;
81
+ }
82
+ this.tracker.track(event);
83
+ this.scaleGestureDetector.onTouchEvent(event, this.tracker);
84
+ super.onPointerMove(event);
85
+ }
86
+ onPointerOutOfBounds(event) {
87
+ if (this.tracker.trackedPointersCount < 2) {
88
+ return;
89
+ }
90
+ this.tracker.track(event);
91
+ this.scaleGestureDetector.onTouchEvent(event, this.tracker);
92
+ super.onPointerOutOfBounds(event);
93
+ }
94
+ tryBegin() {
95
+ if (this.state !== State.UNDETERMINED) {
96
+ return;
97
+ }
98
+ this.resetProgress();
99
+ this.begin();
100
+ }
101
+ activate(force) {
102
+ if (this.state !== State.ACTIVE) {
103
+ this.resetProgress();
104
+ }
105
+ super.activate(force);
106
+ }
107
+ onReset() {
108
+ this.resetProgress();
109
+ }
110
+ resetProgress() {
111
+ if (this.state === State.ACTIVE) {
112
+ return;
113
+ }
114
+ this.velocity = 0;
115
+ this.scale = 1;
116
+ }
117
+ }
@@ -25,4 +25,3 @@ export default class RotationGestureHandler extends GestureHandler {
25
25
  protected tryBegin(): void;
26
26
  protected onReset(): void;
27
27
  }
28
- //# sourceMappingURL=RotationGestureHandler.d.ts.map
@@ -0,0 +1,122 @@
1
+ import { State } from '../../State';
2
+ import GestureHandler from './GestureHandler';
3
+ import RotationGestureDetector from '../detectors/RotationGestureDetector';
4
+ const ROTATION_RECOGNITION_THRESHOLD = Math.PI / 36;
5
+ export default class RotationGestureHandler extends GestureHandler {
6
+ rotation = 0;
7
+ velocity = 0;
8
+ cachedAnchorX = 0;
9
+ cachedAnchorY = 0;
10
+ rotationGestureListener = {
11
+ onRotationBegin: (_detector) => true,
12
+ onRotation: (detector) => {
13
+ const previousRotation = this.rotation;
14
+ this.rotation += detector.rotation;
15
+ const delta = detector.timeDelta;
16
+ if (delta > 0) {
17
+ this.velocity = (this.rotation - previousRotation) / delta;
18
+ }
19
+ if (Math.abs(this.rotation) >= ROTATION_RECOGNITION_THRESHOLD &&
20
+ this.state === State.BEGAN) {
21
+ this.activate();
22
+ }
23
+ return true;
24
+ },
25
+ onRotationEnd: (_detector) => {
26
+ this.end();
27
+ },
28
+ };
29
+ rotationGestureDetector = new RotationGestureDetector(this.rotationGestureListener);
30
+ init(ref, propsRef) {
31
+ super.init(ref, propsRef);
32
+ this.shouldCancelWhenOutside = false;
33
+ }
34
+ transformNativeEvent() {
35
+ return {
36
+ rotation: this.rotation ? this.rotation : 0,
37
+ anchorX: this.getAnchorX(),
38
+ anchorY: this.getAnchorY(),
39
+ velocity: this.velocity ? this.velocity : 0,
40
+ };
41
+ }
42
+ getAnchorX() {
43
+ const anchorX = this.rotationGestureDetector.anchorX;
44
+ return anchorX ? anchorX : this.cachedAnchorX;
45
+ }
46
+ getAnchorY() {
47
+ const anchorY = this.rotationGestureDetector.anchorY;
48
+ return anchorY ? anchorY : this.cachedAnchorY;
49
+ }
50
+ onPointerDown(event) {
51
+ this.tracker.addToTracker(event);
52
+ super.onPointerDown(event);
53
+ this.tryToSendTouchEvent(event);
54
+ }
55
+ onPointerAdd(event) {
56
+ this.tracker.addToTracker(event);
57
+ super.onPointerAdd(event);
58
+ this.tryBegin();
59
+ this.rotationGestureDetector.onTouchEvent(event, this.tracker);
60
+ }
61
+ onPointerMove(event) {
62
+ if (this.tracker.trackedPointersCount < 2) {
63
+ return;
64
+ }
65
+ if (this.getAnchorX()) {
66
+ this.cachedAnchorX = this.getAnchorX();
67
+ }
68
+ if (this.getAnchorY()) {
69
+ this.cachedAnchorY = this.getAnchorY();
70
+ }
71
+ this.tracker.track(event);
72
+ this.rotationGestureDetector.onTouchEvent(event, this.tracker);
73
+ super.onPointerMove(event);
74
+ }
75
+ onPointerOutOfBounds(event) {
76
+ if (this.tracker.trackedPointersCount < 2) {
77
+ return;
78
+ }
79
+ if (this.getAnchorX()) {
80
+ this.cachedAnchorX = this.getAnchorX();
81
+ }
82
+ if (this.getAnchorY()) {
83
+ this.cachedAnchorY = this.getAnchorY();
84
+ }
85
+ this.tracker.track(event);
86
+ this.rotationGestureDetector.onTouchEvent(event, this.tracker);
87
+ super.onPointerOutOfBounds(event);
88
+ }
89
+ onPointerUp(event) {
90
+ super.onPointerUp(event);
91
+ this.tracker.removeFromTracker(event.pointerId);
92
+ this.rotationGestureDetector.onTouchEvent(event, this.tracker);
93
+ if (this.state !== State.ACTIVE) {
94
+ return;
95
+ }
96
+ if (this.state === State.ACTIVE) {
97
+ this.end();
98
+ }
99
+ else {
100
+ this.fail();
101
+ }
102
+ }
103
+ onPointerRemove(event) {
104
+ super.onPointerRemove(event);
105
+ this.rotationGestureDetector.onTouchEvent(event, this.tracker);
106
+ this.tracker.removeFromTracker(event.pointerId);
107
+ }
108
+ tryBegin() {
109
+ if (this.state !== State.UNDETERMINED) {
110
+ return;
111
+ }
112
+ this.begin();
113
+ }
114
+ onReset() {
115
+ if (this.state === State.ACTIVE) {
116
+ return;
117
+ }
118
+ this.rotation = 0;
119
+ this.velocity = 0;
120
+ this.rotationGestureDetector.reset();
121
+ }
122
+ }
@@ -23,6 +23,7 @@ export default class TapGestureHandler extends GestureHandler {
23
23
  private clearTimeouts;
24
24
  private startTap;
25
25
  private endTap;
26
+ private updateLastCoords;
26
27
  protected onPointerDown(event: AdaptedEvent): void;
27
28
  protected onPointerAdd(event: AdaptedEvent): void;
28
29
  protected onPointerUp(event: AdaptedEvent): void;
@@ -36,4 +37,3 @@ export default class TapGestureHandler extends GestureHandler {
36
37
  protected onCancel(): void;
37
38
  protected resetProgress(): void;
38
39
  }
39
- //# sourceMappingURL=TapGestureHandler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TapGestureHandler.d.ts","sourceRoot":"","sources":["../../../../src/web/handlers/TapGestureHandler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAc,MAAM,eAAe,CAAC;AAEjE,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAO9C,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,cAAc;IAC3D,OAAO,CAAC,SAAS,CAA2B;IAC5C,OAAO,CAAC,SAAS,CAA2B;IAC5C,OAAO,CAAC,SAAS,CAA2B;IAC5C,OAAO,CAAC,aAAa,CAA2B;IAChD,OAAO,CAAC,UAAU,CAAwB;IAE1C,OAAO,CAAC,YAAY,CAA0B;IAC9C,OAAO,CAAC,mBAAmB,CAAkC;IAC7D,OAAO,CAAC,0BAA0B,CAAK;IAEvC,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,KAAK,CAAK;IAElB,OAAO,CAAC,WAAW,CAAqB;IACxC,OAAO,CAAC,YAAY,CAAqB;IAEzC,OAAO,CAAC,SAAS,CAAK;IAEf,mBAAmB,CAAC,EAAE,OAAc,EAAE,GAAG,KAAK,EAAE,EAAE,MAAM,GAAG,IAAI;IAgCtE,SAAS,CAAC,WAAW,IAAI,IAAI;IAY7B,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,MAAM;IAcd,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAqBlD,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAkBjD,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAYhD,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAiBpD,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAalD,SAAS,CAAC,oBAAoB,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAazD,OAAO,CAAC,WAAW;IA8BnB,OAAO,CAAC,kBAAkB;IAW1B,OAAO,CAAC,UAAU;IAyBX,QAAQ,IAAI,IAAI;IAMvB,SAAS,CAAC,QAAQ,IAAI,IAAI;IAK1B,SAAS,CAAC,aAAa,IAAI,IAAI;CAKhC"}
1
+ {"version":3,"file":"TapGestureHandler.d.ts","sourceRoot":"","sources":["../../../../src/web/handlers/TapGestureHandler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAc,MAAM,eAAe,CAAC;AAEjE,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAO9C,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,cAAc;IAC3D,OAAO,CAAC,SAAS,CAA2B;IAC5C,OAAO,CAAC,SAAS,CAA2B;IAC5C,OAAO,CAAC,SAAS,CAA2B;IAC5C,OAAO,CAAC,aAAa,CAA2B;IAChD,OAAO,CAAC,UAAU,CAAwB;IAE1C,OAAO,CAAC,YAAY,CAA0B;IAC9C,OAAO,CAAC,mBAAmB,CAAkC;IAC7D,OAAO,CAAC,0BAA0B,CAAK;IAEvC,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,KAAK,CAAK;IAElB,OAAO,CAAC,WAAW,CAAqB;IACxC,OAAO,CAAC,YAAY,CAAqB;IAEzC,OAAO,CAAC,SAAS,CAAK;IAEf,mBAAmB,CAAC,EAAE,OAAc,EAAE,GAAG,KAAK,EAAE,EAAE,MAAM,GAAG,IAAI;IAgCtE,SAAS,CAAC,WAAW,IAAI,IAAI;IAY7B,OAAO,CAAC,aAAa;IAKrB,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,MAAM;IAad,OAAO,CAAC,gBAAgB;IAQxB,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAqBlD,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAgBjD,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAUhD,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAepD,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAUlD,SAAS,CAAC,oBAAoB,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAUzD,OAAO,CAAC,WAAW;IA8BnB,OAAO,CAAC,kBAAkB;IAW1B,OAAO,CAAC,UAAU;IAyBX,QAAQ,IAAI,IAAI;IAMvB,SAAS,CAAC,QAAQ,IAAI,IAAI;IAK1B,SAAS,CAAC,aAAa,IAAI,IAAI;CAKhC"}