react-native-gesture-handler 2.14.0 → 2.15.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -0
- package/RNGestureHandler.podspec +2 -2
- package/android/paper/src/main/java/com/swmansion/gesturehandler/NativeRNGestureHandlerModuleSpec.java +55 -0
- package/android/src/main/java/com/swmansion/gesturehandler/RNGestureHandlerPackage.kt +64 -4
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +12 -2
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +53 -19
- package/{ios → apple}/Handlers/RNFlingHandler.m +25 -5
- package/{ios → apple}/Handlers/RNForceTouchHandler.m +25 -7
- package/{ios → apple}/Handlers/RNHoverHandler.m +26 -1
- package/{ios → apple}/Handlers/RNLongPressHandler.m +24 -4
- package/{ios → apple}/Handlers/RNManualHandler.m +24 -4
- package/{ios → apple}/Handlers/RNNativeViewHandler.mm +42 -6
- package/{ios → apple}/Handlers/RNPanHandler.m +100 -15
- package/apple/Handlers/RNPinchHandler.m +162 -0
- package/{ios → apple}/Handlers/RNRotationHandler.m +71 -9
- package/{ios → apple}/Handlers/RNTapHandler.m +96 -26
- package/apple/RNGHUIKit.h +27 -0
- package/{ios → apple}/RNGestureHandler.h +3 -3
- package/{ios → apple}/RNGestureHandler.m +31 -5
- package/{ios → apple}/RNGestureHandlerButton.h +4 -1
- package/{ios → apple}/RNGestureHandlerButton.m +12 -4
- package/{ios → apple}/RNGestureHandlerButtonManager.m +4 -2
- package/{ios → apple}/RNGestureHandlerEvents.h +1 -1
- package/{ios → apple}/RNGestureHandlerManager.h +2 -2
- package/{ios → apple}/RNGestureHandlerManager.mm +46 -11
- package/apple/RNGestureHandlerModule.h +17 -0
- package/{ios → apple}/RNGestureHandlerModule.mm +46 -60
- package/{ios → apple}/RNGestureHandlerPointerTracker.h +5 -5
- package/{ios → apple}/RNGestureHandlerPointerTracker.m +19 -14
- package/{ios → apple}/RNGestureHandlerRegistry.h +1 -1
- package/{ios → apple}/RNGestureHandlerRegistry.m +1 -1
- package/{ios → apple}/RNManualActivationRecognizer.h +8 -0
- package/{ios → apple}/RNManualActivationRecognizer.m +27 -7
- package/{ios → apple}/RNRootViewGestureRecognizer.m +72 -4
- package/lib/commonjs/RNGestureHandlerModule.js +5 -18
- package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
- package/lib/commonjs/RNGestureHandlerModule.windows.js +10 -102
- package/lib/commonjs/RNGestureHandlerModule.windows.js.map +1 -1
- package/lib/commonjs/components/DrawerLayout.js +2 -0
- package/lib/commonjs/components/DrawerLayout.js.map +1 -1
- package/lib/commonjs/components/gestureHandlerRootHOC.js.map +1 -1
- package/lib/commonjs/components/touchables/TouchableWithoutFeedback.js.map +1 -1
- package/lib/commonjs/handlers/gestureHandlerCommon.js +1 -1
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector.js +11 -1
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gesture.js +5 -0
- package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gestureStateManager.js +39 -37
- package/lib/commonjs/handlers/gestures/gestureStateManager.js.map +1 -1
- package/lib/commonjs/index.js +8 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/NativeRNGestureHandlerModule.js +13 -0
- package/lib/commonjs/specs/NativeRNGestureHandlerModule.js.map +1 -0
- package/lib/commonjs/web/handlers/FlingGestureHandler.js +8 -6
- package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/GestureHandler.js +13 -1
- package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/LongPressGestureHandler.js +8 -6
- package/lib/commonjs/web/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PanGestureHandler.js +4 -0
- package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/TapGestureHandler.js +4 -0
- package/lib/commonjs/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/commonjs/web/interfaces.js +12 -14
- package/lib/commonjs/web/interfaces.js.map +1 -1
- package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js +35 -0
- package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js.map +1 -1
- package/lib/commonjs/web/tools/NodeManager.js +3 -2
- package/lib/commonjs/web/tools/NodeManager.js.map +1 -1
- package/lib/commonjs/web/tools/PointerEventManager.js +16 -6
- package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
- package/lib/commonjs/web/tools/TouchEventManager.js +0 -1
- package/lib/commonjs/web/tools/TouchEventManager.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.js +4 -18
- package/lib/module/RNGestureHandlerModule.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.windows.js +10 -81
- package/lib/module/RNGestureHandlerModule.windows.js.map +1 -1
- package/lib/module/components/DrawerLayout.js +2 -0
- package/lib/module/components/DrawerLayout.js.map +1 -1
- package/lib/module/components/gestureHandlerRootHOC.js.map +1 -1
- package/lib/module/components/touchables/TouchableWithoutFeedback.js.map +1 -1
- package/lib/module/handlers/gestureHandlerCommon.js +1 -1
- package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector.js +11 -1
- package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/module/handlers/gestures/gesture.js +5 -0
- package/lib/module/handlers/gestures/gesture.js.map +1 -1
- package/lib/module/handlers/gestures/gestureStateManager.js +44 -42
- package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/NativeRNGestureHandlerModule.js +3 -0
- package/lib/module/specs/NativeRNGestureHandlerModule.js.map +1 -0
- package/lib/module/web/handlers/FlingGestureHandler.js +8 -6
- package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/GestureHandler.js +14 -2
- package/lib/module/web/handlers/GestureHandler.js.map +1 -1
- package/lib/module/web/handlers/LongPressGestureHandler.js +8 -5
- package/lib/module/web/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PanGestureHandler.js +4 -0
- package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/TapGestureHandler.js +4 -0
- package/lib/module/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/module/web/interfaces.js +9 -11
- package/lib/module/web/interfaces.js.map +1 -1
- package/lib/module/web/tools/GestureHandlerWebDelegate.js +34 -0
- package/lib/module/web/tools/GestureHandlerWebDelegate.js.map +1 -1
- package/lib/module/web/tools/NodeManager.js +3 -2
- package/lib/module/web/tools/NodeManager.js.map +1 -1
- package/lib/module/web/tools/PointerEventManager.js +16 -7
- package/lib/module/web/tools/PointerEventManager.js.map +1 -1
- package/lib/module/web/tools/TouchEventManager.js +1 -2
- package/lib/module/web/tools/TouchEventManager.js.map +1 -1
- package/lib/typescript/RNGestureHandlerModule.d.ts +2 -13
- package/lib/typescript/RNGestureHandlerModule.windows.d.ts +5 -21
- package/lib/typescript/components/DrawerLayout.d.ts +11 -0
- package/lib/typescript/components/gestureHandlerRootHOC.d.ts +1 -1
- package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts +1 -1
- package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +1 -1
- package/lib/typescript/handlers/PanGestureHandler.d.ts +1 -1
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +4 -1
- package/lib/typescript/handlers/gestures/GestureDetector.d.ts +2 -1
- package/lib/typescript/handlers/gestures/gesture.d.ts +2 -0
- package/lib/typescript/handlers/gestures/gestureStateManager.d.ts +3 -1
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts +14 -0
- package/lib/typescript/web/handlers/GestureHandler.d.ts +3 -1
- package/lib/typescript/web/interfaces.d.ts +9 -9
- package/lib/typescript/web/tools/GestureHandlerDelegate.d.ts +2 -0
- package/lib/typescript/web/tools/GestureHandlerWebDelegate.d.ts +7 -0
- package/lib/typescript/web/tools/PointerEventManager.d.ts +2 -0
- package/package.json +14 -11
- package/src/RNGestureHandlerModule.ts +4 -49
- package/src/RNGestureHandlerModule.windows.ts +18 -100
- package/src/components/DrawerLayout.tsx +15 -0
- package/src/components/gestureHandlerRootHOC.tsx +1 -3
- package/src/components/touchables/TouchableWithoutFeedback.tsx +3 -3
- package/src/handlers/gestureHandlerCommon.ts +5 -0
- package/src/handlers/gestures/GestureDetector.tsx +16 -2
- package/src/handlers/gestures/gesture.ts +6 -0
- package/src/handlers/gestures/gestureStateManager.ts +42 -40
- package/src/index.ts +1 -0
- package/src/specs/NativeRNGestureHandlerModule.ts +26 -0
- package/src/web/handlers/FlingGestureHandler.ts +9 -5
- package/src/web/handlers/GestureHandler.ts +17 -0
- package/src/web/handlers/LongPressGestureHandler.ts +8 -5
- package/src/web/handlers/PanGestureHandler.ts +4 -0
- package/src/web/handlers/TapGestureHandler.ts +4 -0
- package/src/web/interfaces.ts +10 -10
- package/src/web/tools/GestureHandlerDelegate.ts +3 -0
- package/src/web/tools/GestureHandlerWebDelegate.ts +39 -0
- package/src/web/tools/NodeManager.ts +5 -1
- package/src/web/tools/PointerEventManager.ts +23 -5
- package/src/web/tools/TouchEventManager.ts +0 -2
- package/ios/Handlers/RNPinchHandler.m +0 -95
- package/ios/RNGestureHandlerModule.h +0 -7
- package/lib/commonjs/RNGestureHandlerModule.macos.js +0 -149
- package/lib/commonjs/RNGestureHandlerModule.macos.js.map +0 -1
- package/lib/module/RNGestureHandlerModule.macos.js +0 -110
- package/lib/module/RNGestureHandlerModule.macos.js.map +0 -1
- package/lib/typescript/RNGestureHandlerModule.macos.d.ts +0 -47
- package/src/RNGestureHandlerModule.macos.ts +0 -133
- /package/{ios → apple}/Handlers/RNFlingHandler.h +0 -0
- /package/{ios → apple}/Handlers/RNForceTouchHandler.h +0 -0
- /package/{ios → apple}/Handlers/RNHoverHandler.h +0 -0
- /package/{ios → apple}/Handlers/RNLongPressHandler.h +0 -0
- /package/{ios → apple}/Handlers/RNManualHandler.h +0 -0
- /package/{ios → apple}/Handlers/RNNativeViewHandler.h +0 -0
- /package/{ios → apple}/Handlers/RNPanHandler.h +0 -0
- /package/{ios → apple}/Handlers/RNPinchHandler.h +0 -0
- /package/{ios → apple}/Handlers/RNRotationHandler.h +0 -0
- /package/{ios → apple}/Handlers/RNTapHandler.h +0 -0
- /package/{ios → apple}/RNGHTouchEventType.h +0 -0
- /package/{ios → apple}/RNGestureHandler.xcodeproj/project.pbxproj +0 -0
- /package/{ios → apple}/RNGestureHandler.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -0
- /package/{ios → apple}/RNGestureHandlerActionType.h +0 -0
- /package/{ios → apple}/RNGestureHandlerButtonComponentView.h +0 -0
- /package/{ios → apple}/RNGestureHandlerButtonComponentView.mm +0 -0
- /package/{ios → apple}/RNGestureHandlerButtonManager.h +0 -0
- /package/{ios → apple}/RNGestureHandlerDirection.h +0 -0
- /package/{ios → apple}/RNGestureHandlerEvents.m +0 -0
- /package/{ios → apple}/RNGestureHandlerRootViewComponentView.mm +0 -0
- /package/{ios → apple}/RNGestureHandlerState.h +0 -0
- /package/{ios → apple}/RNGestureHandlerStateManager.h +0 -0
- /package/{ios → apple}/RNRootViewGestureRecognizer.h +0 -0
@@ -12,8 +12,9 @@ export type GestureConfigReference = {
|
|
12
12
|
};
|
13
13
|
interface GestureDetectorProps {
|
14
14
|
gesture: ComposedGesture | GestureType;
|
15
|
-
userSelect?: UserSelect;
|
16
15
|
children?: React.ReactNode;
|
16
|
+
userSelect?: UserSelect;
|
17
|
+
enableContextMenu?: boolean;
|
17
18
|
}
|
18
19
|
export declare const GestureDetector: (props: GestureDetectorProps) => React.JSX.Element;
|
19
20
|
export {};
|
@@ -8,6 +8,7 @@ import { PinchGestureHandlerEventPayload } from '../PinchGestureHandler';
|
|
8
8
|
import { RotationGestureHandlerEventPayload } from '../RotationGestureHandler';
|
9
9
|
import { TapGestureHandlerEventPayload } from '../TapGestureHandler';
|
10
10
|
import { NativeViewGestureHandlerPayload } from '../NativeViewGestureHandler';
|
11
|
+
import { MouseButton } from '../../web/interfaces';
|
11
12
|
export type GestureType = BaseGesture<Record<string, unknown>> | BaseGesture<Record<string, never>> | BaseGesture<TapGestureHandlerEventPayload> | BaseGesture<PanGestureHandlerEventPayload> | BaseGesture<LongPressGestureHandlerEventPayload> | BaseGesture<RotationGestureHandlerEventPayload> | BaseGesture<PinchGestureHandlerEventPayload> | BaseGesture<FlingGestureHandlerEventPayload> | BaseGesture<ForceTouchGestureHandlerEventPayload> | BaseGesture<NativeViewGestureHandlerPayload>;
|
12
13
|
export type GestureRef = number | GestureType | React.RefObject<GestureType | undefined> | React.RefObject<React.ComponentType | undefined>;
|
13
14
|
export interface BaseGestureConfig extends CommonGestureConfig, Record<string, unknown> {
|
@@ -91,6 +92,7 @@ export declare abstract class BaseGesture<EventPayloadT extends Record<string, u
|
|
91
92
|
shouldCancelWhenOutside(value: boolean): this;
|
92
93
|
hitSlop(hitSlop: HitSlop): this;
|
93
94
|
activeCursor(activeCursor: ActiveCursor): this;
|
95
|
+
mouseButton(mouseButton: MouseButton): this;
|
94
96
|
runOnJS(runOnJS: boolean): this;
|
95
97
|
simultaneousWithExternalGesture(...gestures: Exclude<GestureRef, number>[]): this;
|
96
98
|
requireExternalGestureToFail(...gestures: Exclude<GestureRef, number>[]): this;
|
@@ -4,6 +4,8 @@ export interface GestureStateManagerType {
|
|
4
4
|
fail: () => void;
|
5
5
|
end: () => void;
|
6
6
|
}
|
7
|
+
declare function create(handlerTag: number): GestureStateManagerType;
|
7
8
|
export declare const GestureStateManager: {
|
8
|
-
create
|
9
|
+
create: typeof create;
|
9
10
|
};
|
11
|
+
export {};
|
@@ -1,5 +1,6 @@
|
|
1
1
|
export { Directions } from './Directions';
|
2
2
|
export { State } from './State';
|
3
|
+
export { MouseButton } from './web/interfaces';
|
3
4
|
export { default as gestureHandlerRootHOC } from './components/gestureHandlerRootHOC';
|
4
5
|
export { default as GestureHandlerRootView } from './components/GestureHandlerRootView';
|
5
6
|
export type { GestureEvent, HandlerStateChangeEvent, GestureEventPayload, HandlerStateChangeEventPayload, GestureTouchEvent, TouchData, GestureUpdateEvent, GestureStateChangeEvent, } from './handlers/gestureHandlerCommon';
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { TurboModule } from 'react-native';
|
2
|
+
import { Int32 } from 'react-native/Libraries/Types/CodegenTypes';
|
3
|
+
export interface Spec extends TurboModule {
|
4
|
+
handleSetJSResponder: (tag: Int32, blockNativeResponder: boolean) => void;
|
5
|
+
handleClearJSResponder: () => void;
|
6
|
+
createGestureHandler: (handlerName: string, handlerTag: Int32, config: Object) => void;
|
7
|
+
attachGestureHandler: (handlerTag: Int32, newView: Int32, actionType: Int32) => void;
|
8
|
+
updateGestureHandler: (handlerTag: Int32, newConfig: Object) => void;
|
9
|
+
dropGestureHandler: (handlerTag: Int32) => void;
|
10
|
+
install: () => boolean;
|
11
|
+
flushOperations: () => void;
|
12
|
+
}
|
13
|
+
declare const _default: Spec;
|
14
|
+
export default _default;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { State } from '../../State';
|
2
|
-
import { Config, AdaptedEvent, PointerType } from '../interfaces';
|
2
|
+
import { Config, AdaptedEvent, PointerType, MouseButton } from '../interfaces';
|
3
3
|
import EventManager from '../tools/EventManager';
|
4
4
|
import PointerTracker from '../tools/PointerTracker';
|
5
5
|
import { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate';
|
@@ -74,7 +74,9 @@ export default abstract class GestureHandler {
|
|
74
74
|
protected checkCustomActivationCriteria(criterias: string[]): void;
|
75
75
|
private validateHitSlops;
|
76
76
|
private checkHitSlop;
|
77
|
+
isButtonInConfig(mouseButton: MouseButton | undefined): number | true | undefined;
|
77
78
|
protected resetConfig(): void;
|
79
|
+
onDestroy(): void;
|
78
80
|
getTag(): number;
|
79
81
|
setTag(tag: number): void;
|
80
82
|
getConfig(): Config;
|
@@ -24,6 +24,8 @@ export interface Config extends Record<string, ConfigArgs> {
|
|
24
24
|
shouldCancelWhenOutside?: boolean;
|
25
25
|
userSelect?: UserSelect;
|
26
26
|
activeCursor?: ActiveCursor;
|
27
|
+
mouseButton?: MouseButton;
|
28
|
+
enableContextMenu?: boolean;
|
27
29
|
activateAfterLongPress?: number;
|
28
30
|
failOffsetXStart?: number;
|
29
31
|
failOffsetYStart?: number;
|
@@ -99,21 +101,19 @@ export interface AdaptedEvent {
|
|
99
101
|
pointerId: number;
|
100
102
|
eventType: EventTypes;
|
101
103
|
pointerType: PointerType;
|
102
|
-
buttons: number;
|
103
104
|
time: number;
|
105
|
+
button?: MouseButton;
|
104
106
|
allTouches?: TouchList;
|
105
107
|
changedTouches?: TouchList;
|
106
108
|
touchEventType?: TouchEventType;
|
107
109
|
}
|
108
|
-
export declare enum
|
109
|
-
NONE = 0,
|
110
|
+
export declare enum MouseButton {
|
110
111
|
LEFT = 1,
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
SCROLL_LEFT_RIGHT = 7
|
112
|
+
MIDDLE = 2,
|
113
|
+
RIGHT = 4,
|
114
|
+
BUTTON_4 = 8,
|
115
|
+
BUTTON_5 = 16,
|
116
|
+
ALL = 31
|
117
117
|
}
|
118
118
|
export declare enum EventTypes {
|
119
119
|
DOWN = 0,
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import type GestureHandler from '../handlers/GestureHandler';
|
2
|
+
import { Config } from '../interfaces';
|
2
3
|
export interface MeasureResult {
|
3
4
|
pageX: number;
|
4
5
|
pageY: number;
|
@@ -19,4 +20,5 @@ export interface GestureHandlerDelegate<T> {
|
|
19
20
|
onEnd(): void;
|
20
21
|
onCancel(): void;
|
21
22
|
onFail(): void;
|
23
|
+
destroy(config: Config): void;
|
22
24
|
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import type GestureHandler from '../handlers/GestureHandler';
|
2
2
|
import { GestureHandlerDelegate, MeasureResult } from './GestureHandlerDelegate';
|
3
|
+
import { Config } from '../interfaces';
|
3
4
|
export declare class GestureHandlerWebDelegate implements GestureHandlerDelegate<HTMLElement> {
|
4
5
|
private view;
|
5
6
|
private gestureHandler;
|
@@ -13,9 +14,15 @@ export declare class GestureHandlerWebDelegate implements GestureHandlerDelegate
|
|
13
14
|
measureView(): MeasureResult;
|
14
15
|
reset(): void;
|
15
16
|
tryResetCursor(): void;
|
17
|
+
private shouldDisableContextMenu;
|
18
|
+
private addContextMenuListeners;
|
19
|
+
private removeContextMenuListeners;
|
20
|
+
private disableContextMenu;
|
21
|
+
private enableContextMenu;
|
16
22
|
onBegin(): void;
|
17
23
|
onActivate(): void;
|
18
24
|
onEnd(): void;
|
19
25
|
onCancel(): void;
|
20
26
|
onFail(): void;
|
27
|
+
destroy(config: Config): void;
|
21
28
|
}
|
@@ -2,6 +2,8 @@ import { AdaptedEvent, EventTypes } from '../interfaces';
|
|
2
2
|
import EventManager from './EventManager';
|
3
3
|
export default class PointerEventManager extends EventManager<HTMLElement> {
|
4
4
|
private trackedPointers;
|
5
|
+
private readonly mouseButtonsMapper;
|
6
|
+
constructor(view: HTMLElement);
|
5
7
|
setListeners(): void;
|
6
8
|
protected mapEvent(event: PointerEvent, eventType: EventTypes): AdaptedEvent;
|
7
9
|
resetManager(): void;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-native-gesture-handler",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.15.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 && husky install",
|
@@ -9,10 +9,10 @@
|
|
9
9
|
"precommit": "lint-staged",
|
10
10
|
"release": "npm login && release-it",
|
11
11
|
"ts-check": "yarn tsc --noEmit",
|
12
|
-
"format:js": "prettier --write --list-different './{src,example,FabricExample}/**/*.{js,jsx,ts,tsx}'",
|
12
|
+
"format:js": "prettier --write --list-different './{src,example,FabricExample,MacOSExample}/**/*.{js,jsx,ts,tsx}'",
|
13
13
|
"format:android": "node ./scripts/format-android.js",
|
14
|
-
"format:ios": "find
|
15
|
-
"lint:js": "eslint --ext '.js,.ts,.tsx' src/ example/src FabricExample/src && yarn prettier --check './{src,example,FabricExample}/**/*.{js,jsx,ts,tsx}'",
|
14
|
+
"format:ios": "find apple/ -iname *.h -o -iname *.m -o -iname *.cpp -o -iname *.mm | xargs clang-format -i",
|
15
|
+
"lint:js": "eslint --ext '.js,.ts,.tsx' src/ example/src FabricExample/src MacOSExample/src && yarn prettier --check './{src,example,FabricExample,MacOSExample}/**/*.{js,jsx,ts,tsx}'",
|
16
16
|
"lint:js-root": "eslint --ext '.js,.ts,.tsx' src/ && yarn prettier --check './src/**/*.{js,jsx,ts,tsx}'",
|
17
17
|
"lint:android": "./android/gradlew -p android spotlessCheck -q"
|
18
18
|
},
|
@@ -36,7 +36,7 @@
|
|
36
36
|
"android/common/src/main/java/",
|
37
37
|
"android/reanimated/src/main/java/",
|
38
38
|
"android/noreanimated/src/main/java/",
|
39
|
-
"
|
39
|
+
"apple/",
|
40
40
|
"Swipeable/",
|
41
41
|
"jest-utils/",
|
42
42
|
"DrawerLayout/",
|
@@ -77,7 +77,7 @@
|
|
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.
|
80
|
+
"@react-native/babel-preset": "^0.73.19",
|
81
81
|
"@testing-library/jest-native": "^4.0.4",
|
82
82
|
"@testing-library/react-native": "^9.0.0",
|
83
83
|
"@types/hammerjs": "^2.0.38",
|
@@ -101,7 +101,7 @@
|
|
101
101
|
"prettier": "^2.7.1",
|
102
102
|
"react": "18.2.0",
|
103
103
|
"react-dom": "^16.12.0",
|
104
|
-
"react-native": "0.73.
|
104
|
+
"react-native": "0.73.2",
|
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",
|
@@ -114,9 +114,9 @@
|
|
114
114
|
"react-native": "*"
|
115
115
|
},
|
116
116
|
"lint-staged": {
|
117
|
-
"./{src,example,FabricExample}/**/*.{ts,tsx}": "yarn format:js",
|
117
|
+
"./{src,example,FabricExample,MacOSExample}/**/*.{ts,tsx}": "yarn format:js",
|
118
118
|
"android/**/*.kt": "yarn format:android",
|
119
|
-
"
|
119
|
+
"apple/**/*.{h,m,mm,cpp}": "yarn format:ios"
|
120
120
|
},
|
121
121
|
"release-it": {
|
122
122
|
"hooks": {
|
@@ -146,7 +146,10 @@
|
|
146
146
|
],
|
147
147
|
"codegenConfig": {
|
148
148
|
"name": "rngesturehandler_codegen",
|
149
|
-
"type": "
|
150
|
-
"jsSrcsDir": "./src/specs"
|
149
|
+
"type": "all",
|
150
|
+
"jsSrcsDir": "./src/specs",
|
151
|
+
"android": {
|
152
|
+
"javaPackageName": "com.swmansion.gesturehandler"
|
153
|
+
}
|
151
154
|
}
|
152
155
|
}
|
@@ -1,50 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
import { tagMessage } from './utils';
|
4
|
-
const { RNGestureHandlerModule } = NativeModules;
|
1
|
+
// Reexport the native module spec used by codegen. The relevant files are inluded on Android
|
2
|
+
// to ensure the compatibility with the old arch, while iOS doesn't require those at all.
|
5
3
|
|
6
|
-
|
7
|
-
|
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 ..).
|
10
|
-
|
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
|
-
)
|
16
|
-
);
|
17
|
-
}
|
18
|
-
|
19
|
-
if (
|
20
|
-
RNGestureHandlerModule &&
|
21
|
-
RNGestureHandlerModule.flushOperations === undefined
|
22
|
-
) {
|
23
|
-
RNGestureHandlerModule.flushOperations = () => {
|
24
|
-
// NO-OP if not defined
|
25
|
-
};
|
26
|
-
}
|
27
|
-
|
28
|
-
export type RNGestureHandlerModuleProps = {
|
29
|
-
handleSetJSResponder: (tag: number, blockNativeResponder: boolean) => void;
|
30
|
-
handleClearJSResponder: () => void;
|
31
|
-
createGestureHandler: (
|
32
|
-
handlerName: string,
|
33
|
-
handlerTag: number,
|
34
|
-
config: Readonly<Record<string, unknown>>
|
35
|
-
) => void;
|
36
|
-
attachGestureHandler: (
|
37
|
-
handlerTag: number,
|
38
|
-
newView: number,
|
39
|
-
actionType: ActionType
|
40
|
-
) => void;
|
41
|
-
updateGestureHandler: (
|
42
|
-
handlerTag: number,
|
43
|
-
newConfig: Readonly<Record<string, unknown>>
|
44
|
-
) => void;
|
45
|
-
dropGestureHandler: (handlerTag: number) => void;
|
46
|
-
install: () => void;
|
47
|
-
flushOperations: () => void;
|
48
|
-
};
|
49
|
-
|
50
|
-
export default RNGestureHandlerModule as RNGestureHandlerModuleProps;
|
4
|
+
import Module from './specs/NativeRNGestureHandlerModule';
|
5
|
+
export default Module;
|
@@ -1,11 +1,8 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
|
3
3
|
import { ActionType } from './ActionType';
|
4
|
-
import { isNewWebImplementationEnabled } from './EnableNewWebImplementation';
|
5
4
|
|
6
|
-
//GestureHandlers
|
7
|
-
import InteractionManager from './web/tools/InteractionManager';
|
8
|
-
import NodeManager from './web/tools/NodeManager';
|
5
|
+
// GestureHandlers
|
9
6
|
import PanGestureHandler from './web/handlers/PanGestureHandler';
|
10
7
|
import TapGestureHandler from './web/handlers/TapGestureHandler';
|
11
8
|
import LongPressGestureHandler from './web/handlers/LongPressGestureHandler';
|
@@ -14,18 +11,7 @@ import RotationGestureHandler from './web/handlers/RotationGestureHandler';
|
|
14
11
|
import FlingGestureHandler from './web/handlers/FlingGestureHandler';
|
15
12
|
import NativeViewGestureHandler from './web/handlers/NativeViewGestureHandler';
|
16
13
|
import ManualGestureHandler from './web/handlers/ManualGestureHandler';
|
17
|
-
|
18
|
-
//Hammer Handlers
|
19
|
-
import * as HammerNodeManager from './web_hammer/NodeManager';
|
20
|
-
import HammerNativeViewGestureHandler from './web_hammer/NativeViewGestureHandler';
|
21
|
-
import HammerPanGestureHandler from './web_hammer/PanGestureHandler';
|
22
|
-
import HammerTapGestureHandler from './web_hammer/TapGestureHandler';
|
23
|
-
import HammerLongPressGestureHandler from './web_hammer/LongPressGestureHandler';
|
24
|
-
import HammerPinchGestureHandler from './web_hammer/PinchGestureHandler';
|
25
|
-
import HammerRotationGestureHandler from './web_hammer/RotationGestureHandler';
|
26
|
-
import HammerFlingGestureHandler from './web_hammer/FlingGestureHandler';
|
27
14
|
import { Config } from './web/interfaces';
|
28
|
-
import { GestureHandlerWebDelegate } from './web/tools/GestureHandlerWebDelegate';
|
29
15
|
|
30
16
|
export const Gestures = {
|
31
17
|
NativeViewGestureHandler,
|
@@ -38,16 +24,6 @@ export const Gestures = {
|
|
38
24
|
ManualGestureHandler,
|
39
25
|
};
|
40
26
|
|
41
|
-
export const HammerGestures = {
|
42
|
-
NativeViewGestureHandler: HammerNativeViewGestureHandler,
|
43
|
-
PanGestureHandler: HammerPanGestureHandler,
|
44
|
-
TapGestureHandler: HammerTapGestureHandler,
|
45
|
-
LongPressGestureHandler: HammerLongPressGestureHandler,
|
46
|
-
PinchGestureHandler: HammerPinchGestureHandler,
|
47
|
-
RotationGestureHandler: HammerRotationGestureHandler,
|
48
|
-
FlingGestureHandler: HammerFlingGestureHandler,
|
49
|
-
};
|
50
|
-
|
51
27
|
export default {
|
52
28
|
handleSetJSResponder(_tag: number, _blockNativeResponder: boolean) {
|
53
29
|
// NO-OP
|
@@ -56,89 +32,31 @@ export default {
|
|
56
32
|
// NO-OP
|
57
33
|
},
|
58
34
|
createGestureHandler<T>(
|
59
|
-
|
60
|
-
|
61
|
-
|
35
|
+
_handlerName: keyof typeof Gestures,
|
36
|
+
_handlerTag: number,
|
37
|
+
_config: T
|
62
38
|
) {
|
63
|
-
|
64
|
-
if (!(handlerName in Gestures)) {
|
65
|
-
throw new Error(
|
66
|
-
`react-native-gesture-handler: ${handlerName} is not supported on web.`
|
67
|
-
);
|
68
|
-
}
|
69
|
-
|
70
|
-
const GestureClass = Gestures[handlerName];
|
71
|
-
NodeManager.createGestureHandler(
|
72
|
-
handlerTag,
|
73
|
-
new GestureClass(new GestureHandlerWebDelegate())
|
74
|
-
);
|
75
|
-
InteractionManager.getInstance().configureInteractions(
|
76
|
-
NodeManager.getHandler(handlerTag),
|
77
|
-
config as unknown as Config
|
78
|
-
);
|
79
|
-
} else {
|
80
|
-
if (!(handlerName in HammerGestures)) {
|
81
|
-
throw new Error(
|
82
|
-
`react-native-gesture-handler: ${handlerName} is not supported on web.`
|
83
|
-
);
|
84
|
-
}
|
85
|
-
|
86
|
-
// @ts-ignore If it doesn't exist, the error is thrown
|
87
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
88
|
-
const GestureClass = HammerGestures[handlerName];
|
89
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
90
|
-
HammerNodeManager.createGestureHandler(handlerTag, new GestureClass());
|
91
|
-
}
|
92
|
-
|
93
|
-
this.updateGestureHandler(handlerTag, config as unknown as Config);
|
39
|
+
// NO-OP
|
94
40
|
},
|
95
41
|
attachGestureHandler(
|
96
|
-
|
42
|
+
_handlerTag: number,
|
97
43
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
98
|
-
|
44
|
+
_newView: any,
|
99
45
|
_actionType: ActionType,
|
100
|
-
|
46
|
+
_propsRef: React.RefObject<unknown>
|
101
47
|
) {
|
102
|
-
|
103
|
-
!(newView instanceof HTMLElement || newView instanceof React.Component)
|
104
|
-
) {
|
105
|
-
return;
|
106
|
-
}
|
107
|
-
|
108
|
-
if (isNewWebImplementationEnabled()) {
|
109
|
-
//@ts-ignore Types should be HTMLElement or React.Component
|
110
|
-
NodeManager.getHandler(handlerTag).init(newView, propsRef);
|
111
|
-
} else {
|
112
|
-
//@ts-ignore Types should be HTMLElement or React.Component
|
113
|
-
HammerNodeManager.getHandler(handlerTag).setView(newView, propsRef);
|
114
|
-
}
|
48
|
+
// NO-OP
|
115
49
|
},
|
116
|
-
updateGestureHandler(
|
117
|
-
|
118
|
-
NodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);
|
119
|
-
|
120
|
-
InteractionManager.getInstance().configureInteractions(
|
121
|
-
NodeManager.getHandler(handlerTag),
|
122
|
-
newConfig
|
123
|
-
);
|
124
|
-
} else {
|
125
|
-
HammerNodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);
|
126
|
-
}
|
50
|
+
updateGestureHandler(_handlerTag: number, _newConfig: Config) {
|
51
|
+
// NO-OP
|
127
52
|
},
|
128
|
-
getGestureHandlerNode(
|
129
|
-
|
130
|
-
return NodeManager.getHandler(handlerTag);
|
131
|
-
} else {
|
132
|
-
return HammerNodeManager.getHandler(handlerTag);
|
133
|
-
}
|
53
|
+
getGestureHandlerNode(_handlerTag: number) {
|
54
|
+
// NO-OP
|
134
55
|
},
|
135
|
-
dropGestureHandler(
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
}
|
56
|
+
dropGestureHandler(_handlerTag: number) {
|
57
|
+
// NO-OP
|
58
|
+
},
|
59
|
+
flushOperations() {
|
60
|
+
// NO-OP
|
141
61
|
},
|
142
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
143
|
-
flushOperations() {},
|
144
62
|
};
|
@@ -38,6 +38,7 @@ import {
|
|
38
38
|
TapGestureHandlerEventPayload,
|
39
39
|
} from '../handlers/TapGestureHandler';
|
40
40
|
import { State } from '../State';
|
41
|
+
import { MouseButton } from '../web/interfaces';
|
41
42
|
|
42
43
|
const DRAG_TOSS = 0.05;
|
43
44
|
|
@@ -173,6 +174,18 @@ export interface DrawerLayoutProps {
|
|
173
174
|
* Values: see CSS cursor values
|
174
175
|
*/
|
175
176
|
activeCursor?: ActiveCursor;
|
177
|
+
|
178
|
+
/**
|
179
|
+
* @default 'MouseButton.LEFT'
|
180
|
+
* Allows to choose which mouse button should underlying pan handler react to.
|
181
|
+
*/
|
182
|
+
mouseButton?: MouseButton;
|
183
|
+
|
184
|
+
/**
|
185
|
+
* @default 'false if MouseButton.RIGHT is specified'
|
186
|
+
* Allows to enable/disable context menu.
|
187
|
+
*/
|
188
|
+
enableContextMenu?: boolean;
|
176
189
|
}
|
177
190
|
|
178
191
|
export type DrawerLayoutState = {
|
@@ -700,6 +713,8 @@ export default class DrawerLayout extends Component<
|
|
700
713
|
// @ts-ignore could be fixed in handler types
|
701
714
|
userSelect={this.props.userSelect}
|
702
715
|
activeCursor={this.props.activeCursor}
|
716
|
+
mouseButton={this.props.mouseButton}
|
717
|
+
enableContextMenu={this.props.enableContextMenu}
|
703
718
|
ref={this.setPanGestureRef}
|
704
719
|
hitSlop={hitSlop}
|
705
720
|
activeOffsetX={gestureOrientation * minSwipeDistance!}
|
@@ -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> {
|
@@ -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 =
|
5
|
+
export type TouchableWithoutFeedbackProps = GenericTouchableProps;
|
6
6
|
|
7
7
|
const TouchableWithoutFeedback = React.forwardRef<
|
8
|
-
|
9
|
-
PropsWithChildren<
|
8
|
+
GenericTouchable,
|
9
|
+
PropsWithChildren<TouchableWithoutFeedbackProps>
|
10
10
|
>((props, ref) => <GenericTouchable ref={ref} {...props} />);
|
11
11
|
|
12
12
|
TouchableWithoutFeedback.defaultProps = GenericTouchable.defaultProps;
|
@@ -12,6 +12,7 @@ import { handlerIDToTag } from './handlersRegistry';
|
|
12
12
|
import { toArray } from '../utils';
|
13
13
|
import RNGestureHandlerModule from '../RNGestureHandlerModule';
|
14
14
|
import { ghQueueMicrotask } from '../ghQueueMicrotask';
|
15
|
+
import { MouseButton } from '../web/interfaces';
|
15
16
|
|
16
17
|
const commonProps = [
|
17
18
|
'id',
|
@@ -21,6 +22,8 @@ const commonProps = [
|
|
21
22
|
'cancelsTouchesInView',
|
22
23
|
'userSelect',
|
23
24
|
'activeCursor',
|
25
|
+
'mouseButton',
|
26
|
+
'enableContextMenu',
|
24
27
|
] as const;
|
25
28
|
|
26
29
|
const componentInteractionProps = [
|
@@ -149,6 +152,8 @@ export type CommonGestureConfig = {
|
|
149
152
|
hitSlop?: HitSlop;
|
150
153
|
userSelect?: UserSelect;
|
151
154
|
activeCursor?: ActiveCursor;
|
155
|
+
mouseButton?: MouseButton;
|
156
|
+
enableContextMenu?: boolean;
|
152
157
|
};
|
153
158
|
|
154
159
|
// Events payloads are types instead of interfaces due to TS limitation.
|
@@ -605,10 +605,20 @@ const applyUserSelectProp = (
|
|
605
605
|
}
|
606
606
|
};
|
607
607
|
|
608
|
+
const applyEnableContextMenuProp = (
|
609
|
+
enableContextMenu: boolean,
|
610
|
+
gesture: ComposedGesture | GestureType
|
611
|
+
): void => {
|
612
|
+
for (const g of gesture.toGestureArray()) {
|
613
|
+
g.config.enableContextMenu = enableContextMenu;
|
614
|
+
}
|
615
|
+
};
|
616
|
+
|
608
617
|
interface GestureDetectorProps {
|
609
618
|
gesture: ComposedGesture | GestureType;
|
610
|
-
userSelect?: UserSelect;
|
611
619
|
children?: React.ReactNode;
|
620
|
+
userSelect?: UserSelect;
|
621
|
+
enableContextMenu?: boolean;
|
612
622
|
}
|
613
623
|
interface GestureDetectorState {
|
614
624
|
firstRender: boolean;
|
@@ -630,6 +640,10 @@ export const GestureDetector = (props: GestureDetectorProps) => {
|
|
630
640
|
applyUserSelectProp(props.userSelect, gestureConfig);
|
631
641
|
}
|
632
642
|
|
643
|
+
if (props.enableContextMenu !== undefined) {
|
644
|
+
applyEnableContextMenuProp(props.enableContextMenu, gestureConfig);
|
645
|
+
}
|
646
|
+
|
633
647
|
const gesture = gestureConfig.toGestureArray();
|
634
648
|
const useReanimatedHook = gesture.some((g) => g.shouldUseReanimated);
|
635
649
|
|
@@ -763,7 +777,7 @@ export const GestureDetector = (props: GestureDetectorProps) => {
|
|
763
777
|
// in case the view has changed, while config update would be handled be the `useEffect` above
|
764
778
|
onHandlersUpdate(true);
|
765
779
|
|
766
|
-
if (isFabric()) {
|
780
|
+
if (isFabric() && global.isFormsStackingContext) {
|
767
781
|
const node = getShadowNodeFromRef(ref);
|
768
782
|
if (global.isFormsStackingContext(node) === false) {
|
769
783
|
console.error(
|
@@ -17,6 +17,7 @@ import { RotationGestureHandlerEventPayload } from '../RotationGestureHandler';
|
|
17
17
|
import { TapGestureHandlerEventPayload } from '../TapGestureHandler';
|
18
18
|
import { NativeViewGestureHandlerPayload } from '../NativeViewGestureHandler';
|
19
19
|
import { isRemoteDebuggingEnabled } from '../../utils';
|
20
|
+
import { MouseButton } from '../../web/interfaces';
|
20
21
|
|
21
22
|
export type GestureType =
|
22
23
|
| BaseGesture<Record<string, unknown>>
|
@@ -257,6 +258,11 @@ export abstract class BaseGesture<
|
|
257
258
|
return this;
|
258
259
|
}
|
259
260
|
|
261
|
+
mouseButton(mouseButton: MouseButton) {
|
262
|
+
this.config.mouseButton = mouseButton;
|
263
|
+
return this;
|
264
|
+
}
|
265
|
+
|
260
266
|
runOnJS(runOnJS: boolean) {
|
261
267
|
this.config.runOnJS = runOnJS;
|
262
268
|
return this;
|