react-native-gesture-handler 2.2.0 → 2.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (260) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +5 -1
  3. package/RNGestureHandler.podspec +27 -3
  4. package/android/build.gradle +81 -8
  5. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.kt +5 -1
  6. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerOrchestrator.kt +14 -12
  7. package/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.kt +2 -4
  8. package/android/lib/src/main/java/com/swmansion/gesturehandler/ScaleGestureDetector.java +558 -0
  9. package/android/src/fabric/java/com/swmansion/gesturehandler/RNGestureHandlerComponentsRegistry.java +29 -0
  10. package/android/src/fabric/java/com/swmansion/gesturehandler/ReactContextExtensions.kt +12 -0
  11. package/android/src/main/AndroidManifest.xml +1 -1
  12. package/android/src/main/java/com/swmansion/gesturehandler/RNGestureHandlerPackage.kt +29 -0
  13. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +40 -13
  14. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +111 -47
  15. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRegistry.kt +9 -4
  16. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +1 -1
  17. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootViewManager.kt +17 -2
  18. package/android/src/main/jni/Android.mk +53 -0
  19. package/android/src/main/jni/OnLoad.cpp +9 -0
  20. package/android/src/main/jni/RNGestureHandlerComponentsRegistry.cpp +71 -0
  21. package/android/src/main/jni/RNGestureHandlerComponentsRegistry.h +34 -0
  22. package/android/src/main/jni/cpp-adapter.cpp +41 -0
  23. package/android/src/paper/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java +47 -0
  24. package/android/src/paper/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerInterface.java +22 -0
  25. package/android/src/paper/java/com/facebook/react/viewmanagers/RNGestureHandlerRootViewManagerDelegate.java +25 -0
  26. package/android/src/paper/java/com/facebook/react/viewmanagers/RNGestureHandlerRootViewManagerInterface.java +16 -0
  27. package/android/src/paper/java/com/swmansion/gesturehandler/ReactContextExtensions.kt +13 -0
  28. package/ios/Handlers/RNFlingHandler.m +2 -0
  29. package/ios/Handlers/RNPanHandler.m +2 -0
  30. package/ios/Handlers/RNPinchHandler.m +2 -0
  31. package/ios/Handlers/RNRotationHandler.m +2 -0
  32. package/ios/RNGestureHandler.h +3 -8
  33. package/ios/RNGestureHandler.m +2 -10
  34. package/ios/RNGestureHandler.xcodeproj/project.xcworkspace/xcuserdata/jakubpiasecki.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  35. package/ios/RNGestureHandlerActionType.h +8 -0
  36. package/ios/RNGestureHandlerButtonComponentView.h +17 -0
  37. package/ios/RNGestureHandlerButtonComponentView.mm +48 -0
  38. package/ios/RNGestureHandlerButtonManager.h +5 -0
  39. package/ios/RNGestureHandlerButtonManager.m +30 -0
  40. package/ios/RNGestureHandlerManager.h +2 -4
  41. package/ios/{RNGestureHandlerManager.m → RNGestureHandlerManager.mm} +92 -20
  42. package/ios/{RNGestureHandlerModule.m → RNGestureHandlerModule.mm} +91 -36
  43. package/ios/RNGestureHandlerRegistry.h +1 -2
  44. package/ios/RNGestureHandlerRegistry.m +2 -11
  45. package/ios/RNGestureHandlerRootViewComponentView.mm +21 -0
  46. package/jest-utils/package.json +6 -0
  47. package/lib/commonjs/ActionType.js +15 -0
  48. package/lib/commonjs/ActionType.js.map +1 -0
  49. package/lib/commonjs/GestureHandlerRootView.android.js +6 -6
  50. package/lib/commonjs/GestureHandlerRootView.android.js.map +1 -1
  51. package/lib/commonjs/GestureHandlerRootView.js +2 -3
  52. package/lib/commonjs/GestureHandlerRootView.js.map +1 -1
  53. package/lib/commonjs/RNGestureHandlerModule.js +4 -2
  54. package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
  55. package/lib/commonjs/RNGestureHandlerModule.web.js +1 -1
  56. package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
  57. package/lib/commonjs/components/DrawerLayout.js +2 -2
  58. package/lib/commonjs/components/DrawerLayout.js.map +1 -1
  59. package/lib/commonjs/components/GestureHandlerButton.js +5 -2
  60. package/lib/commonjs/components/GestureHandlerButton.js.map +1 -1
  61. package/lib/commonjs/components/Swipeable.js +22 -20
  62. package/lib/commonjs/components/Swipeable.js.map +1 -1
  63. package/lib/commonjs/components/touchables/TouchableOpacity.js +3 -1
  64. package/lib/commonjs/components/touchables/TouchableOpacity.js.map +1 -1
  65. package/lib/commonjs/fabric/RNGestureHandlerButtonNativeComponent.js +21 -0
  66. package/lib/commonjs/fabric/RNGestureHandlerButtonNativeComponent.js.map +1 -0
  67. package/lib/commonjs/fabric/RNGestureHandlerRootViewNativeComponent.js +21 -0
  68. package/lib/commonjs/fabric/RNGestureHandlerRootViewNativeComponent.js.map +1 -0
  69. package/lib/commonjs/getShadowNodeFromRef.js +24 -0
  70. package/lib/commonjs/getShadowNodeFromRef.js.map +1 -0
  71. package/lib/commonjs/getShadowNodeFromRef.web.js +15 -0
  72. package/lib/commonjs/getShadowNodeFromRef.web.js.map +1 -0
  73. package/lib/commonjs/handlers/FlingGestureHandler.js +4 -2
  74. package/lib/commonjs/handlers/FlingGestureHandler.js.map +1 -1
  75. package/lib/commonjs/handlers/ForceTouchGestureHandler.js +8 -4
  76. package/lib/commonjs/handlers/ForceTouchGestureHandler.js.map +1 -1
  77. package/lib/commonjs/handlers/LongPressGestureHandler.js +4 -2
  78. package/lib/commonjs/handlers/LongPressGestureHandler.js.map +1 -1
  79. package/lib/commonjs/handlers/NativeViewGestureHandler.js +4 -2
  80. package/lib/commonjs/handlers/NativeViewGestureHandler.js.map +1 -1
  81. package/lib/commonjs/handlers/PanGestureHandler.js +4 -2
  82. package/lib/commonjs/handlers/PanGestureHandler.js.map +1 -1
  83. package/lib/commonjs/handlers/PinchGestureHandler.js +4 -2
  84. package/lib/commonjs/handlers/PinchGestureHandler.js.map +1 -1
  85. package/lib/commonjs/handlers/RotationGestureHandler.js +4 -2
  86. package/lib/commonjs/handlers/RotationGestureHandler.js.map +1 -1
  87. package/lib/commonjs/handlers/TapGestureHandler.js +4 -2
  88. package/lib/commonjs/handlers/TapGestureHandler.js.map +1 -1
  89. package/lib/commonjs/handlers/createHandler.js +63 -9
  90. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  91. package/lib/commonjs/handlers/createNativeWrapper.js +6 -2
  92. package/lib/commonjs/handlers/createNativeWrapper.js.map +1 -1
  93. package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
  94. package/lib/commonjs/handlers/gestures/GestureDetector.js +84 -32
  95. package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
  96. package/lib/commonjs/handlers/gestures/eventReceiver.js +25 -8
  97. package/lib/commonjs/handlers/gestures/eventReceiver.js.map +1 -1
  98. package/lib/commonjs/handlers/gestures/forceTouchGesture.js.map +1 -1
  99. package/lib/commonjs/handlers/gestures/gesture.js +16 -1
  100. package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
  101. package/lib/commonjs/handlers/gestures/gestureStateManager.js +7 -4
  102. package/lib/commonjs/handlers/gestures/gestureStateManager.js.map +1 -1
  103. package/lib/commonjs/handlers/gestures/panGesture.js.map +1 -1
  104. package/lib/commonjs/handlers/gestures/pinchGesture.js.map +1 -1
  105. package/lib/commonjs/handlers/gestures/reanimatedWrapper.js +4 -1
  106. package/lib/commonjs/handlers/gestures/reanimatedWrapper.js.map +1 -1
  107. package/lib/commonjs/handlers/handlersRegistry.js +42 -6
  108. package/lib/commonjs/handlers/handlersRegistry.js.map +1 -1
  109. package/lib/commonjs/index.js.map +1 -1
  110. package/lib/commonjs/init.js +10 -0
  111. package/lib/commonjs/init.js.map +1 -1
  112. package/lib/commonjs/jestUtils/index.js +20 -0
  113. package/lib/commonjs/jestUtils/index.js.map +1 -0
  114. package/lib/commonjs/jestUtils/jestUtils.js +375 -0
  115. package/lib/commonjs/jestUtils/jestUtils.js.map +1 -0
  116. package/lib/commonjs/utils.js +38 -0
  117. package/lib/commonjs/utils.js.map +1 -1
  118. package/lib/module/ActionType.js +7 -0
  119. package/lib/module/ActionType.js.map +1 -0
  120. package/lib/module/GestureHandlerRootView.android.js +5 -6
  121. package/lib/module/GestureHandlerRootView.android.js.map +1 -1
  122. package/lib/module/GestureHandlerRootView.js +2 -3
  123. package/lib/module/GestureHandlerRootView.js.map +1 -1
  124. package/lib/module/RNGestureHandlerModule.js +3 -2
  125. package/lib/module/RNGestureHandlerModule.js.map +1 -1
  126. package/lib/module/RNGestureHandlerModule.web.js +1 -1
  127. package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
  128. package/lib/module/components/DrawerLayout.js +2 -2
  129. package/lib/module/components/DrawerLayout.js.map +1 -1
  130. package/lib/module/components/GestureHandlerButton.js +4 -2
  131. package/lib/module/components/GestureHandlerButton.js.map +1 -1
  132. package/lib/module/components/Swipeable.js +22 -20
  133. package/lib/module/components/Swipeable.js.map +1 -1
  134. package/lib/module/components/touchables/TouchableOpacity.js +4 -2
  135. package/lib/module/components/touchables/TouchableOpacity.js.map +1 -1
  136. package/lib/module/fabric/RNGestureHandlerButtonNativeComponent.js +9 -0
  137. package/lib/module/fabric/RNGestureHandlerButtonNativeComponent.js.map +1 -0
  138. package/lib/module/fabric/RNGestureHandlerRootViewNativeComponent.js +9 -0
  139. package/lib/module/fabric/RNGestureHandlerRootViewNativeComponent.js.map +1 -0
  140. package/lib/module/getShadowNodeFromRef.js +17 -0
  141. package/lib/module/getShadowNodeFromRef.js.map +1 -0
  142. package/lib/module/getShadowNodeFromRef.web.js +8 -0
  143. package/lib/module/getShadowNodeFromRef.web.js.map +1 -0
  144. package/lib/module/handlers/FlingGestureHandler.js +2 -1
  145. package/lib/module/handlers/FlingGestureHandler.js.map +1 -1
  146. package/lib/module/handlers/ForceTouchGestureHandler.js +5 -3
  147. package/lib/module/handlers/ForceTouchGestureHandler.js.map +1 -1
  148. package/lib/module/handlers/LongPressGestureHandler.js +2 -1
  149. package/lib/module/handlers/LongPressGestureHandler.js.map +1 -1
  150. package/lib/module/handlers/NativeViewGestureHandler.js +2 -1
  151. package/lib/module/handlers/NativeViewGestureHandler.js.map +1 -1
  152. package/lib/module/handlers/PanGestureHandler.js +2 -1
  153. package/lib/module/handlers/PanGestureHandler.js.map +1 -1
  154. package/lib/module/handlers/PinchGestureHandler.js +2 -1
  155. package/lib/module/handlers/PinchGestureHandler.js.map +1 -1
  156. package/lib/module/handlers/RotationGestureHandler.js +2 -1
  157. package/lib/module/handlers/RotationGestureHandler.js.map +1 -1
  158. package/lib/module/handlers/TapGestureHandler.js +2 -1
  159. package/lib/module/handlers/TapGestureHandler.js.map +1 -1
  160. package/lib/module/handlers/createHandler.js +62 -10
  161. package/lib/module/handlers/createHandler.js.map +1 -1
  162. package/lib/module/handlers/createNativeWrapper.js +6 -2
  163. package/lib/module/handlers/createNativeWrapper.js.map +1 -1
  164. package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
  165. package/lib/module/handlers/gestures/GestureDetector.js +79 -32
  166. package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
  167. package/lib/module/handlers/gestures/eventReceiver.js +25 -7
  168. package/lib/module/handlers/gestures/eventReceiver.js.map +1 -1
  169. package/lib/module/handlers/gestures/forceTouchGesture.js.map +1 -1
  170. package/lib/module/handlers/gestures/gesture.js +16 -1
  171. package/lib/module/handlers/gestures/gesture.js.map +1 -1
  172. package/lib/module/handlers/gestures/gestureStateManager.js +6 -4
  173. package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -1
  174. package/lib/module/handlers/gestures/panGesture.js.map +1 -1
  175. package/lib/module/handlers/gestures/pinchGesture.js.map +1 -1
  176. package/lib/module/handlers/gestures/reanimatedWrapper.js +2 -1
  177. package/lib/module/handlers/gestures/reanimatedWrapper.js.map +1 -1
  178. package/lib/module/handlers/handlersRegistry.js +34 -6
  179. package/lib/module/handlers/handlersRegistry.js.map +1 -1
  180. package/lib/module/index.js.map +1 -1
  181. package/lib/module/init.js +6 -0
  182. package/lib/module/init.js.map +1 -1
  183. package/lib/module/jestUtils/index.js +2 -0
  184. package/lib/module/jestUtils/index.js.map +1 -0
  185. package/lib/module/jestUtils/jestUtils.js +350 -0
  186. package/lib/module/jestUtils/jestUtils.js.map +1 -0
  187. package/lib/module/utils.js +28 -0
  188. package/lib/module/utils.js.map +1 -1
  189. package/lib/typescript/ActionType.d.ts +7 -0
  190. package/lib/typescript/GestureHandlerRootView.android.d.ts +5 -2
  191. package/lib/typescript/GestureHandlerRootView.d.ts +1 -1
  192. package/lib/typescript/RNGestureHandlerModule.d.ts +3 -1
  193. package/lib/typescript/RNGestureHandlerModule.web.d.ts +2 -1
  194. package/lib/typescript/components/GestureHandlerButton.d.ts +2 -2
  195. package/lib/typescript/components/Swipeable.d.ts +12 -4
  196. package/lib/typescript/components/touchables/TouchableOpacity.d.ts +5 -1
  197. package/lib/typescript/getShadowNodeFromRef.d.ts +1 -0
  198. package/lib/typescript/getShadowNodeFromRef.web.d.ts +1 -0
  199. package/lib/typescript/handlers/FlingGestureHandler.d.ts +1 -0
  200. package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +2 -1
  201. package/lib/typescript/handlers/LongPressGestureHandler.d.ts +1 -0
  202. package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +1 -0
  203. package/lib/typescript/handlers/PanGestureHandler.d.ts +1 -0
  204. package/lib/typescript/handlers/PinchGestureHandler.d.ts +1 -0
  205. package/lib/typescript/handlers/RotationGestureHandler.d.ts +1 -0
  206. package/lib/typescript/handlers/TapGestureHandler.d.ts +1 -0
  207. package/lib/typescript/handlers/gestureHandlerCommon.d.ts +2 -4
  208. package/lib/typescript/handlers/gestures/GestureDetector.d.ts +4 -1
  209. package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +1 -2
  210. package/lib/typescript/handlers/gestures/gesture.d.ts +5 -0
  211. package/lib/typescript/handlers/gestures/panGesture.d.ts +1 -2
  212. package/lib/typescript/handlers/gestures/pinchGesture.d.ts +1 -2
  213. package/lib/typescript/handlers/handlersRegistry.d.ts +11 -3
  214. package/lib/typescript/index.d.ts +3 -0
  215. package/lib/typescript/jestUtils/index.d.ts +1 -0
  216. package/lib/typescript/jestUtils/jestUtils.d.ts +28 -0
  217. package/lib/typescript/utils.d.ts +6 -0
  218. package/lib/typescript/web/constants.d.ts +0 -1
  219. package/package.json +40 -16
  220. package/src/ActionType.ts +9 -0
  221. package/src/GestureHandlerRootView.android.tsx +14 -14
  222. package/src/GestureHandlerRootView.tsx +4 -4
  223. package/src/RNGestureHandlerModule.ts +11 -6
  224. package/src/RNGestureHandlerModule.web.ts +2 -1
  225. package/src/components/DrawerLayout.tsx +8 -2
  226. package/src/components/GestureHandlerButton.tsx +7 -4
  227. package/src/components/Swipeable.tsx +28 -22
  228. package/src/components/touchables/TouchableOpacity.tsx +6 -2
  229. package/src/fabric/RNGestureHandlerButtonNativeComponent.js +27 -0
  230. package/src/fabric/RNGestureHandlerRootViewNativeComponent.js +19 -0
  231. package/src/getShadowNodeFromRef.ts +19 -0
  232. package/src/getShadowNodeFromRef.web.ts +7 -0
  233. package/src/handlers/FlingGestureHandler.ts +3 -1
  234. package/src/handlers/ForceTouchGestureHandler.ts +8 -2
  235. package/src/handlers/LongPressGestureHandler.ts +3 -1
  236. package/src/handlers/NativeViewGestureHandler.ts +3 -1
  237. package/src/handlers/PanGestureHandler.ts +3 -1
  238. package/src/handlers/PinchGestureHandler.ts +3 -1
  239. package/src/handlers/RotationGestureHandler.ts +3 -1
  240. package/src/handlers/TapGestureHandler.ts +3 -1
  241. package/src/handlers/createHandler.ts +69 -7
  242. package/src/handlers/createNativeWrapper.tsx +7 -1
  243. package/src/handlers/gestureHandlerCommon.ts +2 -5
  244. package/src/handlers/gestures/GestureDetector.tsx +110 -37
  245. package/src/handlers/gestures/eventReceiver.ts +23 -19
  246. package/src/handlers/gestures/forceTouchGesture.ts +1 -1
  247. package/src/handlers/gestures/gesture.ts +21 -1
  248. package/src/handlers/gestures/gestureStateManager.ts +9 -12
  249. package/src/handlers/gestures/panGesture.ts +1 -1
  250. package/src/handlers/gestures/pinchGesture.ts +1 -1
  251. package/src/handlers/gestures/reanimatedWrapper.ts +4 -1
  252. package/src/handlers/handlersRegistry.ts +44 -6
  253. package/src/index.ts +3 -0
  254. package/src/init.ts +6 -0
  255. package/src/jestUtils/index.ts +1 -0
  256. package/src/jestUtils/jestUtils.ts +506 -0
  257. package/src/utils.ts +38 -0
  258. package/android/lib/src/main/java/com/swmansion/gesturehandler/BaseGestureHandlerInteractionController.kt +0 -18
  259. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerRegistryImpl.kt +0 -21
  260. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerPackage.kt +0 -17
@@ -52,5 +52,6 @@ export interface TapGestureConfig {
52
52
  }
53
53
  export interface TapGestureHandlerProps extends BaseGestureHandlerProps<TapGestureHandlerEventPayload>, TapGestureConfig {
54
54
  }
55
+ export declare const tapHandlerName = "TapGestureHandler";
55
56
  export declare type TapGestureHandler = typeof TapGestureHandler;
56
57
  export declare const TapGestureHandler: import("react").ComponentType<TapGestureHandlerProps & import("react").RefAttributes<any>>;
@@ -9,10 +9,7 @@ export interface GestureEventPayload {
9
9
  numberOfPointers: number;
10
10
  state: ValueOf<typeof State>;
11
11
  }
12
- export interface HandlerStateChangeEventPayload {
13
- handlerTag: number;
14
- numberOfPointers: number;
15
- state: ValueOf<typeof State>;
12
+ export interface HandlerStateChangeEventPayload extends GestureEventPayload {
16
13
  oldState: ValueOf<typeof State>;
17
14
  }
18
15
  export declare type HitSlop = number | Partial<Record<'left' | 'right' | 'top' | 'bottom' | 'vertical' | 'horizontal', number>> | Record<'width' | 'left', number> | Record<'width' | 'right', number> | Record<'height' | 'top', number> | Record<'height' | 'bottom', number>;
@@ -48,6 +45,7 @@ export declare type BaseGestureHandlerProps<ExtraEventPayloadT extends Record<st
48
45
  id?: string;
49
46
  waitFor?: React.Ref<unknown> | React.Ref<unknown>[];
50
47
  simultaneousHandlers?: React.Ref<unknown> | React.Ref<unknown>[];
48
+ testID?: string;
51
49
  onBegan?: (event: HandlerStateChangeEvent) => void;
52
50
  onFailed?: (event: HandlerStateChangeEvent) => void;
53
51
  onCancelled?: (event: HandlerStateChangeEvent) => void;
@@ -2,12 +2,15 @@ import React from 'react';
2
2
  import { GestureType, HandlerCallbacks } from './gesture';
3
3
  import { SharedValue } from './reanimatedWrapper';
4
4
  import { ComposedGesture } from './gestureComposition';
5
+ declare global {
6
+ function isFormsStackingContext(node: unknown): boolean | null;
7
+ }
5
8
  export declare type GestureConfigReference = {
6
9
  config: GestureType[];
7
10
  animatedEventHandler: unknown;
8
11
  animatedHandlers: SharedValue<HandlerCallbacks<Record<string, unknown>>[] | null> | null;
9
12
  firstExecution: boolean;
10
- useAnimated: boolean;
13
+ useReanimatedHook: boolean;
11
14
  };
12
15
  interface GestureDetectorProps {
13
16
  gesture?: ComposedGesture | GestureType;
@@ -1,7 +1,7 @@
1
1
  import { BaseGestureConfig, ContinousBaseGesture } from './gesture';
2
2
  import { ForceTouchGestureConfig, ForceTouchGestureHandlerEventPayload } from '../ForceTouchGestureHandler';
3
3
  import { GestureUpdateEvent } from '../gestureHandlerCommon';
4
- declare type ForceTouchGestureChangeEventPayload = {
4
+ export declare type ForceTouchGestureChangeEventPayload = {
5
5
  forceChange: number;
6
6
  };
7
7
  export declare class ForceTouchGesture extends ContinousBaseGesture<ForceTouchGestureHandlerEventPayload, ForceTouchGestureChangeEventPayload> {
@@ -13,4 +13,3 @@ export declare class ForceTouchGesture extends ContinousBaseGesture<ForceTouchGe
13
13
  onChange(callback: (event: GestureUpdateEvent<GestureUpdateEvent<ForceTouchGestureHandlerEventPayload & ForceTouchGestureChangeEventPayload>>) => void): this;
14
14
  }
15
15
  export declare type ForceTouchGestureType = InstanceType<typeof ForceTouchGesture>;
16
- export {};
@@ -16,6 +16,8 @@ export interface BaseGestureConfig extends CommonGestureConfig, Record<string, u
16
16
  simultaneousWith?: GestureRef[];
17
17
  needsPointerData?: boolean;
18
18
  manualActivation?: boolean;
19
+ runOnJS?: boolean;
20
+ testId?: string;
19
21
  }
20
22
  declare type TouchEventHandlerType = (event: GestureTouchEvent, stateManager: GestureStateManagerType) => void;
21
23
  export declare type HandlerCallbacks<EventPayloadT extends Record<string, unknown>> = {
@@ -83,11 +85,14 @@ export declare abstract class BaseGesture<EventPayloadT extends Record<string, u
83
85
  enabled(enabled: boolean): this;
84
86
  shouldCancelWhenOutside(value: boolean): this;
85
87
  hitSlop(hitSlop: HitSlop): this;
88
+ runOnJS(runOnJS: boolean): this;
86
89
  simultaneousWithExternalGesture(...gestures: Exclude<GestureRef, number>[]): this;
87
90
  requireExternalGestureToFail(...gestures: Exclude<GestureRef, number>[]): this;
91
+ withTestId(id: string): this;
88
92
  initialize(): void;
89
93
  toGestureArray(): GestureType[];
90
94
  prepare(): void;
95
+ get shouldUseReanimated(): boolean;
91
96
  }
92
97
  export declare abstract class ContinousBaseGesture<EventPayloadT extends Record<string, unknown>, EventChangePayloadT extends Record<string, unknown>> extends BaseGesture<EventPayloadT> {
93
98
  onUpdate(callback: (event: GestureUpdateEvent<EventPayloadT>) => void): this;
@@ -1,7 +1,7 @@
1
1
  import { BaseGestureConfig, ContinousBaseGesture } from './gesture';
2
2
  import { GestureUpdateEvent } from '../gestureHandlerCommon';
3
3
  import { PanGestureConfig, PanGestureHandlerEventPayload } from '../PanGestureHandler';
4
- declare type PanGestureChangeEventPayload = {
4
+ export declare type PanGestureChangeEventPayload = {
5
5
  changeX: number;
6
6
  changeY: number;
7
7
  };
@@ -23,4 +23,3 @@ export declare class PanGesture extends ContinousBaseGesture<PanGestureHandlerEv
23
23
  onChange(callback: (event: GestureUpdateEvent<PanGestureHandlerEventPayload & PanGestureChangeEventPayload>) => void): this;
24
24
  }
25
25
  export declare type PanGestureType = InstanceType<typeof PanGesture>;
26
- export {};
@@ -1,7 +1,7 @@
1
1
  import { ContinousBaseGesture } from './gesture';
2
2
  import { PinchGestureHandlerEventPayload } from '../PinchGestureHandler';
3
3
  import { GestureUpdateEvent } from '../gestureHandlerCommon';
4
- declare type PinchGestureChangeEventPayload = {
4
+ export declare type PinchGestureChangeEventPayload = {
5
5
  scaleChange: number;
6
6
  };
7
7
  export declare class PinchGesture extends ContinousBaseGesture<PinchGestureHandlerEventPayload, PinchGestureChangeEventPayload> {
@@ -9,4 +9,3 @@ export declare class PinchGesture extends ContinousBaseGesture<PinchGestureHandl
9
9
  onChange(callback: (event: GestureUpdateEvent<PinchGestureHandlerEventPayload & PinchGestureChangeEventPayload>) => void): this;
10
10
  }
11
11
  export declare type PinchGestureType = InstanceType<typeof PinchGesture>;
12
- export {};
@@ -1,6 +1,14 @@
1
1
  import { GestureType } from './gestures/gesture';
2
+ import { GestureEvent, HandlerStateChangeEvent } from './gestureHandlerCommon';
2
3
  export declare const handlerIDToTag: Record<string, number>;
3
4
  export declare function getNextHandlerTag(): number;
4
- export declare function registerHandler(handlerTag: number, handler: GestureType): void;
5
- export declare function unregisterHandler(handlerTag: number): void;
6
- export declare function findHandler(handlerTag: number): import("./gestures/gesture").BaseGesture<Record<string, unknown>> | import("./gestures/gesture").BaseGesture<Record<string, never>> | import("./gestures/gesture").BaseGesture<import("./TapGestureHandler").TapGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./PanGestureHandler").PanGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./LongPressGestureHandler").LongPressGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./RotationGestureHandler").RotationGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./PinchGestureHandler").PinchGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./FlingGestureHandler").FlingGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./ForceTouchGestureHandler").ForceTouchGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./NativeViewGestureHandler").NativeViewGestureHandlerPayload> | undefined;
5
+ export declare function registerHandler(handlerTag: number, handler: GestureType, testID?: string): void;
6
+ export declare function registerOldGestureHandler(handlerTag: number, handler: GestureHandlerCallbacks): void;
7
+ export declare function unregisterHandler(handlerTag: number, testID?: string): void;
8
+ export declare function findHandler(handlerTag: number): GestureType | undefined;
9
+ export declare function findOldGestureHandler(handlerTag: number): GestureHandlerCallbacks | undefined;
10
+ export declare function findHandlerByTestID(testID: string): import("./gestures/gesture").BaseGesture<Record<string, unknown>> | import("./gestures/gesture").BaseGesture<Record<string, never>> | import("./gestures/gesture").BaseGesture<import("./TapGestureHandler").TapGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./PanGestureHandler").PanGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./LongPressGestureHandler").LongPressGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./RotationGestureHandler").RotationGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./PinchGestureHandler").PinchGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./ForceTouchGestureHandler").ForceTouchGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./NativeViewGestureHandler").NativeViewGestureHandlerPayload> | null;
11
+ export interface GestureHandlerCallbacks {
12
+ onGestureEvent: (event: GestureEvent<any>) => void;
13
+ onGestureStateChange: (event: HandlerStateChangeEvent<any>) => void;
14
+ }
@@ -6,9 +6,12 @@ export type { GestureEvent, HandlerStateChangeEvent, GestureEventPayload, Handle
6
6
  export type { GestureType } from './handlers/gestures/gesture';
7
7
  export type { TapGestureHandlerEventPayload, TapGestureHandlerProps, } from './handlers/TapGestureHandler';
8
8
  export type { ForceTouchGestureHandlerEventPayload, ForceTouchGestureHandlerProps, } from './handlers/ForceTouchGestureHandler';
9
+ export type { ForceTouchGestureChangeEventPayload } from './handlers/gestures/forceTouchGesture';
9
10
  export type { LongPressGestureHandlerEventPayload, LongPressGestureHandlerProps, } from './handlers/LongPressGestureHandler';
10
11
  export type { PanGestureHandlerEventPayload, PanGestureHandlerProps, } from './handlers/PanGestureHandler';
12
+ export type { PanGestureChangeEventPayload } from './handlers/gestures/panGesture';
11
13
  export type { PinchGestureHandlerEventPayload, PinchGestureHandlerProps, } from './handlers/PinchGestureHandler';
14
+ export type { PinchGestureChangeEventPayload } from './handlers/gestures/pinchGesture';
12
15
  export type { RotationGestureHandlerEventPayload, RotationGestureHandlerProps, } from './handlers/RotationGestureHandler';
13
16
  export type { FlingGestureHandlerEventPayload, FlingGestureHandlerProps, } from './handlers/FlingGestureHandler';
14
17
  export { TapGestureHandler } from './handlers/TapGestureHandler';
@@ -0,0 +1 @@
1
+ export { getByGestureTestId, fireGestureHandler } from './jestUtils';
@@ -0,0 +1,28 @@
1
+ import { ReactTestInstance } from 'react-test-renderer';
2
+ import { FlingGestureHandler } from '../handlers/FlingGestureHandler';
3
+ import { ForceTouchGestureHandler, ForceTouchGestureHandlerEventPayload } from '../handlers/ForceTouchGestureHandler';
4
+ import { BaseGestureHandlerProps, GestureEvent, HandlerStateChangeEvent } from '../handlers/gestureHandlerCommon';
5
+ import { FlingGesture } from '../handlers/gestures/flingGesture';
6
+ import { ForceTouchGesture } from '../handlers/gestures/forceTouchGesture';
7
+ import { BaseGesture, GestureType } from '../handlers/gestures/gesture';
8
+ import { LongPressGesture } from '../handlers/gestures/longPressGesture';
9
+ import { NativeGesture } from '../handlers/gestures/nativeGesture';
10
+ import { PanGesture } from '../handlers/gestures/panGesture';
11
+ import { PinchGesture } from '../handlers/gestures/pinchGesture';
12
+ import { RotationGesture } from '../handlers/gestures/rotationGesture';
13
+ import { TapGesture } from '../handlers/gestures/tapGesture';
14
+ import { LongPressGestureHandler, LongPressGestureHandlerEventPayload } from '../handlers/LongPressGestureHandler';
15
+ import { NativeViewGestureHandler, NativeViewGestureHandlerPayload } from '../handlers/NativeViewGestureHandler';
16
+ import { PanGestureHandler, PanGestureHandlerEventPayload } from '../handlers/PanGestureHandler';
17
+ import { PinchGestureHandler, PinchGestureHandlerEventPayload } from '../handlers/PinchGestureHandler';
18
+ import { RotationGestureHandler, RotationGestureHandlerEventPayload } from '../handlers/RotationGestureHandler';
19
+ import { TapGestureHandler, TapGestureHandlerEventPayload } from '../handlers/TapGestureHandler';
20
+ declare type GestureHandlerTestEvent<TEventPayload extends Record<string, unknown> = Record<string, unknown>> = (GestureEvent<TEventPayload> | HandlerStateChangeEvent<TEventPayload>)['nativeEvent'];
21
+ declare type AllGestures = TapGesture | PanGesture | LongPressGesture | RotationGesture | PinchGesture | FlingGesture | ForceTouchGesture | NativeGesture;
22
+ declare type AllHandlers = TapGestureHandler | PanGestureHandler | LongPressGestureHandler | RotationGestureHandler | PinchGestureHandler | FlingGestureHandler | ForceTouchGestureHandler | NativeViewGestureHandler;
23
+ declare type ClassComponentConstructor<P> = new (props: P) => React.Component<P, any, any>;
24
+ declare type ExtractPayloadFromProps<T> = T extends BaseGestureHandlerProps<infer TPayload> ? TPayload : never;
25
+ declare type ExtractConfig<T> = T extends BaseGesture<infer TGesturePayload> ? TGesturePayload : T extends ClassComponentConstructor<infer THandlerProps> ? ExtractPayloadFromProps<THandlerProps> : Record<string, unknown>;
26
+ export declare function fireGestureHandler<THandler extends AllGestures | AllHandlers>(componentOrGesture: ReactTestInstance | GestureType, eventList?: Partial<GestureHandlerTestEvent<ExtractConfig<THandler>>>[]): void;
27
+ export declare function getByGestureTestId(testID: string): BaseGesture<Record<string, unknown>> | BaseGesture<Record<string, never>> | BaseGesture<TapGestureHandlerEventPayload> | BaseGesture<PanGestureHandlerEventPayload> | BaseGesture<LongPressGestureHandlerEventPayload> | BaseGesture<RotationGestureHandlerEventPayload> | BaseGesture<PinchGestureHandlerEventPayload> | BaseGesture<ForceTouchGestureHandlerEventPayload> | BaseGesture<NativeViewGestureHandlerPayload>;
28
+ export {};
@@ -1 +1,7 @@
1
1
  export declare function toArray<T>(object: T | T[]): T[];
2
+ export declare type withPrevAndCurrentMapFn<T, Transformed> = (previous: Transformed | null, current: T) => Transformed;
3
+ export declare function withPrevAndCurrent<T, Transformed>(array: T[], mapFn: withPrevAndCurrentMapFn<T, Transformed>): Transformed[];
4
+ export declare function hasProperty(object: object, key: string): boolean;
5
+ export declare function isJestEnv(): boolean;
6
+ export declare function tagMessage(msg: string): string;
7
+ export declare function isFabric(): boolean;
@@ -1,4 +1,3 @@
1
- import Hammer from '@egjs/hammerjs';
2
1
  export declare const CONTENT_TOUCHES_DELAY = 240;
3
2
  export declare const CONTENT_TOUCHES_QUICK_TAP_END_DELAY = 50;
4
3
  export declare const MULTI_FINGER_PAN_MAX_PINCH_THRESHOLD = 0.1;
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "react-native-gesture-handler",
3
- "version": "2.2.0",
3
+ "version": "2.3.2",
4
4
  "description": "Experimental implementation of a new declarative API for gesture handling in react-native",
5
5
  "scripts": {
6
6
  "prepare": "bob build",
7
7
  "test": "jest",
8
- "build": "yarn tsc",
8
+ "build": "yarn tsc -p tsconfig.build.json",
9
9
  "precommit": "lint-staged",
10
10
  "release": "npm login && release-it",
11
11
  "ts-check": "yarn tsc --noEmit",
@@ -25,11 +25,15 @@
25
25
  "android/gradle.properties",
26
26
  "android/src/main/AndroidManifest.xml",
27
27
  "android/src/main/java/",
28
+ "android/src/main/jni/",
29
+ "android/src/fabric/java",
30
+ "android/src/paper/java",
28
31
  "android/lib/build.gradle",
29
32
  "android/lib/src/main/java/",
30
33
  "android/common/src/main/java/",
31
34
  "ios/",
32
35
  "Swipeable/",
36
+ "jest-utils/",
33
37
  "DrawerLayout/",
34
38
  "README.md",
35
39
  "jestSetup.js",
@@ -57,7 +61,7 @@
57
61
  "prop-types": "^15.7.2"
58
62
  },
59
63
  "jest": {
60
- "preset": "jest-react-native",
64
+ "preset": "react-native",
61
65
  "modulePathIgnorePatterns": [
62
66
  "<rootDir>/lib/"
63
67
  ]
@@ -68,36 +72,41 @@
68
72
  "@babel/preset-env": "^7.12.11",
69
73
  "@babel/preset-typescript": "^7.12.7",
70
74
  "@babel/runtime": "^7.12.5",
75
+ "@testing-library/jest-native": "^4.0.4",
76
+ "@testing-library/react-native": "^9.0.0",
71
77
  "@types/hammerjs": "^2.0.38",
72
78
  "@types/hoist-non-react-statics": "^3.3.1",
73
- "@types/jest": "^26.0.19",
79
+ "@types/jest": "^27.0.3",
74
80
  "@types/react": "^17.0.0",
75
81
  "@types/react-native": "^0.64.2",
76
82
  "@types/react-test-renderer": "^17.0.0",
77
- "@typescript-eslint/eslint-plugin": "^4.10.0",
78
- "@typescript-eslint/parser": "^4.10.0",
83
+ "@typescript-eslint/eslint-plugin": "^4.33.0",
84
+ "@typescript-eslint/parser": "^4.33.0",
79
85
  "babel-jest": "^26.6.3",
80
86
  "eslint": "^7.15.0",
81
87
  "eslint-config-satya164": "^3.1.8",
82
88
  "eslint-import-resolver-babel-module": "^5.2.0",
83
89
  "eslint-plugin-import": "^2.22.1",
90
+ "eslint-plugin-jest": "^26.0.0",
84
91
  "expo": "^35.0.1",
85
- "flow-bin": "^0.98.0",
86
92
  "husky": "^0.14.3",
87
- "jest": "^24.7.1",
88
- "jest-react-native": "16.0.0",
89
- "lint-staged": "^10.2.11",
93
+ "jest": "^26.6.3",
94
+ "lint-staged": "^12.3.2",
90
95
  "metro-react-native-babel-preset": "^0.64.0",
91
96
  "prettier": "^2.2.1",
92
97
  "react": "^16.8.6",
93
98
  "react-dom": "^16.12.0",
94
99
  "react-native": "^0.64.0",
95
100
  "react-native-builder-bob": "^0.17.1",
96
- "react-native-reanimated": "^2.0.0",
101
+ "react-native-reanimated": "^2.3.1",
97
102
  "react-native-web": "^0.11.7",
98
- "react-test-renderer": "16.8.6",
103
+ "react-test-renderer": "17.0.2",
99
104
  "release-it": "^13.6.5",
100
- "typescript": "^4.1.2"
105
+ "typescript": "^4.5.5"
106
+ },
107
+ "peerDependencies": {
108
+ "react": "*",
109
+ "react-native": "*"
101
110
  },
102
111
  "lint-staged": {
103
112
  "*.{ts,tsx}": [
@@ -117,11 +126,26 @@
117
126
  "targets": [
118
127
  "commonjs",
119
128
  "module",
120
- "typescript"
129
+ [
130
+ "typescript",
131
+ {
132
+ "project": "tsconfig.build.json"
133
+ }
134
+ ]
121
135
  ]
122
136
  },
123
137
  "eslintIgnore": [
124
138
  "node_modules/",
125
- "lib/"
126
- ]
139
+ "lib/",
140
+ "src/fabric/*NativeComponent.js"
141
+ ],
142
+ "codegenConfig": {
143
+ "libraries": [
144
+ {
145
+ "name": "rngesturehandler",
146
+ "type": "components",
147
+ "jsSrcsDir": "./src/fabric"
148
+ }
149
+ ]
150
+ }
127
151
  }
@@ -0,0 +1,9 @@
1
+ export const ActionType = {
2
+ REANIMATED_WORKLET: 1,
3
+ NATIVE_ANIMATED_EVENT: 2,
4
+ JS_FUNCTION_OLD_API: 3,
5
+ JS_FUNCTION_NEW_API: 4,
6
+ } as const;
7
+
8
+ // eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; it can be used as a type and as a value
9
+ export type ActionType = typeof ActionType[keyof typeof ActionType];
@@ -1,18 +1,18 @@
1
+ /* eslint-disable @typescript-eslint/no-var-requires */
1
2
  import * as React from 'react';
2
- import { requireNativeComponent } from 'react-native';
3
- import { GestureHandlerRootViewProps } from './GestureHandlerRootView';
3
+ import { PropsWithChildren } from 'react';
4
+ import { requireNativeComponent, ViewProps } from 'react-native';
5
+ import { isFabric } from './utils';
4
6
 
5
- const GestureHandlerRootViewNative = requireNativeComponent(
6
- 'GestureHandlerRootView'
7
- );
7
+ const GestureHandlerRootViewNativeComponent = isFabric()
8
+ ? require('./fabric/RNGestureHandlerRootViewNativeComponent').default
9
+ : requireNativeComponent('RNGestureHandlerRootView');
8
10
 
9
- export default function GestureHandlerRootView({
10
- children,
11
- ...rest
12
- }: GestureHandlerRootViewProps) {
13
- return (
14
- <GestureHandlerRootViewNative {...rest}>
15
- {children}
16
- </GestureHandlerRootViewNative>
17
- );
11
+ export interface GestureHandlerRootViewProps
12
+ extends PropsWithChildren<ViewProps> {}
13
+
14
+ export default function GestureHandlerRootView(
15
+ props: GestureHandlerRootViewProps
16
+ ) {
17
+ return <GestureHandlerRootViewNativeComponent {...props} />;
18
18
  }
@@ -5,8 +5,8 @@ import { View, ViewProps } from 'react-native';
5
5
  export interface GestureHandlerRootViewProps
6
6
  extends PropsWithChildren<ViewProps> {}
7
7
 
8
- export default function GestureHandlerRootView({
9
- ...rest
10
- }: GestureHandlerRootViewProps) {
11
- return <View {...rest} />;
8
+ export default function GestureHandlerRootView(
9
+ props: GestureHandlerRootViewProps
10
+ ) {
11
+ return <View {...props} />;
12
12
  }
@@ -1,14 +1,18 @@
1
1
  import { NativeModules } from 'react-native';
2
+ import { ActionType } from './ActionType';
3
+ import { tagMessage } from './utils';
2
4
  const { RNGestureHandlerModule } = NativeModules;
3
5
 
4
6
  if (RNGestureHandlerModule == null) {
5
7
  console.error(
6
- `react-native-gesture-handler module was not found. Make sure you're running your app on the native platform and your code is linked properly (cd ios && pod install && cd ..).
8
+ tagMessage(
9
+ `react-native-gesture-handler module was not found. Make sure you're running your app on the native platform and your code is linked properly (cd ios && pod install && cd ..).
7
10
 
8
- For installation instructions, please refer to https://docs.swmansion.com/react-native-gesture-handler/docs/#installation`
9
- .split('\n')
10
- .map((line) => line.trim())
11
- .join('\n')
11
+ For installation instructions, please refer to https://docs.swmansion.com/react-native-gesture-handler/docs/#installation`
12
+ .split('\n')
13
+ .map((line) => line.trim())
14
+ .join('\n')
15
+ )
12
16
  );
13
17
  }
14
18
 
@@ -23,13 +27,14 @@ export type RNGestureHandlerModuleProps = {
23
27
  attachGestureHandler: (
24
28
  handlerTag: number,
25
29
  newView: number,
26
- usingDeviceEvents: boolean
30
+ actionType: ActionType
27
31
  ) => void;
28
32
  updateGestureHandler: (
29
33
  handlerTag: number,
30
34
  newConfig: Readonly<Record<string, unknown>>
31
35
  ) => void;
32
36
  dropGestureHandler: (handlerTag: number) => void;
37
+ install: () => void;
33
38
  };
34
39
 
35
40
  export default RNGestureHandlerModule as RNGestureHandlerModuleProps;
@@ -1,3 +1,4 @@
1
+ import { ActionType } from './ActionType';
1
2
  import { Direction } from './web/constants';
2
3
  import FlingGestureHandler from './web/FlingGestureHandler';
3
4
  import LongPressGestureHandler from './web/LongPressGestureHandler';
@@ -44,7 +45,7 @@ export default {
44
45
  attachGestureHandler(
45
46
  handlerTag: number,
46
47
  newView: number,
47
- _usingDeviceEvents: boolean,
48
+ _actionType: ActionType,
48
49
  propsRef: React.RefObject<unknown>
49
50
  ) {
50
51
  NodeManager.getHandler(handlerTag).setView(newView, propsRef);
@@ -490,7 +490,8 @@ export default class DrawerLayout extends Component<
490
490
  // TODO: decide if it should be null or undefined is the proper value
491
491
  undefined,
492
492
  this.props.drawerWidth!,
493
- options.velocity ? options.velocity : 0
493
+ options.velocity ? options.velocity : 0,
494
+ options.speed
494
495
  );
495
496
 
496
497
  // We need to force the update, otherwise the overlay is not rerendered and
@@ -500,7 +501,12 @@ export default class DrawerLayout extends Component<
500
501
 
501
502
  closeDrawer = (options: DrawerMovementOption = {}) => {
502
503
  // TODO: decide if it should be null or undefined is the proper value
503
- this.animateDrawer(undefined, 0, options.velocity ? options.velocity : 0);
504
+ this.animateDrawer(
505
+ undefined,
506
+ 0,
507
+ options.velocity ? options.velocity : 0,
508
+ options.speed
509
+ );
504
510
 
505
511
  // We need to force the update, otherwise the overlay is not rerendered and
506
512
  // it would be still clickable
@@ -1,7 +1,10 @@
1
+ /* eslint-disable @typescript-eslint/no-var-requires */
1
2
  import { HostComponent, requireNativeComponent } from 'react-native';
2
3
  import { RawButtonProps } from './GestureButtons';
3
- const RNGestureHandlerButton: HostComponent<RawButtonProps> = requireNativeComponent(
4
- 'RNGestureHandlerButton'
5
- );
4
+ import { isFabric } from '../utils';
6
5
 
7
- export default RNGestureHandlerButton;
6
+ const RNGestureHandlerButtonNativeComponent = isFabric()
7
+ ? require('../fabric/RNGestureHandlerButtonNativeComponent').default
8
+ : requireNativeComponent('RNGestureHandlerButton');
9
+
10
+ export default RNGestureHandlerButtonNativeComponent as HostComponent<RawButtonProps>;
@@ -90,11 +90,15 @@ export interface SwipeableProps
90
90
  overshootFriction?: number;
91
91
 
92
92
  /**
93
+ * @deprecated Use `direction` argument of onSwipeableOpen()
94
+ *
93
95
  * Called when left action panel gets open.
94
96
  */
95
97
  onSwipeableLeftOpen?: () => void;
96
98
 
97
99
  /**
100
+ * @deprecated Use `direction` argument of onSwipeableOpen()
101
+ *
98
102
  * Called when right action panel gets open.
99
103
  */
100
104
  onSwipeableRightOpen?: () => void;
@@ -102,19 +106,23 @@ export interface SwipeableProps
102
106
  /**
103
107
  * Called when action panel gets open (either right or left).
104
108
  */
105
- onSwipeableOpen?: () => void;
109
+ onSwipeableOpen?: (direction: 'left' | 'right') => void;
106
110
 
107
111
  /**
108
112
  * Called when action panel is closed.
109
113
  */
110
- onSwipeableClose?: () => void;
114
+ onSwipeableClose?: (direction: 'left' | 'right') => void;
111
115
 
112
116
  /**
117
+ * @deprecated Use `direction` argument of onSwipeableWillOpen()
118
+ *
113
119
  * Called when left action panel starts animating on open.
114
120
  */
115
121
  onSwipeableLeftWillOpen?: () => void;
116
122
 
117
123
  /**
124
+ * @deprecated Use `direction` argument of onSwipeableWillOpen()
125
+ *
118
126
  * Called when right action panel starts animating on open.
119
127
  */
120
128
  onSwipeableRightWillOpen?: () => void;
@@ -122,12 +130,12 @@ export interface SwipeableProps
122
130
  /**
123
131
  * Called when action panel starts animating on open (either right or left).
124
132
  */
125
- onSwipeableWillOpen?: () => void;
133
+ onSwipeableWillOpen?: (direction: 'left' | 'right') => void;
126
134
 
127
135
  /**
128
136
  * Called when action panel starts animating on close.
129
137
  */
130
- onSwipeableWillClose?: () => void;
138
+ onSwipeableWillClose?: (direction: 'left' | 'right') => void;
131
139
 
132
140
  /**
133
141
  *
@@ -369,29 +377,27 @@ export default class Swipeable extends Component<
369
377
  ...this.props.animationOptions,
370
378
  }).start(({ finished }) => {
371
379
  if (finished) {
372
- if (toValue > 0 && this.props.onSwipeableLeftOpen) {
373
- this.props.onSwipeableLeftOpen();
374
- } else if (toValue < 0 && this.props.onSwipeableRightOpen) {
375
- this.props.onSwipeableRightOpen();
376
- }
377
-
378
- if (toValue === 0) {
379
- this.props.onSwipeableClose?.();
380
+ if (toValue > 0) {
381
+ this.props.onSwipeableLeftOpen?.();
382
+ this.props.onSwipeableOpen?.('left');
383
+ } else if (toValue < 0) {
384
+ this.props.onSwipeableRightOpen?.();
385
+ this.props.onSwipeableOpen?.('right');
380
386
  } else {
381
- this.props.onSwipeableOpen?.();
387
+ const closingDirection = fromValue > 0 ? 'left' : 'right';
388
+ this.props.onSwipeableClose?.(closingDirection);
382
389
  }
383
390
  }
384
391
  });
385
- if (toValue > 0 && this.props.onSwipeableLeftWillOpen) {
386
- this.props.onSwipeableLeftWillOpen();
387
- } else if (toValue < 0 && this.props.onSwipeableRightWillOpen) {
388
- this.props.onSwipeableRightWillOpen();
389
- }
390
-
391
- if (toValue === 0) {
392
- this.props.onSwipeableWillClose?.();
392
+ if (toValue > 0) {
393
+ this.props.onSwipeableLeftWillOpen?.();
394
+ this.props.onSwipeableWillOpen?.('left');
395
+ } else if (toValue < 0) {
396
+ this.props.onSwipeableRightWillOpen?.();
397
+ this.props.onSwipeableWillOpen?.('right');
393
398
  } else {
394
- this.props.onSwipeableWillOpen?.();
399
+ const closingDirection = fromValue > 0 ? 'left' : 'right';
400
+ this.props.onSwipeableWillClose?.(closingDirection);
395
401
  }
396
402
  };
397
403
 
@@ -12,11 +12,15 @@ import GenericTouchable, {
12
12
  import * as React from 'react';
13
13
  import { Component } from 'react';
14
14
 
15
+ interface GHTouchableOpacityProps {
16
+ useNativeAnimations?: boolean;
17
+ }
18
+
15
19
  /**
16
20
  * TouchableOpacity bases on timing animation which has been used in RN's core
17
21
  */
18
22
  export default class TouchableOpacity extends Component<
19
- TouchableOpacityProps & GenericTouchableProps
23
+ TouchableOpacityProps & GenericTouchableProps & GHTouchableOpacityProps
20
24
  > {
21
25
  static defaultProps = {
22
26
  ...GenericTouchable.defaultProps,
@@ -36,7 +40,7 @@ export default class TouchableOpacity extends Component<
36
40
  toValue: value,
37
41
  duration: duration,
38
42
  easing: Easing.inOut(Easing.quad),
39
- useNativeDriver: false,
43
+ useNativeDriver: this.props.useNativeAnimations ?? true,
40
44
  }).start();
41
45
  };
42
46
 
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @flow strict-local
3
+ * @format
4
+ */
5
+ /* eslint-disable */
6
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
7
+ import type { HostComponent } from 'react-native';
8
+ import type { ColorValue } from 'react-native/Libraries/StyleSheet/StyleSheet';
9
+ import type { ViewProps } from 'react-native/Libraries/Components/View/ViewPropTypes';
10
+ import type { Int32 } from 'react-native/Libraries/Types/CodegenTypes';
11
+
12
+ type NativeProps = $ReadOnly<{|
13
+ ...ViewProps, // This is required.
14
+ exclusive: boolean,
15
+ foreground: boolean,
16
+ borderless: boolean,
17
+ enabled: boolean,
18
+ rippleColor: ColorValue,
19
+ rippleRadius: Int32,
20
+ |}>;
21
+
22
+ type ComponentType = HostComponent<NativeProps>;
23
+
24
+ export default (codegenNativeComponent<NativeProps>(
25
+ 'RNGestureHandlerButton',
26
+ {}
27
+ ): ComponentType);