Skip to content
6 changes: 5 additions & 1 deletion packages/react-native-gesture-handler/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@ export { NativeDetector } from './v3/NativeDetector/NativeDetector';
export * from './v3/hooks/useGesture';
export * from './v3/hooks/relations';

export { SingleGestureName } from './v3/types';
export {
SingleGestureName,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is that needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SingleGestureName? I'm preety sure it is no longer needed after we added dedicated gesture hooks, am I correct cc @m-bert? I could remove it in this PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think it is no longer required. It was with useGesture but now it is only internal (but please make sure that it's true before removing it 😅)

SingleGestureType,
ComposedGesture as ComposedGestureType,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, what do you think about going in the other direction and exporting SingleGesture, LongPressGesture, ...?

That will conflict with the API v2, so we may want to rename those and keep that in mind for the migration guide.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that would be prefarable, and was my first choice, but I didn't want to conflict with v2 api. If you think it is Ok I will gladly change it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think we can rename the old types to something else to free up the "makes sense" names for the future. We would have to include that in the migration guide.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll just point out that we should write it somewhere in case we forget. Not sure if doing TODO comment` is the best, but but we could include it in the roadmap.

} from './v3/types';

export * from './v3/hooks/gestures';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
export type { TapGestureConfig } from './useTap';
export { useTap } from './useTap';
export { useTap, TapGestureType, TapGestureEvent } from './useTap';

export type { FlingGestureConfig } from './useFling';
export { useFling } from './useFling';
export { useFling, FlingGestureType, FlingGestureEvent } from './useFling';

export type { LongPressGestureConfig } from './useLongPress';
export { useLongPress } from './useLongPress';
export {
useLongPress,
LongPressGestureType,
LongPressGestureEvent,
} from './useLongPress';

export type { PinchGestureConfig } from './usePinch';
export { usePinch } from './usePinch';
export { usePinch, PinchGestureType, PinchGestureEvent } from './usePinch';

export type { RotationGestureConfig } from './useRotation';
export { useRotation } from './useRotation';
export {
useRotation,
RotationGestureType,
RotationGestureEvent,
} from './useRotation';

export type { HoverGestureConfig } from './useHover';
export { useHover } from './useHover';
export { useHover, HoverGestureType, HoverGestureEvent } from './useHover';

export type { ManualGestureConfig } from './useManual';
export { useManual } from './useManual';
export { useManual, ManualGestureType, ManualGestureEvent } from './useManual';

export type { NativeViewGestureConfig } from './useNative';
export { useNative } from './useNative';
export { useNative, NativeGestureType, NativeGestureEvent } from './useNative';

export type { PanGestureConfig } from './usePan';
export { usePan } from './usePan';
export { usePan, PanGestureType, PanGestureEvent } from './usePan';
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {
BaseGestureConfig,
ExcludeInternalConfigProps,
GestureEvents,
SingleGesture,
SingleGestureName,
} from '../../types';
import { useGesture } from '../useGesture';
Expand Down Expand Up @@ -51,3 +53,9 @@ export function useFling(config: FlingGestureConfig) {

return useGesture(SingleGestureName.Fling, flingConfig);
}

export type FlingGestureEvent = GestureEvents<FlingHandlerData>;
export type FlingGestureType = SingleGesture<
FlingHandlerData,
FlingGestureProperties
>;
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { HoverEffect } from '../../../handlers/gestures/hoverGesture';
import {
BaseGestureConfig,
ExcludeInternalConfigProps,
GestureEvents,
SingleGesture,
SingleGestureName,
} from '../../types';
import { useGesture } from '../useGesture';
Expand Down Expand Up @@ -44,3 +46,9 @@ export function useHover(config: HoverGestureConfig) {

return useGesture(SingleGestureName.Hover, hoverConfig);
}

export type HoverGestureEvent = GestureEvents<HoverHandlerData>;
export type HoverGestureType = SingleGesture<
HoverHandlerData,
HoverGestureProperties
>;
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {
BaseGestureConfig,
ExcludeInternalConfigProps,
GestureEvents,
SingleGesture,
SingleGestureName,
} from '../../types';
import { useGesture } from '../useGesture';
Expand Down Expand Up @@ -78,3 +80,9 @@ export function useLongPress(config: LongPressGestureConfig) {
longPressConfig
);
}

export type LongPressGestureEvent = GestureEvents<LongPressHandlerData>;
export type LongPressGestureType = SingleGesture<
LongPressHandlerData,
LongPressGestureProperties
>;
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {
BaseGestureConfig,
ExcludeInternalConfigProps,
GestureEvents,
SingleGesture,
SingleGestureName,
} from '../../types';
import { useGesture } from '../useGesture';
Expand All @@ -24,3 +26,9 @@ export function useManual(config: ManualGestureConfig) {

return useGesture(SingleGestureName.Manual, manualConfig);
}

export type ManualGestureEvent = GestureEvents<ManualHandlerData>;
export type ManualGestureType = SingleGesture<
ManualHandlerData,
ManualGestureProperties
>;
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {
BaseGestureConfig,
ExcludeInternalConfigProps,
GestureEvents,
SingleGesture,
SingleGestureName,
} from '../../types';
import { useGesture } from '../useGesture';
Expand Down Expand Up @@ -42,3 +44,9 @@ export function useNative(config: NativeViewGestureConfig) {

return useGesture(SingleGestureName.Native, nativeConfig);
}

export type NativeGestureEvent = GestureEvents<NativeViewHandlerData>;
export type NativeGestureType = SingleGesture<
NativeViewHandlerData,
NativeViewGestureProperties
>;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { StylusData } from '../../../handlers/gestureHandlerCommon';
import {
BaseGestureConfig,
ExcludeInternalConfigProps,
GestureEvents,
SingleGesture,
SingleGestureName,
} from '../../types';
import { useGesture } from '../useGesture';
Expand Down Expand Up @@ -257,3 +259,9 @@ export function usePan(config: PanGestureConfig) {
panConfig
);
}

export type PanGestureEvent = GestureEvents<PanHandlerData>;
export type PanGestureType = SingleGesture<
PanHandlerData,
PanGestureProperties
>;
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {
BaseGestureConfig,
ExcludeInternalConfigProps,
GestureEvents,
SingleGesture,
SingleGestureName,
} from '../../types';
import { useGesture } from '../useGesture';
Expand Down Expand Up @@ -30,3 +32,9 @@ export function usePinch(config: PinchGestureConfig) {

return useGesture(SingleGestureName.Pinch, pinchConfig);
}

export type PinchGestureEvent = GestureEvents<PinchHandlerData>;
export type PinchGestureType = SingleGesture<
PinchHandlerData,
PinchGestureProperties
>;
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {
BaseGestureConfig,
ExcludeInternalConfigProps,
GestureEvents,
SingleGesture,
SingleGestureName,
} from '../../types';
import { useGesture } from '../useGesture';
Expand Down Expand Up @@ -31,3 +33,9 @@ export function useRotation(config: RotationGestureConfig) {

return useGesture(SingleGestureName.Rotation, rotationConfig);
}

export type RotationGestureEvent = GestureEvents<RotationHandlerData>;
export type RotationGestureType = SingleGesture<
RotationHandlerData,
RotationGestureProperties
>;
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {
BaseGestureConfig,
ExcludeInternalConfigProps,
GestureEvents,
SingleGesture,
SingleGestureName,
} from '../../types';
import { useGesture } from '../useGesture';
Expand Down Expand Up @@ -107,3 +109,9 @@ export function useTap(config: TapGestureConfig) {
tapConfig
);
}

export type TapGestureEvent = GestureEvents<TapHandlerData>;
export type TapGestureType = SingleGesture<
TapHandlerData,
TapGestureProperties
>;
2 changes: 2 additions & 0 deletions packages/react-native-gesture-handler/src/v3/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ export type SingleGesture<THandlerData, TConfig> = {
gestureRelations: GestureRelations;
};

export type SingleGestureType = SingleGesture<unknown, unknown>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about a union: TapGestureType | PanGestureType | ...

It would have to be defined elsewhere, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea, done in 43bd77d


export type ComposedGesture = {
tags: number[];
type: ComposedGestureName;
Expand Down
Loading