react-native-gesture-handler 2.3.0 → 2.4.0

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 (175) hide show
  1. package/RNGestureHandler.podspec +2 -1
  2. package/android/build.gradle +10 -2
  3. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.kt +14 -2
  4. package/android/noreanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt +10 -0
  5. package/android/reanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt +17 -0
  6. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +11 -3
  7. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.kt +3 -41
  8. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.kt +6 -0
  9. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +10 -54
  10. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt +2 -0
  11. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.kt +6 -0
  12. package/ios/RNGHTouchEventType.h +9 -0
  13. package/ios/RNGestureHandler.h +2 -2
  14. package/ios/RNGestureHandler.m +21 -8
  15. package/ios/RNGestureHandler.xcodeproj/project.xcworkspace/xcuserdata/jakubpiasecki.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  16. package/ios/RNGestureHandler.xcodeproj/xcuserdata/jakubpiasecki.xcuserdatad/xcschemes/xcschememanagement.plist +19 -0
  17. package/ios/RNGestureHandlerButton.h +1 -0
  18. package/ios/RNGestureHandlerButton.m +9 -1
  19. package/ios/RNGestureHandlerButtonComponentView.mm +14 -1
  20. package/ios/RNGestureHandlerButtonManager.m +4 -1
  21. package/ios/RNGestureHandlerEvents.h +2 -2
  22. package/ios/RNGestureHandlerEvents.m +2 -2
  23. package/ios/RNGestureHandlerManager.h +2 -0
  24. package/ios/RNGestureHandlerManager.mm +30 -20
  25. package/ios/RNGestureHandlerModule.mm +18 -0
  26. package/ios/RNGestureHandlerPointerTracker.h +2 -2
  27. package/ios/RNGestureHandlerPointerTracker.m +9 -6
  28. package/ios/RNGestureHandlerRegistry.h +1 -0
  29. package/ios/RNGestureHandlerRegistry.m +10 -0
  30. package/jest-utils/package.json +6 -0
  31. package/lib/commonjs/GestureHandlerRootView.android.js +7 -1
  32. package/lib/commonjs/GestureHandlerRootView.android.js.map +1 -1
  33. package/lib/commonjs/GestureHandlerRootView.js +6 -0
  34. package/lib/commonjs/GestureHandlerRootView.js.map +1 -1
  35. package/lib/commonjs/GestureHandlerRootView.web.js +19 -0
  36. package/lib/commonjs/GestureHandlerRootView.web.js.map +1 -0
  37. package/lib/commonjs/RNGestureHandlerModule.js +5 -0
  38. package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
  39. package/lib/commonjs/RNGestureHandlerModule.web.js +4 -1
  40. package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
  41. package/lib/commonjs/{EventType.js → TouchEventType.js} +4 -4
  42. package/lib/commonjs/TouchEventType.js.map +1 -0
  43. package/lib/commonjs/components/GestureButtons.js.map +1 -1
  44. package/lib/commonjs/components/GestureHandlerButton.js +1 -1
  45. package/lib/commonjs/components/GestureHandlerButton.js.map +1 -1
  46. package/lib/commonjs/components/touchables/GenericTouchable.js +2 -0
  47. package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -1
  48. package/lib/commonjs/components/touchables/TouchableOpacity.js +3 -1
  49. package/lib/commonjs/components/touchables/TouchableOpacity.js.map +1 -1
  50. package/lib/commonjs/fabric/RNGestureHandlerButtonNativeComponent.js +4 -6
  51. package/lib/commonjs/fabric/RNGestureHandlerButtonNativeComponent.js.map +1 -1
  52. package/lib/commonjs/fabric/RNGestureHandlerRootViewNativeComponent.js +4 -6
  53. package/lib/commonjs/fabric/RNGestureHandlerRootViewNativeComponent.js.map +1 -1
  54. package/lib/commonjs/getShadowNodeFromRef.js +12 -9
  55. package/lib/commonjs/getShadowNodeFromRef.js.map +1 -1
  56. package/lib/commonjs/handlers/createHandler.js +10 -14
  57. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  58. package/lib/commonjs/handlers/gestureHandlerCommon.js +18 -1
  59. package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
  60. package/lib/commonjs/handlers/gestures/GestureDetector.js +41 -21
  61. package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
  62. package/lib/commonjs/handlers/gestures/eventReceiver.js +6 -5
  63. package/lib/commonjs/handlers/gestures/eventReceiver.js.map +1 -1
  64. package/lib/commonjs/handlers/gestures/gesture.js +11 -2
  65. package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
  66. package/lib/commonjs/index.js +0 -14
  67. package/lib/commonjs/index.js.map +1 -1
  68. package/lib/commonjs/init.js +10 -1
  69. package/lib/commonjs/init.js.map +1 -1
  70. package/lib/commonjs/jestUtils/index.js +20 -0
  71. package/lib/commonjs/jestUtils/index.js.map +1 -0
  72. package/lib/commonjs/{jestUtils.js → jestUtils/jestUtils.js} +12 -12
  73. package/lib/commonjs/jestUtils/jestUtils.js.map +1 -0
  74. package/lib/commonjs/utils.js +23 -1
  75. package/lib/commonjs/utils.js.map +1 -1
  76. package/lib/commonjs/web/GestureHandler.js +4 -1
  77. package/lib/commonjs/web/GestureHandler.js.map +1 -1
  78. package/lib/module/GestureHandlerRootView.android.js +7 -2
  79. package/lib/module/GestureHandlerRootView.android.js.map +1 -1
  80. package/lib/module/GestureHandlerRootView.js +5 -0
  81. package/lib/module/GestureHandlerRootView.js.map +1 -1
  82. package/lib/module/GestureHandlerRootView.web.js +6 -0
  83. package/lib/module/GestureHandlerRootView.web.js.map +1 -0
  84. package/lib/module/RNGestureHandlerModule.js +5 -0
  85. package/lib/module/RNGestureHandlerModule.js.map +1 -1
  86. package/lib/module/RNGestureHandlerModule.web.js +4 -1
  87. package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
  88. package/lib/module/{EventType.js → TouchEventType.js} +2 -2
  89. package/lib/module/TouchEventType.js.map +1 -0
  90. package/lib/module/components/GestureButtons.js.map +1 -1
  91. package/lib/module/components/GestureHandlerButton.js +2 -2
  92. package/lib/module/components/GestureHandlerButton.js.map +1 -1
  93. package/lib/module/components/touchables/GenericTouchable.js +2 -0
  94. package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
  95. package/lib/module/components/touchables/TouchableOpacity.js +4 -2
  96. package/lib/module/components/touchables/TouchableOpacity.js.map +1 -1
  97. package/lib/module/fabric/RNGestureHandlerButtonNativeComponent.js +5 -7
  98. package/lib/module/fabric/RNGestureHandlerButtonNativeComponent.js.map +1 -1
  99. package/lib/module/fabric/RNGestureHandlerRootViewNativeComponent.js +5 -8
  100. package/lib/module/fabric/RNGestureHandlerRootViewNativeComponent.js.map +1 -1
  101. package/lib/module/getShadowNodeFromRef.js +11 -8
  102. package/lib/module/getShadowNodeFromRef.js.map +1 -1
  103. package/lib/module/handlers/createHandler.js +10 -17
  104. package/lib/module/handlers/createHandler.js.map +1 -1
  105. package/lib/module/handlers/gestureHandlerCommon.js +11 -1
  106. package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
  107. package/lib/module/handlers/gestures/GestureDetector.js +41 -22
  108. package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
  109. package/lib/module/handlers/gestures/eventReceiver.js +6 -7
  110. package/lib/module/handlers/gestures/eventReceiver.js.map +1 -1
  111. package/lib/module/handlers/gestures/gesture.js +10 -2
  112. package/lib/module/handlers/gestures/gesture.js.map +1 -1
  113. package/lib/module/index.js +0 -1
  114. package/lib/module/index.js.map +1 -1
  115. package/lib/module/init.js +6 -1
  116. package/lib/module/init.js.map +1 -1
  117. package/lib/module/jestUtils/index.js +2 -0
  118. package/lib/module/jestUtils/index.js.map +1 -0
  119. package/lib/module/{jestUtils.js → jestUtils/jestUtils.js} +12 -12
  120. package/lib/module/jestUtils/jestUtils.js.map +1 -0
  121. package/lib/module/utils.js +17 -1
  122. package/lib/module/utils.js.map +1 -1
  123. package/lib/module/web/GestureHandler.js +4 -1
  124. package/lib/module/web/GestureHandler.js.map +1 -1
  125. package/lib/typescript/GestureHandlerRootView.web.d.ts +5 -0
  126. package/lib/typescript/RNGestureHandlerModule.d.ts +1 -0
  127. package/lib/typescript/RNGestureHandlerModule.web.d.ts +1 -0
  128. package/lib/typescript/{EventType.d.ts → TouchEventType.d.ts} +2 -2
  129. package/lib/typescript/components/GestureButtons.d.ts +18 -6
  130. package/lib/typescript/components/touchables/TouchableOpacity.d.ts +5 -1
  131. package/lib/typescript/fabric/RNGestureHandlerButtonNativeComponent.d.ts +13 -0
  132. package/lib/typescript/fabric/RNGestureHandlerRootViewNativeComponent.d.ts +5 -0
  133. package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +1 -1
  134. package/lib/typescript/handlers/gestureHandlerCommon.d.ts +5 -3
  135. package/lib/typescript/handlers/gestures/GestureDetector.d.ts +0 -3
  136. package/lib/typescript/handlers/gestures/eventReceiver.d.ts +2 -0
  137. package/lib/typescript/handlers/gestures/gesture.d.ts +2 -0
  138. package/lib/typescript/index.d.ts +0 -1
  139. package/lib/typescript/init.d.ts +1 -0
  140. package/lib/typescript/jestUtils/index.d.ts +1 -0
  141. package/lib/typescript/{jestUtils.d.ts → jestUtils/jestUtils.d.ts} +18 -18
  142. package/lib/typescript/utils.d.ts +2 -0
  143. package/lib/typescript/web/GestureHandler.d.ts +1 -1
  144. package/package.json +5 -2
  145. package/src/GestureHandlerRootView.android.tsx +8 -2
  146. package/src/GestureHandlerRootView.tsx +6 -0
  147. package/src/GestureHandlerRootView.web.tsx +12 -0
  148. package/src/RNGestureHandlerModule.ts +7 -0
  149. package/src/RNGestureHandlerModule.web.ts +2 -0
  150. package/src/{EventType.ts → TouchEventType.ts} +2 -2
  151. package/src/components/GestureButtons.tsx +21 -7
  152. package/src/components/GestureHandlerButton.tsx +2 -2
  153. package/src/components/touchables/GenericTouchable.tsx +2 -0
  154. package/src/components/touchables/TouchableOpacity.tsx +6 -2
  155. package/src/fabric/RNGestureHandlerButtonNativeComponent.ts +27 -0
  156. package/src/fabric/RNGestureHandlerRootViewNativeComponent.ts +12 -0
  157. package/src/getShadowNodeFromRef.ts +12 -9
  158. package/src/handlers/createHandler.ts +7 -17
  159. package/src/handlers/gestureHandlerCommon.ts +19 -2
  160. package/src/handlers/gestures/GestureDetector.tsx +64 -31
  161. package/src/handlers/gestures/eventReceiver.ts +6 -6
  162. package/src/handlers/gestures/gesture.ts +13 -2
  163. package/src/index.ts +0 -1
  164. package/src/init.ts +8 -1
  165. package/src/jestUtils/index.ts +1 -0
  166. package/src/{jestUtils.ts → jestUtils/jestUtils.ts} +21 -21
  167. package/src/utils.ts +20 -0
  168. package/src/web/GestureHandler.ts +7 -1
  169. package/ios/RNTouchEventType.h +0 -9
  170. package/lib/commonjs/EventType.js.map +0 -1
  171. package/lib/commonjs/jestUtils.js.map +0 -1
  172. package/lib/module/EventType.js.map +0 -1
  173. package/lib/module/jestUtils.js.map +0 -1
  174. package/src/fabric/RNGestureHandlerButtonNativeComponent.js +0 -27
  175. package/src/fabric/RNGestureHandlerRootViewNativeComponent.js +0 -19
@@ -1,22 +1,22 @@
1
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';
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
20
  declare type GestureHandlerTestEvent<TEventPayload extends Record<string, unknown> = Record<string, unknown>> = (GestureEvent<TEventPayload> | HandlerStateChangeEvent<TEventPayload>)['nativeEvent'];
21
21
  declare type AllGestures = TapGesture | PanGesture | LongPressGesture | RotationGesture | PinchGesture | FlingGesture | ForceTouchGesture | NativeGesture;
22
22
  declare type AllHandlers = TapGestureHandler | PanGestureHandler | LongPressGestureHandler | RotationGestureHandler | PinchGestureHandler | FlingGestureHandler | ForceTouchGestureHandler | NativeViewGestureHandler;
@@ -5,3 +5,5 @@ export declare function hasProperty(object: object, key: string): boolean;
5
5
  export declare function isJestEnv(): boolean;
6
6
  export declare function tagMessage(msg: string): string;
7
7
  export declare function isFabric(): boolean;
8
+ export declare function shouldUseCodegenNativeComponent(): boolean;
9
+ export declare function isRemoteDebuggingEnabled(): boolean;
@@ -109,7 +109,7 @@ declare abstract class GestureHandler {
109
109
  nativeEvent: {
110
110
  handlerTag: any;
111
111
  target: any;
112
- oldState: State;
112
+ oldState: State | undefined;
113
113
  numberOfPointers: number;
114
114
  state: State;
115
115
  pointerInside: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-gesture-handler",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "description": "Experimental implementation of a new declarative API for gesture handling in react-native",
5
5
  "scripts": {
6
6
  "prepare": "bob build",
@@ -31,8 +31,11 @@
31
31
  "android/lib/build.gradle",
32
32
  "android/lib/src/main/java/",
33
33
  "android/common/src/main/java/",
34
+ "android/reanimated/src/main/java/",
35
+ "android/noreanimated/src/main/java/",
34
36
  "ios/",
35
37
  "Swipeable/",
38
+ "jest-utils/",
36
39
  "DrawerLayout/",
37
40
  "README.md",
38
41
  "jestSetup.js",
@@ -108,7 +111,7 @@
108
111
  "react-native": "*"
109
112
  },
110
113
  "lint-staged": {
111
- "*.{ts,tsx}": [
114
+ "./src/*.{ts,tsx}": [
112
115
  "prettier --write"
113
116
  ]
114
117
  },
@@ -2,9 +2,10 @@
2
2
  import * as React from 'react';
3
3
  import { PropsWithChildren } from 'react';
4
4
  import { requireNativeComponent, ViewProps } from 'react-native';
5
- import { isFabric } from './utils';
5
+ import { maybeInitializeFabric } from './init';
6
+ import { shouldUseCodegenNativeComponent } from './utils';
6
7
 
7
- const GestureHandlerRootViewNativeComponent = isFabric()
8
+ const GestureHandlerRootViewNativeComponent = shouldUseCodegenNativeComponent()
8
9
  ? require('./fabric/RNGestureHandlerRootViewNativeComponent').default
9
10
  : requireNativeComponent('RNGestureHandlerRootView');
10
11
 
@@ -14,5 +15,10 @@ export interface GestureHandlerRootViewProps
14
15
  export default function GestureHandlerRootView(
15
16
  props: GestureHandlerRootViewProps
16
17
  ) {
18
+ // try initialize fabric on the first render, at this point we can
19
+ // reliably check if fabric is enabled (the function contains a flag
20
+ // to make sure it's called only once)
21
+ maybeInitializeFabric();
22
+
17
23
  return <GestureHandlerRootViewNativeComponent {...props} />;
18
24
  }
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { PropsWithChildren } from 'react';
3
3
  import { View, ViewProps } from 'react-native';
4
+ import { maybeInitializeFabric } from './init';
4
5
 
5
6
  export interface GestureHandlerRootViewProps
6
7
  extends PropsWithChildren<ViewProps> {}
@@ -8,5 +9,10 @@ export interface GestureHandlerRootViewProps
8
9
  export default function GestureHandlerRootView(
9
10
  props: GestureHandlerRootViewProps
10
11
  ) {
12
+ // try initialize fabric on the first render, at this point we can
13
+ // reliably check if fabric is enabled (the function contains a flag
14
+ // to make sure it's called only once)
15
+ maybeInitializeFabric();
16
+
11
17
  return <View {...props} />;
12
18
  }
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import { PropsWithChildren } from 'react';
3
+ import { View, ViewProps } from 'react-native';
4
+
5
+ export interface GestureHandlerRootViewProps
6
+ extends PropsWithChildren<ViewProps> {}
7
+
8
+ export default function GestureHandlerRootView(
9
+ props: GestureHandlerRootViewProps
10
+ ) {
11
+ return <View {...props} />;
12
+ }
@@ -16,6 +16,12 @@ if (RNGestureHandlerModule == null) {
16
16
  );
17
17
  }
18
18
 
19
+ if (RNGestureHandlerModule.flushOperations === undefined) {
20
+ RNGestureHandlerModule.flushOperations = () => {
21
+ // NO-OP if not defined
22
+ };
23
+ }
24
+
19
25
  export type RNGestureHandlerModuleProps = {
20
26
  handleSetJSResponder: (tag: number, blockNativeResponder: boolean) => void;
21
27
  handleClearJSResponder: () => void;
@@ -35,6 +41,7 @@ export type RNGestureHandlerModuleProps = {
35
41
  ) => void;
36
42
  dropGestureHandler: (handlerTag: number) => void;
37
43
  install: () => void;
44
+ flushOperations: () => void;
38
45
  };
39
46
 
40
47
  export default RNGestureHandlerModule as RNGestureHandlerModuleProps;
@@ -59,4 +59,6 @@ export default {
59
59
  dropGestureHandler(handlerTag: number) {
60
60
  NodeManager.dropGestureHandler(handlerTag);
61
61
  },
62
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
63
+ flushOperations() {},
62
64
  };
@@ -1,4 +1,4 @@
1
- export const EventType = {
1
+ export const TouchEventType = {
2
2
  UNDETERMINED: 0,
3
3
  TOUCHES_DOWN: 1,
4
4
  TOUCHES_MOVE: 2,
@@ -7,4 +7,4 @@ export const EventType = {
7
7
  } as const;
8
8
 
9
9
  // eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; it can be used as a type and as a value
10
- export type EventType = typeof EventType[keyof typeof EventType];
10
+ export type TouchEventType = typeof TouchEventType[keyof typeof TouchEventType];
@@ -35,6 +35,27 @@ export interface RawButtonProps extends NativeViewGestureHandlerProps {
35
35
  * Defines color of native ripple animation used since API level 21.
36
36
  */
37
37
  rippleColor?: any; // it was present in BaseButtonProps before but is used here in code
38
+
39
+ /**
40
+ * Android only.
41
+ *
42
+ * Defines radius of native ripple animation used since API level 21.
43
+ */
44
+ rippleRadius?: number | null;
45
+
46
+ /**
47
+ * Android only.
48
+ *
49
+ * Set this to true if you want the ripple animation to render outside the view bounds.
50
+ */
51
+ borderless?: boolean;
52
+
53
+ /**
54
+ * Android only.
55
+ *
56
+ * Defines whether the ripple animation should be drawn on the foreground of the view.
57
+ */
58
+ foreground?: boolean;
38
59
  }
39
60
 
40
61
  export interface BaseButtonProps extends RawButtonProps {
@@ -69,13 +90,6 @@ export interface RectButtonProps extends BaseButtonProps {
69
90
  }
70
91
 
71
92
  export interface BorderlessButtonProps extends BaseButtonProps {
72
- /**
73
- * Android only.
74
- *
75
- * Set this to false if you want the ripple animation to render only within view bounds.
76
- */
77
- borderless?: boolean;
78
-
79
93
  /**
80
94
  * iOS only.
81
95
  *
@@ -1,9 +1,9 @@
1
1
  /* eslint-disable @typescript-eslint/no-var-requires */
2
2
  import { HostComponent, requireNativeComponent } from 'react-native';
3
3
  import { RawButtonProps } from './GestureButtons';
4
- import { isFabric } from '../utils';
4
+ import { shouldUseCodegenNativeComponent } from '../utils';
5
5
 
6
- const RNGestureHandlerButtonNativeComponent = isFabric()
6
+ const RNGestureHandlerButtonNativeComponent = shouldUseCodegenNativeComponent()
7
7
  ? require('../fabric/RNGestureHandlerButtonNativeComponent').default
8
8
  : requireNativeComponent('RNGestureHandlerButton');
9
9
 
@@ -258,6 +258,8 @@ export default class GenericTouchable extends Component<
258
258
  // TODO: check if changed to no 's' correctly, also removed 2 props that are no longer available: `accessibilityComponentType` and `accessibilityTraits`,
259
259
  // would be good to check if it is ok for sure, see: https://github.com/facebook/react-native/issues/24016
260
260
  accessibilityState: this.props.accessibilityState,
261
+ accessibilityActions: this.props.accessibilityActions,
262
+ onAccessibilityAction: this.props.onAccessibilityAction,
261
263
  nativeID: this.props.nativeID,
262
264
  onLayout: this.props.onLayout,
263
265
  hitSlop: this.props.hitSlop,
@@ -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
+ // @ts-ignore TODO: remove once there is a .d.ts file with definitions
2
+ import codegenNativeComponentUntyped from 'react-native/Libraries/Utilities/codegenNativeComponent';
3
+ // @ts-ignore TODO: remove once there is a .d.ts file with definitions
4
+ import type {
5
+ Int32,
6
+ WithDefault,
7
+ // @ts-ignore TODO: remove once there is a .d.ts file with definitions
8
+ } from 'react-native/Libraries/Types/CodegenTypes';
9
+ import type { ViewProps, HostComponent } from 'react-native';
10
+ // @ts-ignore TODO: remove once there is a .d.ts file with definitions
11
+ import type { ColorValue } from 'react-native/Libraries/StyleSheet/StyleSheet';
12
+
13
+ // eslint-disable-next-line @typescript-eslint/ban-types
14
+ const codegenNativeComponent = codegenNativeComponentUntyped as <T extends {}>(
15
+ name: string
16
+ ) => HostComponent<T>;
17
+
18
+ interface NativeProps extends ViewProps {
19
+ exclusive?: WithDefault<boolean, true>;
20
+ foreground?: boolean;
21
+ borderless?: boolean;
22
+ enabled?: WithDefault<boolean, true>;
23
+ rippleColor?: ColorValue;
24
+ rippleRadius?: Int32;
25
+ }
26
+
27
+ export default codegenNativeComponent<NativeProps>('RNGestureHandlerButton');
@@ -0,0 +1,12 @@
1
+ // @ts-ignore TODO: remove once there is a .d.ts file with definitions
2
+ import codegenNativeComponentUntyped from 'react-native/Libraries/Utilities/codegenNativeComponent';
3
+ import type { ViewProps, HostComponent } from 'react-native';
4
+
5
+ // eslint-disable-next-line @typescript-eslint/ban-types
6
+ const codegenNativeComponent = codegenNativeComponentUntyped as <T extends {}>(
7
+ name: string
8
+ ) => HostComponent<T>;
9
+
10
+ interface NativeProps extends ViewProps {}
11
+
12
+ export default codegenNativeComponent<NativeProps>('RNGestureHandlerRootView');
@@ -2,17 +2,20 @@
2
2
  // attached view may get flattened on Fabric. This implementation causes errors
3
3
  // on web due to the static resolution of `require` statements by webpack breaking
4
4
  // the conditional importing. Solved by making .web file.
5
- let findHostInstance_DEPRECATED = (_ref: any) => null;
6
-
7
- try {
8
- // eslint-disable-next-line @typescript-eslint/no-var-requires
9
- findHostInstance_DEPRECATED = require('react-native/Libraries/Renderer/shims/ReactFabric')
10
- .findHostInstance_DEPRECATED;
11
- } catch (e) {
12
- // do nothing
13
- }
5
+ let findHostInstance_DEPRECATED: (ref: any) => void;
14
6
 
15
7
  export function getShadowNodeFromRef(ref: any) {
8
+ // load findHostInstance_DEPRECATED lazily because it may not be available before render
9
+ if (findHostInstance_DEPRECATED === undefined) {
10
+ try {
11
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
12
+ findHostInstance_DEPRECATED = require('react-native/Libraries/Renderer/shims/ReactFabric')
13
+ .findHostInstance_DEPRECATED;
14
+ } catch (e) {
15
+ findHostInstance_DEPRECATED = (_ref: any) => null;
16
+ }
17
+ }
18
+
16
19
  // @ts-ignore Fabric
17
20
  return findHostInstance_DEPRECATED(ref)._internalInstanceHandle.stateNode
18
21
  .node;
@@ -23,9 +23,10 @@ import {
23
23
  GestureEvent,
24
24
  HandlerStateChangeEvent,
25
25
  findNodeHandle,
26
+ scheduleFlushOperations,
26
27
  } from './gestureHandlerCommon';
27
28
  import { ValueOf } from '../typeUtils';
28
- import { isFabric, isJestEnv, tagMessage } from '../utils';
29
+ import { isFabric, isJestEnv } from '../utils';
29
30
  import { ActionType } from '../ActionType';
30
31
 
31
32
  const UIManagerAny = UIManager as any;
@@ -147,18 +148,6 @@ type InternalEventHandlers = {
147
148
  onGestureHandlerStateChange?: (event: any) => void;
148
149
  };
149
150
 
150
- let showedRngh2Notice = false;
151
- function showRngh2NoticeIfNeeded() {
152
- if (!showedRngh2Notice) {
153
- console.warn(
154
- tagMessage(
155
- "Seems like you're using an old API with gesture components, check out new Gestures system!"
156
- )
157
- );
158
- showedRngh2Notice = true;
159
- }
160
- }
161
-
162
151
  // TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.
163
152
  export default function createHandler<
164
153
  T extends BaseGestureHandlerProps<U>,
@@ -199,9 +188,6 @@ export default function createHandler<
199
188
  }
200
189
  handlerIDToTag[props.id] = this.handlerTag;
201
190
  }
202
- if (__DEV__ && !isJestEnv()) {
203
- showRngh2NoticeIfNeeded();
204
- }
205
191
  }
206
192
 
207
193
  componentDidMount() {
@@ -251,6 +237,7 @@ export default function createHandler<
251
237
  componentWillUnmount() {
252
238
  this.inspectorToggleListener?.remove();
253
239
  RNGestureHandlerModule.dropGestureHandler(this.handlerTag);
240
+ scheduleFlushOperations();
254
241
  if (this.updateEnqueued) {
255
242
  clearImmediate(this.updateEnqueued);
256
243
  }
@@ -361,6 +348,8 @@ export default function createHandler<
361
348
  actionType
362
349
  );
363
350
  }
351
+
352
+ scheduleFlushOperations();
364
353
  };
365
354
 
366
355
  private updateGestureHandler = (
@@ -369,6 +358,7 @@ export default function createHandler<
369
358
  this.config = newConfig;
370
359
 
371
360
  RNGestureHandlerModule.updateGestureHandler(this.handlerTag, newConfig);
361
+ scheduleFlushOperations();
372
362
  };
373
363
 
374
364
  private update() {
@@ -494,7 +484,7 @@ export default function createHandler<
494
484
  handlerTag: this.handlerTag,
495
485
  }
496
486
  : {}),
497
- testID: this.props.testID,
487
+ testID: this.props.testID ?? child.props.testID,
498
488
  ...events,
499
489
  },
500
490
  grandChildren
@@ -6,16 +6,18 @@ import * as React from 'react';
6
6
  import { Platform, findNodeHandle as findNodeHandleRN } from 'react-native';
7
7
 
8
8
  import { State } from '../State';
9
- import { EventType } from '../EventType';
9
+ import { TouchEventType } from '../TouchEventType';
10
10
  import { ValueOf } from '../typeUtils';
11
11
  import { handlerIDToTag } from './handlersRegistry';
12
12
  import { toArray } from '../utils';
13
+ import RNGestureHandlerModule from '../RNGestureHandlerModule';
13
14
 
14
15
  const commonProps = [
15
16
  'id',
16
17
  'enabled',
17
18
  'shouldCancelWhenOutside',
18
19
  'hitSlop',
20
+ 'cancelsTouchesInView',
19
21
  ] as const;
20
22
 
21
23
  const componentInteractionProps = ['waitFor', 'simultaneousHandlers'] as const;
@@ -83,7 +85,7 @@ export type GestureTouchEvent = {
83
85
  handlerTag: number;
84
86
  numberOfTouches: number;
85
87
  state: ValueOf<typeof State>;
86
- eventType: EventType;
88
+ eventType: TouchEventType;
87
89
  allTouches: TouchData[];
88
90
  changedTouches: TouchData[];
89
91
  };
@@ -111,6 +113,7 @@ export type BaseGestureHandlerProps<
111
113
  waitFor?: React.Ref<unknown> | React.Ref<unknown>[];
112
114
  simultaneousHandlers?: React.Ref<unknown> | React.Ref<unknown>[];
113
115
  testID?: string;
116
+ cancelsTouchesInView?: boolean;
114
117
  // TODO(TS) - fix event types
115
118
  onBegan?: (event: HandlerStateChangeEvent) => void;
116
119
  onFailed?: (event: HandlerStateChangeEvent) => void;
@@ -180,3 +183,17 @@ export function findNodeHandle(
180
183
  if (Platform.OS === 'web') return node;
181
184
  return findNodeHandleRN(node);
182
185
  }
186
+
187
+ let scheduledFlushOperationsId: ReturnType<
188
+ typeof requestAnimationFrame
189
+ > | null = null;
190
+
191
+ export function scheduleFlushOperations() {
192
+ if (scheduledFlushOperationsId === null) {
193
+ scheduledFlushOperationsId = requestAnimationFrame(() => {
194
+ RNGestureHandlerModule.flushOperations();
195
+
196
+ scheduledFlushOperationsId = null;
197
+ });
198
+ }
199
+ }