react-native-gesture-handler 2.13.4 → 2.14.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. package/android/build.gradle +3 -2
  2. package/android/gradle.properties +2 -2
  3. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +36 -72
  4. package/android/src/main/java/com/swmansion/gesturehandler/react/Extensions.kt +1 -1
  5. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.kt +12 -14
  6. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.kt +8 -1
  7. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +34 -88
  8. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt +1 -1
  9. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.kt +18 -12
  10. package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/FlingGestureHandlerEventDataBuilder.kt +30 -0
  11. package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/GestureHandlerEventDataBuilder.kt +22 -0
  12. package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/HoverGestureHandlerEventDataBuilder.kt +30 -0
  13. package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/LongPressGestureHandlerEventDataBuilder.kt +33 -0
  14. package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/ManualGestureHandlerEventDataBuilder.kt +5 -0
  15. package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/NativeGestureHandlerEventDataBuilder.kt +18 -0
  16. package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/PanGestureHandlerEventDataBuilder.kt +42 -0
  17. package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/PinchGestureHandlerEventDataBuilder.kt +30 -0
  18. package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/RotationGestureHandlerEventDataBuilder.kt +30 -0
  19. package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/TapGestureHandlerEventDataBuilder.kt +30 -0
  20. package/android/src/main/jni/CMakeLists.txt +14 -2
  21. package/ios/Handlers/RNHoverHandler.m +15 -14
  22. package/ios/RNGestureHandler.m +11 -0
  23. package/ios/RNGestureHandlerButtonComponentView.mm +2 -0
  24. package/lib/commonjs/components/gestureHandlerRootHOC.js.map +1 -1
  25. package/lib/commonjs/components/touchables/TouchableNativeFeedback.android.js +1 -1
  26. package/lib/commonjs/components/touchables/TouchableNativeFeedback.android.js.map +1 -1
  27. package/lib/commonjs/components/touchables/TouchableWithoutFeedback.js.map +1 -1
  28. package/lib/commonjs/getReactNativeVersion.js +22 -0
  29. package/lib/commonjs/getReactNativeVersion.js.map +1 -0
  30. package/lib/commonjs/getReactNativeVersion.web.js +11 -0
  31. package/lib/commonjs/getReactNativeVersion.web.js.map +1 -0
  32. package/lib/commonjs/handlers/gestureHandlerCommon.js +1 -1
  33. package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
  34. package/lib/commonjs/handlers/gestures/GestureDetector.js +13 -3
  35. package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
  36. package/lib/commonjs/handlers/gestures/gesture.js +8 -0
  37. package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
  38. package/lib/commonjs/handlers/gestures/gestureStateManager.js +39 -37
  39. package/lib/commonjs/handlers/gestures/gestureStateManager.js.map +1 -1
  40. package/lib/commonjs/utils.js +0 -13
  41. package/lib/commonjs/utils.js.map +1 -1
  42. package/lib/commonjs/web/handlers/FlingGestureHandler.js +4 -6
  43. package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
  44. package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
  45. package/lib/commonjs/web/interfaces.js.map +1 -1
  46. package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js +4 -15
  47. package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js.map +1 -1
  48. package/lib/commonjs/web/tools/InteractionManager.js +27 -29
  49. package/lib/commonjs/web/tools/InteractionManager.js.map +1 -1
  50. package/lib/commonjs/web/tools/PointerEventManager.js +13 -3
  51. package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
  52. package/lib/module/components/gestureHandlerRootHOC.js.map +1 -1
  53. package/lib/module/components/touchables/TouchableNativeFeedback.android.js +1 -1
  54. package/lib/module/components/touchables/TouchableNativeFeedback.android.js.map +1 -1
  55. package/lib/module/components/touchables/TouchableWithoutFeedback.js.map +1 -1
  56. package/lib/module/getReactNativeVersion.js +10 -0
  57. package/lib/module/getReactNativeVersion.js.map +1 -0
  58. package/lib/module/getReactNativeVersion.web.js +4 -0
  59. package/lib/module/getReactNativeVersion.web.js.map +1 -0
  60. package/lib/module/handlers/gestureHandlerCommon.js +1 -1
  61. package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
  62. package/lib/module/handlers/gestures/GestureDetector.js +12 -3
  63. package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
  64. package/lib/module/handlers/gestures/gesture.js +8 -0
  65. package/lib/module/handlers/gestures/gesture.js.map +1 -1
  66. package/lib/module/handlers/gestures/gestureStateManager.js +44 -42
  67. package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -1
  68. package/lib/module/utils.js +0 -6
  69. package/lib/module/utils.js.map +1 -1
  70. package/lib/module/web/handlers/FlingGestureHandler.js +4 -6
  71. package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
  72. package/lib/module/web/handlers/GestureHandler.js.map +1 -1
  73. package/lib/module/web/interfaces.js.map +1 -1
  74. package/lib/module/web/tools/GestureHandlerOrchestrator.js +4 -15
  75. package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
  76. package/lib/module/web/tools/InteractionManager.js +27 -29
  77. package/lib/module/web/tools/InteractionManager.js.map +1 -1
  78. package/lib/module/web/tools/PointerEventManager.js +12 -3
  79. package/lib/module/web/tools/PointerEventManager.js.map +1 -1
  80. package/lib/typescript/ActionType.d.ts +1 -1
  81. package/lib/typescript/Directions.d.ts +1 -1
  82. package/lib/typescript/PlatformConstants.d.ts +1 -1
  83. package/lib/typescript/RNGestureHandlerModule.d.ts +1 -1
  84. package/lib/typescript/State.d.ts +1 -1
  85. package/lib/typescript/TouchEventType.d.ts +1 -1
  86. package/lib/typescript/components/DrawerLayout.d.ts +9 -9
  87. package/lib/typescript/components/GestureButtons.d.ts +3 -3
  88. package/lib/typescript/components/GestureComponents.d.ts +6 -6
  89. package/lib/typescript/components/GestureComponents.web.d.ts +1 -1
  90. package/lib/typescript/components/GestureHandlerRootView.android.d.ts +2 -1
  91. package/lib/typescript/components/GestureHandlerRootView.d.ts +2 -1
  92. package/lib/typescript/components/GestureHandlerRootView.web.d.ts +2 -1
  93. package/lib/typescript/components/Swipeable.d.ts +4 -4
  94. package/lib/typescript/components/gestureHandlerRootHOC.d.ts +1 -1
  95. package/lib/typescript/components/touchables/GenericTouchable.d.ts +4 -3
  96. package/lib/typescript/components/touchables/TouchableHighlight.d.ts +4 -3
  97. package/lib/typescript/components/touchables/TouchableNativeFeedback.android.d.ts +7 -6
  98. package/lib/typescript/components/touchables/TouchableOpacity.d.ts +3 -2
  99. package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts +1 -1
  100. package/lib/typescript/getReactNativeVersion.d.ts +4 -0
  101. package/lib/typescript/getReactNativeVersion.web.d.ts +1 -0
  102. package/lib/typescript/handlers/FlingGestureHandler.d.ts +2 -2
  103. package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +2 -2
  104. package/lib/typescript/handlers/LongPressGestureHandler.d.ts +2 -2
  105. package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +3 -3
  106. package/lib/typescript/handlers/PanGestureHandler.d.ts +2 -2
  107. package/lib/typescript/handlers/PinchGestureHandler.d.ts +2 -2
  108. package/lib/typescript/handlers/RotationGestureHandler.d.ts +2 -2
  109. package/lib/typescript/handlers/TapGestureHandler.d.ts +2 -2
  110. package/lib/typescript/handlers/createHandler.d.ts +1 -1
  111. package/lib/typescript/handlers/gestureHandlerCommon.d.ts +11 -10
  112. package/lib/typescript/handlers/gestureHandlerTypesCompat.d.ts +32 -32
  113. package/lib/typescript/handlers/gestures/GestureDetector.d.ts +2 -2
  114. package/lib/typescript/handlers/gestures/flingGesture.d.ts +1 -1
  115. package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +2 -2
  116. package/lib/typescript/handlers/gestures/gesture.d.ts +7 -5
  117. package/lib/typescript/handlers/gestures/gestureComposition.d.ts +4 -4
  118. package/lib/typescript/handlers/gestures/gestureStateManager.d.ts +3 -1
  119. package/lib/typescript/handlers/gestures/hoverGesture.d.ts +3 -3
  120. package/lib/typescript/handlers/gestures/longPressGesture.d.ts +1 -1
  121. package/lib/typescript/handlers/gestures/manualGesture.d.ts +1 -1
  122. package/lib/typescript/handlers/gestures/nativeGesture.d.ts +1 -1
  123. package/lib/typescript/handlers/gestures/panGesture.d.ts +2 -2
  124. package/lib/typescript/handlers/gestures/pinchGesture.d.ts +2 -2
  125. package/lib/typescript/handlers/gestures/rotationGesture.d.ts +2 -2
  126. package/lib/typescript/handlers/gestures/tapGesture.d.ts +1 -1
  127. package/lib/typescript/jestUtils/jestUtils.d.ts +6 -6
  128. package/lib/typescript/typeUtils.d.ts +1 -1
  129. package/lib/typescript/utils.d.ts +1 -5
  130. package/lib/typescript/web/interfaces.d.ts +4 -3
  131. package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts +0 -1
  132. package/lib/typescript/web/tools/InteractionManager.d.ts +2 -1
  133. package/lib/typescript/web_hammer/GestureHandler.d.ts +2 -2
  134. package/package.json +7 -7
  135. package/src/components/gestureHandlerRootHOC.tsx +1 -3
  136. package/src/components/touchables/TouchableNativeFeedback.android.tsx +2 -1
  137. package/src/components/touchables/TouchableWithoutFeedback.tsx +3 -3
  138. package/src/getReactNativeVersion.ts +11 -0
  139. package/src/getReactNativeVersion.web.ts +3 -0
  140. package/src/handlers/gestureHandlerCommon.ts +6 -1
  141. package/src/handlers/gestures/GestureDetector.tsx +9 -6
  142. package/src/handlers/gestures/gesture.ts +9 -1
  143. package/src/handlers/gestures/gestureStateManager.ts +42 -40
  144. package/src/utils.ts +0 -8
  145. package/src/web/handlers/FlingGestureHandler.ts +5 -5
  146. package/src/web/handlers/GestureHandler.ts +1 -1
  147. package/src/web/interfaces.ts +1 -0
  148. package/src/web/tools/GestureHandlerOrchestrator.ts +4 -13
  149. package/src/web/tools/InteractionManager.ts +37 -30
  150. package/src/web/tools/PointerEventManager.ts +14 -3
  151. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEventDataExtractor.kt +0 -8
  152. /package/android/{src/fabric → fabric/src/main}/java/com/swmansion/gesturehandler/RNGestureHandlerComponentsRegistry.java +0 -0
  153. /package/android/{src/fabric → fabric/src/main}/java/com/swmansion/gesturehandler/ReactContextExtensions.kt +0 -0
  154. /package/android/{src/paper → paper/src/main}/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java +0 -0
  155. /package/android/{src/paper → paper/src/main}/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerInterface.java +0 -0
  156. /package/android/{src/paper → paper/src/main}/java/com/facebook/react/viewmanagers/RNGestureHandlerRootViewManagerDelegate.java +0 -0
  157. /package/android/{src/paper → paper/src/main}/java/com/facebook/react/viewmanagers/RNGestureHandlerRootViewManagerInterface.java +0 -0
  158. /package/android/{src/paper → paper/src/main}/java/com/swmansion/gesturehandler/ReactContextExtensions.kt +0 -0
@@ -1,12 +1,12 @@
1
1
  import { ContinousBaseGesture } from './gesture';
2
2
  import { RotationGestureHandlerEventPayload } from '../RotationGestureHandler';
3
3
  import { GestureUpdateEvent } from '../gestureHandlerCommon';
4
- declare type RotationGestureChangeEventPayload = {
4
+ type RotationGestureChangeEventPayload = {
5
5
  rotationChange: number;
6
6
  };
7
7
  export declare class RotationGesture extends ContinousBaseGesture<RotationGestureHandlerEventPayload, RotationGestureChangeEventPayload> {
8
8
  constructor();
9
9
  onChange(callback: (event: GestureUpdateEvent<RotationGestureHandlerEventPayload & RotationGestureChangeEventPayload>) => void): this;
10
10
  }
11
- export declare type RotationGestureType = InstanceType<typeof RotationGesture>;
11
+ export type RotationGestureType = InstanceType<typeof RotationGesture>;
12
12
  export {};
@@ -11,4 +11,4 @@ export declare class TapGesture extends BaseGesture<TapGestureHandlerEventPayloa
11
11
  maxDeltaX(delta: number): this;
12
12
  maxDeltaY(delta: number): this;
13
13
  }
14
- export declare type TapGestureType = InstanceType<typeof TapGesture>;
14
+ export type TapGestureType = InstanceType<typeof TapGesture>;
@@ -17,12 +17,12 @@ import { PanGestureHandler, PanGestureHandlerEventPayload } from '../handlers/Pa
17
17
  import { PinchGestureHandler, PinchGestureHandlerEventPayload } from '../handlers/PinchGestureHandler';
18
18
  import { RotationGestureHandler, RotationGestureHandlerEventPayload } from '../handlers/RotationGestureHandler';
19
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>;
20
+ type GestureHandlerTestEvent<TEventPayload extends Record<string, unknown> = Record<string, unknown>> = (GestureEvent<TEventPayload> | HandlerStateChangeEvent<TEventPayload>)['nativeEvent'];
21
+ type AllGestures = TapGesture | PanGesture | LongPressGesture | RotationGesture | PinchGesture | FlingGesture | ForceTouchGesture | NativeGesture;
22
+ type AllHandlers = TapGestureHandler | PanGestureHandler | LongPressGestureHandler | RotationGestureHandler | PinchGestureHandler | FlingGestureHandler | ForceTouchGestureHandler | NativeViewGestureHandler;
23
+ type ClassComponentConstructor<P> = new (props: P) => React.Component<P, any, any>;
24
+ type ExtractPayloadFromProps<T> = T extends BaseGestureHandlerProps<infer TPayload> ? TPayload : never;
25
+ type ExtractConfig<T> = T extends BaseGesture<infer TGesturePayload> ? TGesturePayload : T extends ClassComponentConstructor<infer THandlerProps> ? ExtractPayloadFromProps<THandlerProps> : Record<string, unknown>;
26
26
  export declare function fireGestureHandler<THandler extends AllGestures | AllHandlers>(componentOrGesture: ReactTestInstance | GestureType, eventList?: Partial<GestureHandlerTestEvent<ExtractConfig<THandler>>>[]): void;
27
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
28
  export {};
@@ -1 +1 @@
1
- export declare type ValueOf<T> = T[keyof T];
1
+ export type ValueOf<T> = T[keyof T];
@@ -1,9 +1,5 @@
1
- export declare const REACT_NATIVE_VERSION: {
2
- major: number;
3
- minor: number;
4
- };
5
1
  export declare function toArray<T>(object: T | T[]): T[];
6
- export declare type withPrevAndCurrentMapFn<T, Transformed> = (previous: Transformed | null, current: T) => Transformed;
2
+ export type withPrevAndCurrentMapFn<T, Transformed> = (previous: Transformed | null, current: T) => Transformed;
7
3
  export declare function withPrevAndCurrent<T, Transformed>(array: T[], mapFn: withPrevAndCurrentMapFn<T, Transformed>): Transformed[];
8
4
  export declare function hasProperty(object: object, key: string): boolean;
9
5
  export declare function isJestEnv(): boolean;
@@ -14,11 +14,12 @@ export interface HitSlop {
14
14
  export interface Handler {
15
15
  handlerTag: number;
16
16
  }
17
- declare type ConfigArgs = number | boolean | HitSlop | UserSelect | ActiveCursor | Directions | Handler[] | null | undefined;
17
+ type ConfigArgs = number | boolean | HitSlop | UserSelect | ActiveCursor | Directions | Handler[] | null | undefined;
18
18
  export interface Config extends Record<string, ConfigArgs> {
19
19
  enabled?: boolean;
20
20
  simultaneousHandlers?: Handler[] | null;
21
21
  waitFor?: Handler[] | null;
22
+ blocksHandlers?: Handler[] | null;
22
23
  hitSlop?: HitSlop;
23
24
  shouldCancelWhenOutside?: boolean;
24
25
  userSelect?: UserSelect;
@@ -53,7 +54,7 @@ export interface Config extends Record<string, ConfigArgs> {
53
54
  disallowInterruption?: boolean;
54
55
  direction?: Directions;
55
56
  }
56
- declare type NativeEventArgs = number | State | boolean | undefined;
57
+ type NativeEventArgs = number | State | boolean | undefined;
57
58
  interface NativeEvent extends Record<string, NativeEventArgs> {
58
59
  numberOfPointers: number;
59
60
  state: State;
@@ -69,7 +70,7 @@ export interface PointerData {
69
70
  absoluteX: number;
70
71
  absoluteY: number;
71
72
  }
72
- declare type TouchNativeArgs = number | State | TouchEventType | PointerData[];
73
+ type TouchNativeArgs = number | State | TouchEventType | PointerData[];
73
74
  interface NativeTouchEvent extends Record<string, TouchNativeArgs> {
74
75
  handlerTag: number;
75
76
  state: State;
@@ -4,7 +4,6 @@ export default class GestureHandlerOrchestrator {
4
4
  private static instance;
5
5
  private gestureHandlers;
6
6
  private awaitingHandlers;
7
- private handlersToCancel;
8
7
  private handlingChangeSemaphore;
9
8
  private activationIndex;
10
9
  private constructor();
@@ -4,11 +4,12 @@ export default class InteractionManager {
4
4
  private static instance;
5
5
  private readonly waitForRelations;
6
6
  private readonly simultaneousRelations;
7
+ private readonly blocksHandlersRelations;
7
8
  private constructor();
8
9
  configureInteractions(handler: GestureHandler, config: Config): void;
9
10
  shouldWaitForHandlerFailure(handler: GestureHandler, otherHandler: GestureHandler): boolean;
10
11
  shouldRecognizeSimultaneously(handler: GestureHandler, otherHandler: GestureHandler): boolean;
11
- shouldRequireHandlerToWaitForFailure(_handler: GestureHandler, _otherHandler: GestureHandler): boolean;
12
+ shouldRequireHandlerToWaitForFailure(handler: GestureHandler, otherHandler: GestureHandler): boolean;
12
13
  shouldHandlerBeCancelledBy(_handler: GestureHandler, _otherHandler: GestureHandler): boolean;
13
14
  dropRelationsForHandlerWithTag(handlerTag: number): void;
14
15
  reset(): void;
@@ -1,8 +1,8 @@
1
1
  import { findNodeHandle } from 'react-native';
2
2
  import { State } from '../State';
3
3
  import { EventMap } from './constants';
4
- export declare type HammerInputExt = Omit<HammerInput, 'destroy' | 'handler' | 'init'>;
5
- export declare type Config = Partial<{
4
+ export type HammerInputExt = Omit<HammerInput, 'destroy' | 'handler' | 'init'>;
5
+ export type Config = Partial<{
6
6
  enabled: boolean;
7
7
  minPointers: number;
8
8
  maxPointers: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-gesture-handler",
3
- "version": "2.13.4",
3
+ "version": "2.14.1",
4
4
  "description": "Experimental implementation of a new declarative API for gesture handling in react-native",
5
5
  "scripts": {
6
6
  "prepare": "bob build && husky install",
@@ -31,8 +31,8 @@
31
31
  "android/src/main/AndroidManifest.xml",
32
32
  "android/src/main/java/",
33
33
  "android/src/main/jni/",
34
- "android/src/fabric/java",
35
- "android/src/paper/java",
34
+ "android/fabric/src/main/java",
35
+ "android/paper/src/main/java",
36
36
  "android/common/src/main/java/",
37
37
  "android/reanimated/src/main/java/",
38
38
  "android/noreanimated/src/main/java/",
@@ -77,12 +77,13 @@
77
77
  "@babel/preset-env": "^7.12.11",
78
78
  "@babel/preset-typescript": "^7.12.7",
79
79
  "@babel/runtime": "^7.12.5",
80
+ "@react-native/babel-preset": "^0.73.18",
80
81
  "@testing-library/jest-native": "^4.0.4",
81
82
  "@testing-library/react-native": "^9.0.0",
82
83
  "@types/hammerjs": "^2.0.38",
83
84
  "@types/hoist-non-react-statics": "^3.3.1",
84
85
  "@types/jest": "^27.0.3",
85
- "@types/react": "^18.0.24",
86
+ "@types/react": "^18.2.6",
86
87
  "@types/react-test-renderer": "^17.0.0",
87
88
  "@typescript-eslint/eslint-plugin": "^4.33.0",
88
89
  "@typescript-eslint/parser": "^4.33.0",
@@ -97,17 +98,16 @@
97
98
  "husky": "^8.0.1",
98
99
  "jest": "^26.6.3",
99
100
  "lint-staged": "^12.3.2",
100
- "metro-react-native-babel-preset": "^0.64.0",
101
101
  "prettier": "^2.7.1",
102
102
  "react": "18.2.0",
103
103
  "react-dom": "^16.12.0",
104
- "react-native": "0.72.0-rc.5",
104
+ "react-native": "0.73.0-rc.5",
105
105
  "react-native-builder-bob": "^0.17.1",
106
106
  "react-native-reanimated": "^2.3.1",
107
107
  "react-native-web": "^0.11.7",
108
108
  "react-test-renderer": "17.0.2",
109
109
  "release-it": "^13.6.5",
110
- "typescript": "^4.5.5"
110
+ "typescript": "5.0.4"
111
111
  },
112
112
  "peerDependencies": {
113
113
  "react": "*",
@@ -3,9 +3,7 @@ import { StyleSheet, StyleProp, ViewStyle } from 'react-native';
3
3
  import hoistNonReactStatics from 'hoist-non-react-statics';
4
4
  import GestureHandlerRootView from './GestureHandlerRootView';
5
5
 
6
- export default function gestureHandlerRootHOC<
7
- P extends Record<string, unknown>
8
- >(
6
+ export default function gestureHandlerRootHOC<P extends object>(
9
7
  Component: React.ComponentType<P>,
10
8
  containerStyles?: StyleProp<ViewStyle>
11
9
  ): React.ComponentType<P> {
@@ -56,7 +56,8 @@ export default class TouchableNativeFeedback extends Component<TouchableNativeFe
56
56
  rippleRadius,
57
57
  });
58
58
 
59
- static canUseNativeForeground = () => Platform.Version >= 23;
59
+ static canUseNativeForeground = () =>
60
+ Platform.OS === 'android' && Platform.Version >= 23;
60
61
 
61
62
  getExtraButtonProps() {
62
63
  const extraProps: TouchableNativeFeedbackExtraProps = {};
@@ -2,11 +2,11 @@ import * as React from 'react';
2
2
  import { PropsWithChildren } from 'react';
3
3
  import GenericTouchable, { GenericTouchableProps } from './GenericTouchable';
4
4
 
5
- export type TouchableWithoutFeedbackProps = GenericTouchable;
5
+ export type TouchableWithoutFeedbackProps = GenericTouchableProps;
6
6
 
7
7
  const TouchableWithoutFeedback = React.forwardRef<
8
- TouchableWithoutFeedbackProps,
9
- PropsWithChildren<GenericTouchableProps>
8
+ GenericTouchable,
9
+ PropsWithChildren<TouchableWithoutFeedbackProps>
10
10
  >((props, ref) => <GenericTouchable ref={ref} {...props} />);
11
11
 
12
12
  TouchableWithoutFeedback.defaultProps = GenericTouchable.defaultProps;
@@ -0,0 +1,11 @@
1
+ import pack from 'react-native/package.json';
2
+
3
+ const [majorStr, minorStr] = pack.version.split('.');
4
+ const REACT_NATIVE_VERSION = {
5
+ major: parseInt(majorStr, 10),
6
+ minor: parseInt(minorStr, 10),
7
+ };
8
+
9
+ export function getReactNativeVersion() {
10
+ return REACT_NATIVE_VERSION;
11
+ }
@@ -0,0 +1,3 @@
1
+ export function getReactNativeVersion() {
2
+ throw new Error('getReactNativeVersion is not supported on web');
3
+ }
@@ -23,7 +23,11 @@ const commonProps = [
23
23
  'activeCursor',
24
24
  ] as const;
25
25
 
26
- const componentInteractionProps = ['waitFor', 'simultaneousHandlers'] as const;
26
+ const componentInteractionProps = [
27
+ 'waitFor',
28
+ 'simultaneousHandlers',
29
+ 'blocksHandlers',
30
+ ] as const;
27
31
 
28
32
  export const baseGestureHandlerProps = [
29
33
  ...commonProps,
@@ -155,6 +159,7 @@ export type BaseGestureHandlerProps<
155
159
  id?: string;
156
160
  waitFor?: React.Ref<unknown> | React.Ref<unknown>[];
157
161
  simultaneousHandlers?: React.Ref<unknown> | React.Ref<unknown>[];
162
+ blocksHandlers?: React.Ref<unknown> | React.Ref<unknown>[];
158
163
  testID?: string;
159
164
  cancelsTouchesInView?: boolean;
160
165
  // TODO(TS) - fix event types
@@ -37,12 +37,8 @@ import { State } from '../../State';
37
37
  import { TouchEventType } from '../../TouchEventType';
38
38
  import { ComposedGesture } from './gestureComposition';
39
39
  import { ActionType } from '../../ActionType';
40
- import {
41
- isFabric,
42
- isJestEnv,
43
- REACT_NATIVE_VERSION,
44
- tagMessage,
45
- } from '../../utils';
40
+ import { isFabric, isJestEnv, tagMessage } from '../../utils';
41
+ import { getReactNativeVersion } from '../../getReactNativeVersion';
46
42
  import { getShadowNodeFromRef } from '../../getShadowNodeFromRef';
47
43
  import { Platform } from 'react-native';
48
44
  import type RNGestureHandlerModuleWeb from '../../RNGestureHandlerModule.web';
@@ -197,11 +193,17 @@ function attachHandlers({
197
193
  );
198
194
  }
199
195
 
196
+ let blocksHandlers: number[] = [];
197
+ if (handler.config.blocksHandlers) {
198
+ blocksHandlers = extractValidHandlerTags(handler.config.blocksHandlers);
199
+ }
200
+
200
201
  RNGestureHandlerModule.updateGestureHandler(
201
202
  handler.handlerTag,
202
203
  filterConfig(handler.config, ALLOWED_PROPS, {
203
204
  simultaneousHandlers: simultaneousWith,
204
205
  waitFor: requireToFail,
206
+ blocksHandlers: blocksHandlers,
205
207
  })
206
208
  );
207
209
  }
@@ -565,6 +567,7 @@ function validateDetectorChildren(ref: any) {
565
567
  // / \
566
568
  // NativeView NativeView
567
569
  if (__DEV__ && Platform.OS !== 'web') {
570
+ const REACT_NATIVE_VERSION = getReactNativeVersion();
568
571
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
569
572
  const wrapType =
570
573
  REACT_NATIVE_VERSION.minor > 63 || REACT_NATIVE_VERSION.major > 0
@@ -41,6 +41,7 @@ export interface BaseGestureConfig
41
41
  ref?: React.MutableRefObject<GestureType | undefined>;
42
42
  requireToFail?: GestureRef[];
43
43
  simultaneousWith?: GestureRef[];
44
+ blocksHandlers?: GestureRef[];
44
45
  needsPointerData?: boolean;
45
46
  manualActivation?: boolean;
46
47
  runOnJS?: boolean;
@@ -144,7 +145,7 @@ export abstract class BaseGesture<
144
145
  }
145
146
 
146
147
  private addDependency(
147
- key: 'simultaneousWith' | 'requireToFail',
148
+ key: 'simultaneousWith' | 'requireToFail' | 'blocksHandlers',
148
149
  gesture: Exclude<GestureRef, number>
149
150
  ) {
150
151
  const value = this.config[key];
@@ -275,6 +276,13 @@ export abstract class BaseGesture<
275
276
  return this;
276
277
  }
277
278
 
279
+ blocksExternalGesture(...gestures: Exclude<GestureRef, number>[]) {
280
+ for (const gesture of gestures) {
281
+ this.addDependency('blocksHandlers', gesture);
282
+ }
283
+ return this;
284
+ }
285
+
278
286
  withTestId(id: string) {
279
287
  this.config.testId = id;
280
288
  return this;
@@ -18,45 +18,47 @@ const warningMessage = tagMessage(
18
18
  const REANIMATED_AVAILABLE = Reanimated?.useSharedValue !== undefined;
19
19
  const setGestureState = Reanimated?.setGestureState;
20
20
 
21
+ function create(handlerTag: number): GestureStateManagerType {
22
+ 'worklet';
23
+ return {
24
+ begin: () => {
25
+ 'worklet';
26
+ if (REANIMATED_AVAILABLE) {
27
+ setGestureState(handlerTag, State.BEGAN);
28
+ } else {
29
+ console.warn(warningMessage);
30
+ }
31
+ },
32
+
33
+ activate: () => {
34
+ 'worklet';
35
+ if (REANIMATED_AVAILABLE) {
36
+ setGestureState(handlerTag, State.ACTIVE);
37
+ } else {
38
+ console.warn(warningMessage);
39
+ }
40
+ },
41
+
42
+ fail: () => {
43
+ 'worklet';
44
+ if (REANIMATED_AVAILABLE) {
45
+ setGestureState(handlerTag, State.FAILED);
46
+ } else {
47
+ console.warn(warningMessage);
48
+ }
49
+ },
50
+
51
+ end: () => {
52
+ 'worklet';
53
+ if (REANIMATED_AVAILABLE) {
54
+ setGestureState(handlerTag, State.END);
55
+ } else {
56
+ console.warn(warningMessage);
57
+ }
58
+ },
59
+ };
60
+ }
61
+
21
62
  export const GestureStateManager = {
22
- create(handlerTag: number): GestureStateManagerType {
23
- 'worklet';
24
- return {
25
- begin: () => {
26
- 'worklet';
27
- if (REANIMATED_AVAILABLE) {
28
- setGestureState(handlerTag, State.BEGAN);
29
- } else {
30
- console.warn(warningMessage);
31
- }
32
- },
33
-
34
- activate: () => {
35
- 'worklet';
36
- if (REANIMATED_AVAILABLE) {
37
- setGestureState(handlerTag, State.ACTIVE);
38
- } else {
39
- console.warn(warningMessage);
40
- }
41
- },
42
-
43
- fail: () => {
44
- 'worklet';
45
- if (REANIMATED_AVAILABLE) {
46
- setGestureState(handlerTag, State.FAILED);
47
- } else {
48
- console.warn(warningMessage);
49
- }
50
- },
51
-
52
- end: () => {
53
- 'worklet';
54
- if (REANIMATED_AVAILABLE) {
55
- setGestureState(handlerTag, State.END);
56
- } else {
57
- console.warn(warningMessage);
58
- }
59
- },
60
- };
61
- },
63
+ create,
62
64
  };
package/src/utils.ts CHANGED
@@ -1,11 +1,3 @@
1
- import pack from 'react-native/package.json';
2
-
3
- const [majorStr, minorStr] = pack.version.split('.');
4
- export const REACT_NATIVE_VERSION = {
5
- major: parseInt(majorStr, 10),
6
- minor: parseInt(minorStr, 10),
7
- };
8
-
9
1
  export function toArray<T>(object: T | T[]): T[] {
10
2
  if (!Array.isArray(object)) {
11
3
  return [object];
@@ -5,7 +5,7 @@ import { AdaptedEvent, Config } from '../interfaces';
5
5
  import GestureHandler from './GestureHandler';
6
6
 
7
7
  const DEFAULT_MAX_DURATION_MS = 800;
8
- const DEFAULT_MIN_ACCEPTABLE_DELTA = 160;
8
+ const DEFAULT_MIN_ACCEPTABLE_DELTA = 32;
9
9
  const DEFAULT_DIRECTION = Direction.RIGHT;
10
10
  const DEFAULT_NUMBER_OF_TOUCHES_REQUIRED = 1;
11
11
 
@@ -141,11 +141,11 @@ export default class FlingGestureHandler extends GestureHandler {
141
141
  }
142
142
 
143
143
  private onUp(event: AdaptedEvent): void {
144
- this.tracker.removeFromTracker(event.pointerId);
145
- if (this.currentState !== State.BEGAN) {
146
- return;
144
+ if (this.currentState === State.BEGAN) {
145
+ this.endFling();
147
146
  }
148
- this.endFling();
147
+
148
+ this.tracker.removeFromTracker(event.pointerId);
149
149
  }
150
150
 
151
151
  public activate(force?: boolean): void {
@@ -821,7 +821,7 @@ function invokeNullableMethod(
821
821
  return;
822
822
  }
823
823
 
824
- const { argMapping } = method.__nodeConfig;
824
+ const { argMapping }: { argMapping: unknown } = method.__nodeConfig;
825
825
  if (!Array.isArray(argMapping)) {
826
826
  return;
827
827
  }
@@ -32,6 +32,7 @@ export interface Config extends Record<string, ConfigArgs> {
32
32
  enabled?: boolean;
33
33
  simultaneousHandlers?: Handler[] | null;
34
34
  waitFor?: Handler[] | null;
35
+ blocksHandlers?: Handler[] | null;
35
36
  hitSlop?: HitSlop;
36
37
  shouldCancelWhenOutside?: boolean;
37
38
  userSelect?: UserSelect;
@@ -9,7 +9,6 @@ export default class GestureHandlerOrchestrator {
9
9
 
10
10
  private gestureHandlers: GestureHandler[] = [];
11
11
  private awaitingHandlers: GestureHandler[] = [];
12
- private handlersToCancel: GestureHandler[] = [];
13
12
 
14
13
  private handlingChangeSemaphore = 0;
15
14
  private activationIndex = 0;
@@ -34,7 +33,6 @@ export default class GestureHandlerOrchestrator {
34
33
  public removeHandlerFromOrchestrator(handler: GestureHandler): void {
35
34
  this.gestureHandlers.splice(this.gestureHandlers.indexOf(handler), 1);
36
35
  this.awaitingHandlers.splice(this.awaitingHandlers.indexOf(handler), 1);
37
- this.handlersToCancel.splice(this.handlersToCancel.indexOf(handler), 1);
38
36
  }
39
37
 
40
38
  private cleanupFinishedHandlers(): void {
@@ -177,17 +175,12 @@ export default class GestureHandlerOrchestrator {
177
175
  handler.setShouldResetProgress(true);
178
176
  handler.setActivationIndex(this.activationIndex++);
179
177
 
180
- this.gestureHandlers.forEach((otherHandler) => {
181
- // Order of arguments is correct - we check whether current handler should cancel existing handlers
182
-
183
- if (this.shouldHandlerBeCancelledBy(otherHandler, handler)) {
184
- this.handlersToCancel.push(otherHandler);
178
+ for (let i = this.gestureHandlers.length - 1; i >= 0; --i) {
179
+ if (this.shouldHandlerBeCancelledBy(this.gestureHandlers[i], handler)) {
180
+ this.gestureHandlers[i].cancel();
185
181
  }
186
- });
187
-
188
- for (let i = this.handlersToCancel.length - 1; i >= 0; --i) {
189
- this.handlersToCancel[i]?.cancel();
190
182
  }
183
+
191
184
  this.awaitingHandlers.forEach((otherHandler) => {
192
185
  if (this.shouldHandlerBeCancelledBy(otherHandler, handler)) {
193
186
  otherHandler?.cancel();
@@ -212,8 +205,6 @@ export default class GestureHandlerOrchestrator {
212
205
  }
213
206
  }
214
207
  }
215
-
216
- this.handlersToCancel = [];
217
208
  }
218
209
 
219
210
  private addAwaitingHandler(handler: GestureHandler): void {
@@ -5,6 +5,7 @@ export default class InteractionManager {
5
5
  private static instance: InteractionManager;
6
6
  private readonly waitForRelations: Map<number, number[]> = new Map();
7
7
  private readonly simultaneousRelations: Map<number, number[]> = new Map();
8
+ private readonly blocksHandlersRelations: Map<number, number[]> = new Map();
8
9
 
9
10
  // Private becaues of singleton
10
11
  // eslint-disable-next-line no-useless-constructor, @typescript-eslint/no-empty-function
@@ -40,6 +41,19 @@ export default class InteractionManager {
40
41
 
41
42
  this.simultaneousRelations.set(handler.getTag(), simultaneousHandlers);
42
43
  }
44
+
45
+ if (config.blocksHandlers) {
46
+ const blocksHandlers: number[] = [];
47
+ config.blocksHandlers.forEach((otherHandler: Handler): void => {
48
+ if (typeof otherHandler === 'number') {
49
+ blocksHandlers.push(otherHandler);
50
+ } else {
51
+ blocksHandlers.push(otherHandler.handlerTag);
52
+ }
53
+ });
54
+
55
+ this.blocksHandlersRelations.set(handler.getTag(), blocksHandlers);
56
+ }
43
57
  }
44
58
 
45
59
  public shouldWaitForHandlerFailure(
@@ -49,20 +63,12 @@ export default class InteractionManager {
49
63
  const waitFor: number[] | undefined = this.waitForRelations.get(
50
64
  handler.getTag()
51
65
  );
52
- if (!waitFor) {
53
- return false;
54
- }
55
-
56
- let shouldWait = false;
57
-
58
- waitFor.forEach((tag: number): void => {
59
- if (tag === otherHandler.getTag()) {
60
- shouldWait = true;
61
- return; //Returns from callback
62
- }
63
- });
64
66
 
65
- return shouldWait;
67
+ return (
68
+ waitFor?.find((tag: number) => {
69
+ return tag === otherHandler.getTag();
70
+ }) !== undefined
71
+ );
66
72
  }
67
73
 
68
74
  public shouldRecognizeSimultaneously(
@@ -71,28 +77,27 @@ export default class InteractionManager {
71
77
  ): boolean {
72
78
  const simultaneousHandlers: number[] | undefined =
73
79
  this.simultaneousRelations.get(handler.getTag());
74
- if (!simultaneousHandlers) {
75
- return false;
76
- }
77
-
78
- let shouldRecognizeSimultaneously = false;
79
80
 
80
- simultaneousHandlers.forEach((tag: number): void => {
81
- if (tag === otherHandler.getTag()) {
82
- shouldRecognizeSimultaneously = true;
83
- return;
84
- }
85
- });
86
-
87
- return shouldRecognizeSimultaneously;
81
+ return (
82
+ simultaneousHandlers?.find((tag: number) => {
83
+ return tag === otherHandler.getTag();
84
+ }) !== undefined
85
+ );
88
86
  }
89
87
 
90
88
  public shouldRequireHandlerToWaitForFailure(
91
- _handler: GestureHandler,
92
- _otherHandler: GestureHandler
89
+ handler: GestureHandler,
90
+ otherHandler: GestureHandler
93
91
  ): boolean {
94
- //TODO: Implement logic
95
- return false;
92
+ const waitFor: number[] | undefined = this.blocksHandlersRelations.get(
93
+ handler.getTag()
94
+ );
95
+
96
+ return (
97
+ waitFor?.find((tag: number) => {
98
+ return tag === otherHandler.getTag();
99
+ }) !== undefined
100
+ );
96
101
  }
97
102
 
98
103
  public shouldHandlerBeCancelledBy(
@@ -106,11 +111,13 @@ export default class InteractionManager {
106
111
  public dropRelationsForHandlerWithTag(handlerTag: number): void {
107
112
  this.waitForRelations.delete(handlerTag);
108
113
  this.simultaneousRelations.delete(handlerTag);
114
+ this.blocksHandlersRelations.delete(handlerTag);
109
115
  }
110
116
 
111
117
  public reset() {
112
118
  this.waitForRelations.clear();
113
119
  this.simultaneousRelations.clear();
120
+ this.blocksHandlersRelations.clear();
114
121
  }
115
122
 
116
123
  public static getInstance(): InteractionManager {