react-native-gesture-handler 1.10.3 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (384) hide show
  1. package/README.md +10 -8
  2. package/android/build.gradle +49 -1
  3. package/android/common/src/main/java/com/swmansion/common/GestureHandlerStateManager.kt +5 -0
  4. package/android/gradle.properties +19 -0
  5. package/android/lib/src/main/java/com/swmansion/gesturehandler/BaseGestureHandlerInteractionController.kt +18 -0
  6. package/android/lib/src/main/java/com/swmansion/gesturehandler/Extensions.kt +11 -0
  7. package/android/lib/src/main/java/com/swmansion/gesturehandler/FlingGestureHandler.kt +96 -0
  8. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.kt +744 -0
  9. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerInteractionController.kt +8 -0
  10. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerOrchestrator.kt +596 -0
  11. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistry.kt +8 -0
  12. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistryImpl.kt +21 -0
  13. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureUtils.kt +49 -0
  14. package/android/lib/src/main/java/com/swmansion/gesturehandler/LongPressGestureHandler.kt +97 -0
  15. package/android/lib/src/main/java/com/swmansion/gesturehandler/ManualGestureHandler.kt +11 -0
  16. package/android/lib/src/main/java/com/swmansion/gesturehandler/NativeViewGestureHandler.kt +129 -0
  17. package/android/lib/src/main/java/com/swmansion/gesturehandler/OnTouchEventListener.kt +9 -0
  18. package/android/lib/src/main/java/com/swmansion/gesturehandler/PanGestureHandler.kt +292 -0
  19. package/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.kt +90 -0
  20. package/android/lib/src/main/java/com/swmansion/gesturehandler/{PointerEventsConfig.java → PointerEventsConfig.kt} +3 -5
  21. package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureDetector.kt +125 -0
  22. package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureHandler.kt +81 -0
  23. package/android/lib/src/main/java/com/swmansion/gesturehandler/TapGestureHandler.kt +167 -0
  24. package/android/lib/src/main/java/com/swmansion/gesturehandler/ViewConfigurationHelper.kt +10 -0
  25. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +348 -0
  26. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.kt +57 -0
  27. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.kt +59 -0
  28. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEventDataExtractor.kt +8 -0
  29. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.kt +61 -0
  30. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +686 -0
  31. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerPackage.kt +17 -0
  32. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRegistry.kt +95 -0
  33. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +132 -0
  34. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootInterface.kt +5 -0
  35. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt +68 -0
  36. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootViewManager.kt +34 -0
  37. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.kt +66 -0
  38. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerTouchEvent.kt +69 -0
  39. package/android/src/main/java/com/swmansion/gesturehandler/react/RNViewConfigurationHelper.kt +51 -0
  40. package/ios/Handlers/RNFlingHandler.m +78 -5
  41. package/ios/Handlers/RNForceTouchHandler.m +29 -4
  42. package/ios/Handlers/RNLongPressHandler.m +105 -3
  43. package/ios/Handlers/RNManualHandler.h +4 -0
  44. package/ios/Handlers/RNManualHandler.m +73 -0
  45. package/ios/Handlers/RNNativeViewHandler.m +30 -2
  46. package/ios/Handlers/RNPanHandler.m +64 -4
  47. package/ios/Handlers/RNPinchHandler.m +61 -2
  48. package/ios/Handlers/RNRotationHandler.m +60 -1
  49. package/ios/Handlers/RNTapHandler.m +55 -8
  50. package/ios/RNGestureHandler.h +18 -4
  51. package/ios/RNGestureHandler.m +123 -13
  52. package/ios/RNGestureHandler.xcodeproj/project.xcworkspace/xcuserdata/jakubpiasecki.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  53. package/ios/RNGestureHandler.xcodeproj/xcuserdata/jakubpiasecki.xcuserdatad/xcschemes/xcschememanagement.plist +19 -0
  54. package/ios/RNGestureHandlerEvents.h +9 -0
  55. package/ios/RNGestureHandlerEvents.m +34 -0
  56. package/ios/RNGestureHandlerManager.h +7 -0
  57. package/ios/RNGestureHandlerManager.m +62 -34
  58. package/ios/RNGestureHandlerModule.m +39 -3
  59. package/ios/RNGestureHandlerPointerTracker.h +25 -0
  60. package/ios/RNGestureHandlerPointerTracker.m +237 -0
  61. package/ios/RNGestureHandlerRegistry.h +1 -0
  62. package/ios/RNGestureHandlerRegistry.m +10 -0
  63. package/ios/RNGestureHandlerStateManager.h +5 -0
  64. package/ios/RNManualActivationRecognizer.h +10 -0
  65. package/ios/RNManualActivationRecognizer.m +80 -0
  66. package/ios/RNRootViewGestureRecognizer.m +1 -1
  67. package/ios/RNTouchEventType.h +9 -0
  68. package/lib/commonjs/EventType.js +16 -0
  69. package/lib/commonjs/EventType.js.map +1 -0
  70. package/lib/commonjs/GestureHandlerRootView.android.js +1 -13
  71. package/lib/commonjs/GestureHandlerRootView.android.js.map +1 -1
  72. package/lib/commonjs/GestureHandlerRootView.js +11 -3
  73. package/lib/commonjs/GestureHandlerRootView.js.map +1 -1
  74. package/lib/commonjs/RNGestureHandlerModule.js +3 -1
  75. package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
  76. package/lib/commonjs/RNGestureHandlerModule.web.js +2 -2
  77. package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
  78. package/lib/commonjs/components/DrawerLayout.js +41 -37
  79. package/lib/commonjs/components/DrawerLayout.js.map +1 -1
  80. package/lib/commonjs/components/GestureButtons.js.map +1 -1
  81. package/lib/commonjs/components/GestureComponents.js +31 -12
  82. package/lib/commonjs/components/GestureComponents.js.map +1 -1
  83. package/lib/commonjs/components/Swipeable.js +10 -6
  84. package/lib/commonjs/components/Swipeable.js.map +1 -1
  85. package/lib/commonjs/components/touchables/GenericTouchable.js +2 -1
  86. package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -1
  87. package/lib/commonjs/components/touchables/TouchableOpacity.js +1 -1
  88. package/lib/commonjs/components/touchables/TouchableOpacity.js.map +1 -1
  89. package/lib/commonjs/gestureHandlerRootHOC.js +1 -1
  90. package/lib/commonjs/gestureHandlerRootHOC.js.map +1 -1
  91. package/lib/commonjs/handlers/FlingGestureHandler.js +23 -0
  92. package/lib/commonjs/handlers/FlingGestureHandler.js.map +1 -0
  93. package/lib/commonjs/handlers/ForceTouchGestureHandler.js +44 -0
  94. package/lib/commonjs/handlers/ForceTouchGestureHandler.js.map +1 -0
  95. package/lib/commonjs/handlers/LongPressGestureHandler.js +23 -0
  96. package/lib/commonjs/handlers/LongPressGestureHandler.js.map +1 -0
  97. package/lib/commonjs/handlers/NativeViewGestureHandler.js +6 -4
  98. package/lib/commonjs/handlers/NativeViewGestureHandler.js.map +1 -1
  99. package/lib/commonjs/handlers/PanGestureHandler.js +121 -0
  100. package/lib/commonjs/handlers/PanGestureHandler.js.map +1 -0
  101. package/lib/commonjs/handlers/PinchGestureHandler.js +21 -0
  102. package/lib/commonjs/handlers/PinchGestureHandler.js.map +1 -0
  103. package/lib/commonjs/handlers/RotationGestureHandler.js +21 -0
  104. package/lib/commonjs/handlers/RotationGestureHandler.js.map +1 -0
  105. package/lib/commonjs/handlers/TapGestureHandler.js +23 -0
  106. package/lib/commonjs/handlers/TapGestureHandler.js.map +1 -0
  107. package/lib/commonjs/handlers/createHandler.js +65 -84
  108. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  109. package/lib/commonjs/handlers/gestureHandlerCommon.js +80 -0
  110. package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -0
  111. package/lib/commonjs/handlers/gestures/GestureDetector.js +440 -0
  112. package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -0
  113. package/lib/commonjs/handlers/gestures/eventReceiver.js +135 -0
  114. package/lib/commonjs/handlers/gestures/eventReceiver.js.map +1 -0
  115. package/lib/commonjs/handlers/gestures/flingGesture.js +34 -0
  116. package/lib/commonjs/handlers/gestures/flingGesture.js.map +1 -0
  117. package/lib/commonjs/handlers/gestures/forceTouchGesture.js +65 -0
  118. package/lib/commonjs/handlers/gestures/forceTouchGesture.js.map +1 -0
  119. package/lib/commonjs/handlers/gestures/gesture.js +193 -0
  120. package/lib/commonjs/handlers/gestures/gesture.js.map +1 -0
  121. package/lib/commonjs/handlers/gestures/gestureComposition.js +94 -0
  122. package/lib/commonjs/handlers/gestures/gestureComposition.js.map +1 -0
  123. package/lib/commonjs/handlers/gestures/gestureObjects.js +85 -0
  124. package/lib/commonjs/handlers/gestures/gestureObjects.js.map +1 -0
  125. package/lib/commonjs/handlers/gestures/gestureStateManager.js +58 -0
  126. package/lib/commonjs/handlers/gestures/gestureStateManager.js.map +1 -0
  127. package/lib/commonjs/handlers/gestures/longPressGesture.js +34 -0
  128. package/lib/commonjs/handlers/gestures/longPressGesture.js.map +1 -0
  129. package/lib/commonjs/handlers/gestures/manualGesture.js +31 -0
  130. package/lib/commonjs/handlers/gestures/manualGesture.js.map +1 -0
  131. package/lib/commonjs/handlers/gestures/nativeGesture.js +34 -0
  132. package/lib/commonjs/handlers/gestures/nativeGesture.js.map +1 -0
  133. package/lib/commonjs/handlers/gestures/panGesture.js +144 -0
  134. package/lib/commonjs/handlers/gestures/panGesture.js.map +1 -0
  135. package/lib/commonjs/handlers/gestures/pinchGesture.js +45 -0
  136. package/lib/commonjs/handlers/gestures/pinchGesture.js.map +1 -0
  137. package/lib/commonjs/handlers/gestures/reanimatedWrapper.js +24 -0
  138. package/lib/commonjs/handlers/gestures/reanimatedWrapper.js.map +1 -0
  139. package/lib/commonjs/handlers/gestures/rotationGesture.js +45 -0
  140. package/lib/commonjs/handlers/gestures/rotationGesture.js.map +1 -0
  141. package/lib/commonjs/handlers/gestures/tapGesture.js +59 -0
  142. package/lib/commonjs/handlers/gestures/tapGesture.js.map +1 -0
  143. package/lib/commonjs/handlers/handlersRegistry.js +31 -0
  144. package/lib/commonjs/handlers/handlersRegistry.js.map +1 -0
  145. package/lib/commonjs/index.js +40 -8
  146. package/lib/commonjs/index.js.map +1 -1
  147. package/lib/commonjs/init.js +13 -0
  148. package/lib/commonjs/init.js.map +1 -0
  149. package/lib/commonjs/mocks.js +31 -2
  150. package/lib/commonjs/mocks.js.map +1 -1
  151. package/lib/commonjs/utils.js +15 -0
  152. package/lib/commonjs/utils.js.map +1 -0
  153. package/lib/commonjs/web/Errors.js +1 -1
  154. package/lib/commonjs/web/Errors.js.map +1 -1
  155. package/lib/commonjs/web/GestureHandler.js +4 -6
  156. package/lib/commonjs/web/GestureHandler.js.map +1 -1
  157. package/lib/commonjs/web/NodeManager.js +8 -2
  158. package/lib/commonjs/web/NodeManager.js.map +1 -1
  159. package/lib/module/EventType.js +8 -0
  160. package/lib/module/EventType.js.map +1 -0
  161. package/lib/module/GestureHandlerRootView.android.js +2 -14
  162. package/lib/module/GestureHandlerRootView.android.js.map +1 -1
  163. package/lib/module/GestureHandlerRootView.js +5 -1
  164. package/lib/module/GestureHandlerRootView.js.map +1 -1
  165. package/lib/module/RNGestureHandlerModule.js +3 -1
  166. package/lib/module/RNGestureHandlerModule.js.map +1 -1
  167. package/lib/module/RNGestureHandlerModule.web.js +2 -2
  168. package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
  169. package/lib/module/components/DrawerLayout.js +43 -40
  170. package/lib/module/components/DrawerLayout.js.map +1 -1
  171. package/lib/module/components/GestureButtons.js.map +1 -1
  172. package/lib/module/components/GestureComponents.js +29 -11
  173. package/lib/module/components/GestureComponents.js.map +1 -1
  174. package/lib/module/components/Swipeable.js +9 -6
  175. package/lib/module/components/Swipeable.js.map +1 -1
  176. package/lib/module/components/touchables/GenericTouchable.js +2 -1
  177. package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
  178. package/lib/module/components/touchables/TouchableOpacity.js +1 -1
  179. package/lib/module/components/touchables/TouchableOpacity.js.map +1 -1
  180. package/lib/module/gestureHandlerRootHOC.js +1 -1
  181. package/lib/module/gestureHandlerRootHOC.js.map +1 -1
  182. package/lib/module/handlers/FlingGestureHandler.js +10 -0
  183. package/lib/module/handlers/FlingGestureHandler.js.map +1 -0
  184. package/lib/module/handlers/ForceTouchGestureHandler.js +29 -0
  185. package/lib/module/handlers/ForceTouchGestureHandler.js.map +1 -0
  186. package/lib/module/handlers/LongPressGestureHandler.js +10 -0
  187. package/lib/module/handlers/LongPressGestureHandler.js.map +1 -0
  188. package/lib/module/handlers/NativeViewGestureHandler.js +4 -3
  189. package/lib/module/handlers/NativeViewGestureHandler.js.map +1 -1
  190. package/lib/module/handlers/PanGestureHandler.js +106 -0
  191. package/lib/module/handlers/PanGestureHandler.js.map +1 -0
  192. package/lib/module/handlers/PinchGestureHandler.js +9 -0
  193. package/lib/module/handlers/PinchGestureHandler.js.map +1 -0
  194. package/lib/module/handlers/RotationGestureHandler.js +9 -0
  195. package/lib/module/handlers/RotationGestureHandler.js.map +1 -0
  196. package/lib/module/handlers/TapGestureHandler.js +10 -0
  197. package/lib/module/handlers/TapGestureHandler.js.map +1 -0
  198. package/lib/module/handlers/createHandler.js +55 -77
  199. package/lib/module/handlers/createHandler.js.map +1 -1
  200. package/lib/module/handlers/gestureHandlerCommon.js +66 -0
  201. package/lib/module/handlers/gestureHandlerCommon.js.map +1 -0
  202. package/lib/module/handlers/gestures/GestureDetector.js +402 -0
  203. package/lib/module/handlers/gestures/GestureDetector.js.map +1 -0
  204. package/lib/module/handlers/gestures/eventReceiver.js +120 -0
  205. package/lib/module/handlers/gestures/eventReceiver.js.map +1 -0
  206. package/lib/module/handlers/gestures/flingGesture.js +24 -0
  207. package/lib/module/handlers/gestures/flingGesture.js.map +1 -0
  208. package/lib/module/handlers/gestures/forceTouchGesture.js +56 -0
  209. package/lib/module/handlers/gestures/forceTouchGesture.js.map +1 -0
  210. package/lib/module/handlers/gestures/gesture.js +175 -0
  211. package/lib/module/handlers/gestures/gesture.js.map +1 -0
  212. package/lib/module/handlers/gestures/gestureComposition.js +79 -0
  213. package/lib/module/handlers/gestures/gestureComposition.js.map +1 -0
  214. package/lib/module/handlers/gestures/gestureObjects.js +67 -0
  215. package/lib/module/handlers/gestures/gestureObjects.js.map +1 -0
  216. package/lib/module/handlers/gestures/gestureStateManager.js +48 -0
  217. package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -0
  218. package/lib/module/handlers/gestures/longPressGesture.js +24 -0
  219. package/lib/module/handlers/gestures/longPressGesture.js.map +1 -0
  220. package/lib/module/handlers/gestures/manualGesture.js +22 -0
  221. package/lib/module/handlers/gestures/manualGesture.js.map +1 -0
  222. package/lib/module/handlers/gestures/nativeGesture.js +24 -0
  223. package/lib/module/handlers/gestures/nativeGesture.js.map +1 -0
  224. package/lib/module/handlers/gestures/panGesture.js +135 -0
  225. package/lib/module/handlers/gestures/panGesture.js.map +1 -0
  226. package/lib/module/handlers/gestures/pinchGesture.js +36 -0
  227. package/lib/module/handlers/gestures/pinchGesture.js.map +1 -0
  228. package/lib/module/handlers/gestures/reanimatedWrapper.js +19 -0
  229. package/lib/module/handlers/gestures/reanimatedWrapper.js.map +1 -0
  230. package/lib/module/handlers/gestures/rotationGesture.js +36 -0
  231. package/lib/module/handlers/gestures/rotationGesture.js.map +1 -0
  232. package/lib/module/handlers/gestures/tapGesture.js +49 -0
  233. package/lib/module/handlers/gestures/tapGesture.js.map +1 -0
  234. package/lib/module/handlers/handlersRegistry.js +16 -0
  235. package/lib/module/handlers/handlersRegistry.js.map +1 -0
  236. package/lib/module/index.js +11 -1
  237. package/lib/module/index.js.map +1 -1
  238. package/lib/module/init.js +5 -0
  239. package/lib/module/init.js.map +1 -0
  240. package/lib/module/mocks.js +31 -2
  241. package/lib/module/mocks.js.map +1 -1
  242. package/lib/module/utils.js +8 -0
  243. package/lib/module/utils.js.map +1 -0
  244. package/lib/module/web/Errors.js +1 -1
  245. package/lib/module/web/Errors.js.map +1 -1
  246. package/lib/module/web/GestureHandler.js +4 -6
  247. package/lib/module/web/GestureHandler.js.map +1 -1
  248. package/lib/module/web/NodeManager.js +8 -2
  249. package/lib/module/web/NodeManager.js.map +1 -1
  250. package/lib/typescript/EventType.d.ts +8 -0
  251. package/lib/typescript/GestureHandlerRootView.android.d.ts +2 -4
  252. package/lib/typescript/GestureHandlerRootView.d.ts +5 -2
  253. package/lib/typescript/RNGestureHandlerModule.d.ts +1 -1
  254. package/lib/typescript/RNGestureHandlerModule.web.d.ts +1 -1
  255. package/lib/typescript/components/DrawerLayout.d.ts +50 -1
  256. package/lib/typescript/components/GestureButtons.d.ts +36 -0
  257. package/lib/typescript/components/GestureComponents.d.ts +8 -35
  258. package/lib/typescript/components/Swipeable.d.ts +73 -6
  259. package/lib/typescript/components/touchables/GenericTouchable.d.ts +2 -2
  260. package/lib/typescript/components/touchables/TouchableHighlight.d.ts +1 -0
  261. package/lib/typescript/components/touchables/TouchableOpacity.d.ts +1 -0
  262. package/lib/typescript/handlers/FlingGestureHandler.d.ts +33 -0
  263. package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +43 -0
  264. package/lib/typescript/handlers/LongPressGestureHandler.d.ts +55 -0
  265. package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +19 -4
  266. package/lib/typescript/handlers/PanGestureHandler.d.ts +137 -0
  267. package/lib/typescript/handlers/PinchGestureHandler.d.ts +28 -0
  268. package/lib/typescript/handlers/RotationGestureHandler.d.ts +28 -0
  269. package/lib/typescript/handlers/TapGestureHandler.d.ts +56 -0
  270. package/lib/typescript/handlers/createHandler.d.ts +1 -1
  271. package/lib/typescript/handlers/gestureHandlerCommon.d.ts +62 -0
  272. package/lib/typescript/handlers/gestureHandlerTypesCompat.d.ts +8 -1
  273. package/lib/typescript/handlers/gestures/GestureDetector.d.ts +16 -0
  274. package/lib/typescript/handlers/gestures/eventReceiver.d.ts +2 -0
  275. package/lib/typescript/handlers/gestures/flingGesture.d.ts +9 -0
  276. package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +16 -0
  277. package/lib/typescript/handlers/gestures/gesture.d.ts +97 -0
  278. package/lib/typescript/handlers/gestures/gestureComposition.d.ts +21 -0
  279. package/lib/typescript/handlers/gestures/gestureObjects.d.ts +39 -0
  280. package/lib/typescript/handlers/gestures/gestureStateManager.d.ts +9 -0
  281. package/lib/typescript/handlers/gestures/longPressGesture.d.ts +9 -0
  282. package/lib/typescript/handlers/gestures/manualGesture.d.ts +7 -0
  283. package/lib/typescript/handlers/gestures/nativeGesture.d.ts +9 -0
  284. package/lib/typescript/handlers/gestures/panGesture.d.ts +26 -0
  285. package/lib/typescript/handlers/gestures/pinchGesture.d.ts +12 -0
  286. package/lib/typescript/handlers/gestures/reanimatedWrapper.d.ts +14 -0
  287. package/lib/typescript/handlers/gestures/rotationGesture.d.ts +12 -0
  288. package/lib/typescript/handlers/gestures/tapGesture.d.ts +14 -0
  289. package/lib/typescript/handlers/handlersRegistry.d.ts +6 -0
  290. package/lib/typescript/index.d.ts +29 -2
  291. package/lib/typescript/init.d.ts +1 -0
  292. package/lib/typescript/mocks.d.ts +21 -2
  293. package/lib/typescript/utils.d.ts +1 -0
  294. package/lib/typescript/web/FlingGestureHandler.d.ts +0 -1
  295. package/lib/typescript/web/GestureHandler.d.ts +0 -1
  296. package/lib/typescript/web/PanGestureHandler.d.ts +0 -1
  297. package/lib/typescript/web/PinchGestureHandler.d.ts +0 -1
  298. package/lib/typescript/web/PressGestureHandler.d.ts +0 -1
  299. package/lib/typescript/web/RotationGestureHandler.d.ts +0 -1
  300. package/lib/typescript/web/TapGestureHandler.d.ts +0 -1
  301. package/package.json +8 -5
  302. package/src/EventType.ts +10 -0
  303. package/src/GestureHandlerRootView.android.tsx +9 -25
  304. package/src/GestureHandlerRootView.tsx +11 -2
  305. package/src/RNGestureHandlerModule.ts +5 -1
  306. package/src/RNGestureHandlerModule.web.ts +1 -0
  307. package/src/components/DrawerLayout.tsx +114 -41
  308. package/src/components/GestureButtons.tsx +45 -5
  309. package/src/components/GestureComponents.tsx +47 -41
  310. package/src/components/Swipeable.tsx +108 -21
  311. package/src/components/touchables/GenericTouchable.tsx +2 -1
  312. package/src/components/touchables/TouchableOpacity.tsx +1 -1
  313. package/src/handlers/FlingGestureHandler.ts +57 -0
  314. package/src/handlers/ForceTouchGestureHandler.ts +83 -0
  315. package/src/handlers/LongPressGestureHandler.ts +84 -0
  316. package/src/handlers/NativeViewGestureHandler.ts +31 -7
  317. package/src/handlers/PanGestureHandler.ts +321 -0
  318. package/src/handlers/PinchGestureHandler.ts +46 -0
  319. package/src/handlers/RotationGestureHandler.ts +46 -0
  320. package/src/handlers/TapGestureHandler.ts +90 -0
  321. package/src/handlers/createHandler.ts +67 -79
  322. package/src/handlers/gestureHandlerCommon.ts +185 -0
  323. package/src/handlers/gestureHandlerTypesCompat.ts +19 -5
  324. package/src/handlers/gestures/GestureDetector.tsx +519 -0
  325. package/src/handlers/gestures/eventReceiver.ts +151 -0
  326. package/src/handlers/gestures/flingGesture.ts +27 -0
  327. package/src/handlers/gestures/forceTouchGesture.ts +74 -0
  328. package/src/handlers/gestures/gesture.ts +292 -0
  329. package/src/handlers/gestures/gestureComposition.ts +109 -0
  330. package/src/handlers/gestures/gestureObjects.ts +79 -0
  331. package/src/handlers/gestures/gestureStateManager.ts +60 -0
  332. package/src/handlers/gestures/longPressGesture.ts +27 -0
  333. package/src/handlers/gestures/manualGesture.ts +31 -0
  334. package/src/handlers/gestures/nativeGesture.ts +27 -0
  335. package/src/handlers/gestures/panGesture.ts +147 -0
  336. package/src/handlers/gestures/pinchGesture.ts +51 -0
  337. package/src/handlers/gestures/reanimatedWrapper.ts +45 -0
  338. package/src/handlers/gestures/rotationGesture.ts +51 -0
  339. package/src/handlers/gestures/tapGesture.ts +52 -0
  340. package/src/handlers/handlersRegistry.ts +22 -0
  341. package/src/index.ts +57 -17
  342. package/src/init.ts +5 -0
  343. package/src/mocks.ts +42 -2
  344. package/src/utils.ts +7 -0
  345. package/src/web/GestureHandler.ts +1 -2
  346. package/src/web/NodeManager.ts +5 -0
  347. package/android/lib/src/main/java/com/swmansion/gesturehandler/BaseGestureHandlerInteractionController.java +0 -23
  348. package/android/lib/src/main/java/com/swmansion/gesturehandler/FlingGestureHandler.java +0 -110
  349. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.java +0 -531
  350. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerInteractionController.java +0 -8
  351. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerOrchestrator.java +0 -543
  352. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistry.java +0 -10
  353. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistryImpl.java +0 -29
  354. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureUtils.java +0 -53
  355. package/android/lib/src/main/java/com/swmansion/gesturehandler/LongPressGestureHandler.java +0 -81
  356. package/android/lib/src/main/java/com/swmansion/gesturehandler/NativeViewGestureHandler.java +0 -110
  357. package/android/lib/src/main/java/com/swmansion/gesturehandler/OnTouchEventListener.java +0 -8
  358. package/android/lib/src/main/java/com/swmansion/gesturehandler/PanGestureHandler.java +0 -312
  359. package/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.java +0 -109
  360. package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureDetector.java +0 -169
  361. package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureHandler.java +0 -96
  362. package/android/lib/src/main/java/com/swmansion/gesturehandler/TapGestureHandler.java +0 -172
  363. package/android/lib/src/main/java/com/swmansion/gesturehandler/ViewConfigurationHelper.java +0 -10
  364. package/android/src/main/java/com/facebook/react/views/modal/RNGHModalUtils.java +0 -21
  365. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.java +0 -296
  366. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.java +0 -72
  367. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.java +0 -77
  368. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEventDataExtractor.java +0 -8
  369. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.java +0 -86
  370. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.java +0 -731
  371. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerPackage.java +0 -31
  372. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRegistry.java +0 -101
  373. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.java +0 -151
  374. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootInterface.java +0 -7
  375. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.java +0 -76
  376. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootViewManager.java +0 -49
  377. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.java +0 -82
  378. package/android/src/main/java/com/swmansion/gesturehandler/react/RNViewConfigurationHelper.java +0 -61
  379. package/lib/commonjs/handlers/gestureHandlers.js +0 -236
  380. package/lib/commonjs/handlers/gestureHandlers.js.map +0 -1
  381. package/lib/module/handlers/gestureHandlers.js +0 -216
  382. package/lib/module/handlers/gestureHandlers.js.map +0 -1
  383. package/lib/typescript/handlers/gestureHandlers.d.ts +0 -158
  384. package/src/handlers/gestureHandlers.ts +0 -511
package/README.md CHANGED
@@ -1,7 +1,6 @@
1
- <p align="center">
2
- <h1 align="center">React Native Gesture Handler</h1>
3
- <h3 align="center">Declarative API exposing platform native touch and gesture system to React Native.</h3>
4
- </p>
1
+ <img src="https://user-images.githubusercontent.com/16062886/117444014-2d1ffd80-af39-11eb-9bbb-33c320599d93.png" width="100%" alt="React Native Gesture Handler by Software Mansion">
2
+
3
+ ### Declarative API exposing platform native touch and gesture system to React Native.
5
4
 
6
5
  React Native Gesture Handler provides native-driven gesture management APIs for building best possible touch-based experiences in React Native.
7
6
 
@@ -18,7 +17,7 @@ Check out our dedicated documentation page for info about this library, API refe
18
17
 
19
18
  ## Examples
20
19
 
21
- If you want to play with the API but don't feel like trying it on a real app, you can run the example project. Clone the repo, go to the `Example/` folder and run:
20
+ If you want to play with the API but don't feel like trying it on a real app, you can run the example project. Clone the repo, go to the `example` folder and run:
22
21
 
23
22
  ```bash
24
23
  yarn install
@@ -28,7 +27,7 @@ If you are running on ios, run `pod install` in the ios folder
28
27
 
29
28
  Run `yarn start` to start the metro bundler
30
29
 
31
- Run `react-native run-android` or `react-native run-ios` (depending on which platform you want to run the example app on).
30
+ Run `yarn android` or `yarn ios` (depending on which platform you want to run the example app on).
32
31
 
33
32
  You will need to have an Android or iOS device or emulator connected as well as `react-native-cli` package installed globally.
34
33
 
@@ -40,13 +39,16 @@ You will need to have an Android or iOS device or emulator connected as well as
40
39
  | 1.1.0+ | 0.57.2+ |
41
40
  | <1.1.0 | 0.50.0+ |
42
41
 
42
+ It may be possible to use newer versions of react-native-gesture-handler on React Native with version <= 0.59 by reverse Jetifying.
43
+ Read more on that here https://github.com/mikehardy/jetifier#to-reverse-jetify--convert-node_modules-dependencies-to-support-libraries
43
44
  ## License
44
45
 
45
46
  Gesture handler library is licensed under [The MIT License](LICENSE).
46
47
 
47
48
  ## Credits
48
49
 
49
- This project is supported by amazing people from [Expo.io](https://expo.io) and [Software Mansion](https://swmansion.com)
50
+ This project has been build and is maintained thanks to the support from [Shopify](https://shopify.com), [Expo.io](https://expo.io) and [Software Mansion](https://swmansion.com)
50
51
 
52
+ [![shopify](https://avatars1.githubusercontent.com/u/8085?v=3&s=100 'Shopify.com')](https://shopify.com)
51
53
  [![expo](https://avatars2.githubusercontent.com/u/12504344?v=3&s=100 'Expo.io')](https://expo.io)
52
- [![swm](https://logo.swmansion.com/logo?color=white&variant=desktop&width=150&tag=react-native-gesture-handler-github 'Software Mansion')](https://swmansion.com)
54
+ [![swm](https://logo.swmansion.com/logo?color=white&variant=desktop&width=150&tag=react-native-reanimated-github 'Software Mansion')](https://swmansion.com)
@@ -1,9 +1,42 @@
1
+ import groovy.json.JsonSlurper
2
+
3
+ buildscript {
4
+ def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['RNGH_kotlinVersion']
5
+
6
+ repositories {
7
+ mavenCentral()
8
+ }
9
+
10
+ dependencies {
11
+ classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
12
+ }
13
+ }
14
+
1
15
  apply plugin: 'com.android.library'
16
+ apply plugin: 'kotlin-android'
2
17
 
3
18
  def safeExtGet(prop, fallback) {
4
19
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
5
20
  }
6
21
 
22
+ // Check whether Reanimated 2.3 or higher is installed alongside Gesture Handler
23
+ def shouldUseCommonInterfaceFromReanimated() {
24
+ def reanimated = rootProject.subprojects.find { it.name == 'react-native-reanimated' };
25
+ if (reanimated != null) {
26
+ def inputFile = new File(reanimated.projectDir, '../package.json')
27
+ def json = new JsonSlurper().parseText(inputFile.text)
28
+ def reanimatedVersion = json.version as String
29
+ def (major, minor, patch) = reanimatedVersion.tokenize('.')
30
+ return Integer.parseInt(major) == 2 && Integer.parseInt(minor) >= 3
31
+ } else {
32
+ return false
33
+ }
34
+ }
35
+
36
+ repositories {
37
+ mavenCentral()
38
+ }
39
+
7
40
  android {
8
41
  compileSdkVersion safeExtGet("compileSdkVersion", 28)
9
42
 
@@ -14,15 +47,30 @@ android {
14
47
  versionName "1.0"
15
48
  }
16
49
 
17
- // Include "lib/" as sources, unfortunetely react-native link can't handle
50
+ // Include "lib/" as sources, unfortunately react-native link can't handle
18
51
  // setting up alternative gradle modules. We still have "lib" defined as a
19
52
  // standalone gradle module just to be used in AndroidNativeExample
20
53
  sourceSets {
21
54
  main.java.srcDirs += 'lib/src/main/java'
55
+
56
+ // Include "common/" only when it's not provided by Reanimated to mitigate
57
+ // multiple definitions of the same class preventing build
58
+ if (!shouldUseCommonInterfaceFromReanimated()) {
59
+ main.java.srcDirs += 'common/src/main/java'
60
+ }
22
61
  }
23
62
  }
24
63
 
64
+ def kotlin_version = safeExtGet('kotlinVersion', project.properties['RNGH_kotlinVersion'])
65
+
25
66
  dependencies {
26
67
  //noinspection GradleDynamicVersion
68
+ if (shouldUseCommonInterfaceFromReanimated()) {
69
+ // Include Reanimated as dependency to load the common interface
70
+ implementation project(':react-native-reanimated')
71
+ }
27
72
  implementation 'com.facebook.react:react-native:+'
73
+ implementation 'androidx.appcompat:appcompat:1.2.0'
74
+ implementation "androidx.core:core-ktx:1.6.0"
75
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
28
76
  }
@@ -0,0 +1,5 @@
1
+ package com.swmansion.common
2
+
3
+ interface GestureHandlerStateManager {
4
+ fun setGestureHandlerState(handlerTag: Int, newState: Int)
5
+ }
@@ -0,0 +1,19 @@
1
+ # Project-wide Gradle settings.
2
+
3
+ # IDE (e.g. Android Studio) users:
4
+ # Gradle settings configured through the IDE *will override*
5
+ # any settings specified in this file.
6
+
7
+ # For more details on how to configure your build environment visit
8
+ # http://www.gradle.org/docs/current/userguide/build_environment.html
9
+
10
+ # Specifies the JVM arguments used for the daemon process.
11
+ # The setting is particularly useful for tweaking memory settings.
12
+ # Default value: -Xmx10248m -XX:MaxPermSize=256m
13
+ org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14
+
15
+ # When configured, Gradle will run in incubating parallel mode.
16
+ # This option should only be used with decoupled projects. More details, visit
17
+ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18
+ # org.gradle.parallel=true
19
+ RNGH_kotlinVersion=1.5.20
@@ -0,0 +1,18 @@
1
+ package com.swmansion.gesturehandler
2
+
3
+ abstract class BaseGestureHandlerInteractionController : GestureHandlerInteractionController {
4
+ override fun shouldWaitForHandlerFailure(
5
+ handler: GestureHandler<*>,
6
+ otherHandler: GestureHandler<*>,
7
+ ) = false
8
+
9
+ override fun shouldRequireHandlerToWaitForFailure(
10
+ handler: GestureHandler<*>,
11
+ otherHandler: GestureHandler<*>,
12
+ ) = false
13
+
14
+ override fun shouldRecognizeSimultaneously(
15
+ handler: GestureHandler<*>,
16
+ otherHandler: GestureHandler<*>,
17
+ ) = false
18
+ }
@@ -0,0 +1,11 @@
1
+ package com.swmansion.gesturehandler
2
+
3
+ import com.facebook.react.bridge.ReactContext
4
+ import com.facebook.react.modules.core.DeviceEventManagerModule
5
+ import com.facebook.react.uimanager.UIManagerModule
6
+
7
+ val ReactContext.deviceEventEmitter: DeviceEventManagerModule.RCTDeviceEventEmitter
8
+ get() = this.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
9
+
10
+ val ReactContext.UIManager: UIManagerModule
11
+ get() = this.getNativeModule(UIManagerModule::class.java)!!
@@ -0,0 +1,96 @@
1
+ package com.swmansion.gesturehandler
2
+
3
+ import android.os.Handler
4
+ import android.view.MotionEvent
5
+
6
+ class FlingGestureHandler : GestureHandler<FlingGestureHandler>() {
7
+ var numberOfPointersRequired = DEFAULT_NUMBER_OF_TOUCHES_REQUIRED
8
+ var direction = DEFAULT_DIRECTION
9
+
10
+ private val maxDurationMs = DEFAULT_MAX_DURATION_MS
11
+ private val minAcceptableDelta = DEFAULT_MIN_ACCEPTABLE_DELTA
12
+ private var startX = 0f
13
+ private var startY = 0f
14
+ private var handler: Handler? = null
15
+ private var maxNumberOfPointersSimultaneously = 0
16
+ private val failDelayed = Runnable { fail() }
17
+
18
+ override fun resetConfig() {
19
+ super.resetConfig()
20
+ numberOfPointersRequired = DEFAULT_NUMBER_OF_TOUCHES_REQUIRED
21
+ direction = DEFAULT_DIRECTION
22
+ }
23
+
24
+ private fun startFling(event: MotionEvent) {
25
+ startX = event.rawX
26
+ startY = event.rawY
27
+ begin()
28
+ maxNumberOfPointersSimultaneously = 1
29
+ if (handler == null) {
30
+ handler = Handler() // lazy delegate?
31
+ } else {
32
+ handler!!.removeCallbacksAndMessages(null)
33
+ }
34
+ handler!!.postDelayed(failDelayed, maxDurationMs)
35
+ }
36
+
37
+ private fun tryEndFling(event: MotionEvent) = if (
38
+ maxNumberOfPointersSimultaneously == numberOfPointersRequired &&
39
+ (direction and DIRECTION_RIGHT != 0 &&
40
+ event.rawX - startX > minAcceptableDelta ||
41
+ direction and DIRECTION_LEFT != 0 &&
42
+ startX - event.rawX > minAcceptableDelta ||
43
+ direction and DIRECTION_UP != 0 &&
44
+ startY - event.rawY > minAcceptableDelta ||
45
+ direction and DIRECTION_DOWN != 0 &&
46
+ event.rawY - startY > minAcceptableDelta)) {
47
+ handler!!.removeCallbacksAndMessages(null)
48
+ activate()
49
+ true
50
+ } else {
51
+ false
52
+ }
53
+
54
+ override fun activate(force: Boolean) {
55
+ super.activate(force)
56
+ end()
57
+ }
58
+
59
+ private fun endFling(event: MotionEvent) {
60
+ if (!tryEndFling(event)) {
61
+ fail()
62
+ }
63
+ }
64
+
65
+ override fun onHandle(event: MotionEvent) {
66
+ val state = state
67
+ if (state == STATE_UNDETERMINED) {
68
+ startFling(event)
69
+ }
70
+ if (state == STATE_BEGAN) {
71
+ tryEndFling(event)
72
+ if (event.pointerCount > maxNumberOfPointersSimultaneously) {
73
+ maxNumberOfPointersSimultaneously = event.pointerCount
74
+ }
75
+ val action = event.actionMasked
76
+ if (action == MotionEvent.ACTION_UP) {
77
+ endFling(event)
78
+ }
79
+ }
80
+ }
81
+
82
+ override fun onCancel() {
83
+ handler?.removeCallbacksAndMessages(null)
84
+ }
85
+
86
+ override fun onReset() {
87
+ handler?.removeCallbacksAndMessages(null)
88
+ }
89
+
90
+ companion object {
91
+ private const val DEFAULT_MAX_DURATION_MS: Long = 800
92
+ private const val DEFAULT_MIN_ACCEPTABLE_DELTA: Long = 160
93
+ private const val DEFAULT_DIRECTION = DIRECTION_RIGHT
94
+ private const val DEFAULT_NUMBER_OF_TOUCHES_REQUIRED = 1
95
+ }
96
+ }