react-native-gesture-handler 2.12.1 → 2.13.1
Sign up to get free protection for your applications and to get access to all the features.
- package/RNGestureHandler.podspec +0 -15
- package/android/build.gradle +5 -76
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt +16 -1
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +43 -18
- package/android/src/main/java/com/swmansion/gesturehandler/core/HoverGestureHandler.kt +120 -0
- package/android/src/main/java/com/swmansion/gesturehandler/core/NativeViewGestureHandler.kt +7 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/Extensions.kt +5 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +43 -16
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +21 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +9 -1
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt +10 -0
- package/ios/Handlers/RNHoverHandler.h +12 -0
- package/ios/Handlers/RNHoverHandler.m +152 -0
- package/ios/RNGestureHandlerButtonComponentView.mm +2 -0
- package/ios/RNGestureHandlerEvents.h +1 -0
- package/ios/RNGestureHandlerEvents.m +10 -0
- package/ios/RNGestureHandlerManager.mm +2 -0
- package/ios/RNManualActivationRecognizer.m +2 -1
- package/ios/RNRootViewGestureRecognizer.m +7 -2
- package/lib/commonjs/RNGestureHandlerModule.macos.js +3 -1
- package/lib/commonjs/RNGestureHandlerModule.macos.js.map +1 -1
- package/lib/commonjs/RNGestureHandlerModule.web.js +7 -2
- package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/commonjs/RNGestureHandlerModule.windows.js +3 -1
- package/lib/commonjs/RNGestureHandlerModule.windows.js.map +1 -1
- package/lib/commonjs/components/DrawerLayout.js +1 -0
- package/lib/commonjs/components/DrawerLayout.js.map +1 -1
- package/lib/commonjs/components/touchables/GenericTouchable.js +1 -2
- package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/commonjs/components/touchables/TouchableHighlight.js.map +1 -1
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.android.js.map +1 -1
- package/lib/commonjs/components/touchables/TouchableOpacity.js.map +1 -1
- package/lib/commonjs/components/touchables/TouchableWithoutFeedback.js.map +1 -1
- package/lib/commonjs/components/touchables/index.js.map +1 -1
- package/lib/commonjs/handlers/createHandler.js +3 -3
- package/lib/commonjs/handlers/createHandler.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 +3 -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/gestureObjects.js +5 -0
- package/lib/commonjs/handlers/gestures/gestureObjects.js.map +1 -1
- package/lib/commonjs/handlers/gestures/hoverGesture.js +74 -0
- package/lib/commonjs/handlers/gestures/hoverGesture.js.map +1 -0
- package/lib/commonjs/index.js +8 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/web/handlers/FlingGestureHandler.js +0 -10
- package/lib/commonjs/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/GestureHandler.js +61 -88
- package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/HoverGestureHandler.js +62 -0
- package/lib/commonjs/web/handlers/HoverGestureHandler.js.map +1 -0
- package/lib/commonjs/web/handlers/LongPressGestureHandler.js +6 -7
- package/lib/commonjs/web/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js +12 -4
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PanGestureHandler.js +2 -7
- package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/TapGestureHandler.js +0 -10
- package/lib/commonjs/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/commonjs/web/interfaces.js +1 -1
- package/lib/commonjs/web/interfaces.js.map +1 -1
- package/lib/commonjs/web/tools/EventManager.js +18 -4
- package/lib/commonjs/web/tools/EventManager.js.map +1 -1
- package/lib/commonjs/web/tools/GestureHandlerDelegate.js +6 -0
- package/lib/commonjs/web/tools/GestureHandlerDelegate.js.map +1 -0
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js +5 -7
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js +118 -0
- package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js.map +1 -0
- package/lib/commonjs/web/tools/PointerEventManager.js +38 -5
- package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
- package/lib/commonjs/web/tools/TouchEventManager.js +2 -2
- package/lib/commonjs/web/tools/TouchEventManager.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.macos.js +2 -1
- package/lib/module/RNGestureHandlerModule.macos.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.web.js +6 -3
- package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.windows.js +2 -1
- package/lib/module/RNGestureHandlerModule.windows.js.map +1 -1
- package/lib/module/components/DrawerLayout.js +1 -0
- package/lib/module/components/DrawerLayout.js.map +1 -1
- package/lib/module/components/touchables/GenericTouchable.js +1 -2
- package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/module/components/touchables/TouchableHighlight.js.map +1 -1
- package/lib/module/components/touchables/TouchableNativeFeedback.android.js.map +1 -1
- package/lib/module/components/touchables/TouchableOpacity.js.map +1 -1
- package/lib/module/components/touchables/TouchableWithoutFeedback.js.map +1 -1
- package/lib/module/components/touchables/index.js.map +1 -1
- package/lib/module/handlers/createHandler.js +3 -3
- package/lib/module/handlers/createHandler.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 +2 -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/gestureObjects.js +4 -0
- package/lib/module/handlers/gestures/gestureObjects.js.map +1 -1
- package/lib/module/handlers/gestures/hoverGesture.js +62 -0
- package/lib/module/handlers/gestures/hoverGesture.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/web/handlers/FlingGestureHandler.js +0 -10
- package/lib/module/web/handlers/FlingGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/GestureHandler.js +61 -84
- package/lib/module/web/handlers/GestureHandler.js.map +1 -1
- package/lib/module/web/handlers/HoverGestureHandler.js +47 -0
- package/lib/module/web/handlers/HoverGestureHandler.js.map +1 -0
- package/lib/module/web/handlers/LongPressGestureHandler.js +5 -7
- package/lib/module/web/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/NativeViewGestureHandler.js +11 -4
- package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PanGestureHandler.js +2 -7
- package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/web/handlers/TapGestureHandler.js +0 -10
- package/lib/module/web/handlers/TapGestureHandler.js.map +1 -1
- package/lib/module/web/interfaces.js +1 -1
- package/lib/module/web/interfaces.js.map +1 -1
- package/lib/module/web/tools/EventManager.js +18 -4
- package/lib/module/web/tools/EventManager.js.map +1 -1
- package/lib/module/web/tools/GestureHandlerDelegate.js +2 -0
- package/lib/module/web/tools/GestureHandlerDelegate.js.map +1 -0
- package/lib/module/web/tools/GestureHandlerOrchestrator.js +5 -6
- package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/module/web/tools/GestureHandlerWebDelegate.js +102 -0
- package/lib/module/web/tools/GestureHandlerWebDelegate.js.map +1 -0
- package/lib/module/web/tools/PointerEventManager.js +39 -6
- package/lib/module/web/tools/PointerEventManager.js.map +1 -1
- package/lib/module/web/tools/TouchEventManager.js +2 -2
- package/lib/module/web/tools/TouchEventManager.js.map +1 -1
- package/lib/typescript/RNGestureHandlerModule.macos.d.ts +1 -1
- package/lib/typescript/RNGestureHandlerModule.web.d.ts +3 -1
- package/lib/typescript/RNGestureHandlerModule.windows.d.ts +1 -1
- package/lib/typescript/components/DrawerLayout.d.ts +7 -1
- package/lib/typescript/components/touchables/GenericTouchable.d.ts +3 -2
- package/lib/typescript/components/touchables/TouchableHighlight.d.ts +4 -3
- package/lib/typescript/components/touchables/TouchableNativeFeedback.android.d.ts +3 -2
- package/lib/typescript/components/touchables/TouchableOpacity.d.ts +4 -5
- package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts +1 -0
- package/lib/typescript/components/touchables/index.d.ts +3 -0
- package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +1 -1
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +3 -1
- package/lib/typescript/handlers/gestures/gesture.d.ts +2 -1
- package/lib/typescript/handlers/gestures/gestureObjects.d.ts +2 -0
- package/lib/typescript/handlers/gestures/hoverGesture.d.ts +32 -0
- package/lib/typescript/index.d.ts +4 -0
- package/lib/typescript/web/handlers/FlingGestureHandler.d.ts +0 -6
- package/lib/typescript/web/handlers/GestureHandler.d.ts +12 -17
- package/lib/typescript/web/handlers/HoverGestureHandler.d.ts +10 -0
- package/lib/typescript/web/handlers/LongPressGestureHandler.d.ts +0 -4
- package/lib/typescript/web/handlers/NativeViewGestureHandler.d.ts +1 -1
- package/lib/typescript/web/handlers/PanGestureHandler.d.ts +0 -4
- package/lib/typescript/web/handlers/TapGestureHandler.d.ts +0 -6
- package/lib/typescript/web/interfaces.d.ts +4 -3
- package/lib/typescript/web/tools/EventManager.d.ts +9 -5
- package/lib/typescript/web/tools/GestureHandlerDelegate.d.ts +22 -0
- package/lib/typescript/web/tools/GestureHandlerWebDelegate.d.ts +21 -0
- package/lib/typescript/web/tools/NodeManager.d.ts +2 -2
- package/lib/typescript/web/tools/PointerEventManager.d.ts +1 -1
- package/lib/typescript/web/tools/TouchEventManager.d.ts +1 -1
- package/package.json +2 -2
- package/src/RNGestureHandlerModule.macos.ts +5 -1
- package/src/RNGestureHandlerModule.web.ts +7 -1
- package/src/RNGestureHandlerModule.windows.ts +5 -1
- package/src/components/DrawerLayout.tsx +9 -0
- package/src/components/touchables/GenericTouchable.tsx +4 -4
- package/src/components/touchables/TouchableHighlight.tsx +6 -3
- package/src/components/touchables/TouchableNativeFeedback.android.tsx +5 -4
- package/src/components/touchables/TouchableOpacity.tsx +6 -7
- package/src/components/touchables/TouchableWithoutFeedback.tsx +3 -1
- package/src/components/touchables/index.ts +3 -0
- package/src/handlers/createHandler.tsx +4 -2
- package/src/handlers/gestureHandlerCommon.ts +39 -0
- package/src/handlers/gestures/GestureDetector.tsx +2 -0
- package/src/handlers/gestures/gesture.ts +6 -0
- package/src/handlers/gestures/gestureObjects.ts +5 -0
- package/src/handlers/gestures/hoverGesture.ts +83 -0
- package/src/index.ts +8 -0
- package/src/web/handlers/FlingGestureHandler.ts +0 -11
- package/src/web/handlers/GestureHandler.ts +68 -88
- package/src/web/handlers/HoverGestureHandler.ts +43 -0
- package/src/web/handlers/LongPressGestureHandler.ts +5 -7
- package/src/web/handlers/NativeViewGestureHandler.ts +11 -4
- package/src/web/handlers/PanGestureHandler.ts +1 -6
- package/src/web/handlers/TapGestureHandler.ts +0 -11
- package/src/web/interfaces.ts +4 -2
- package/src/web/tools/EventManager.ts +15 -7
- package/src/web/tools/GestureHandlerDelegate.ts +23 -0
- package/src/web/tools/GestureHandlerOrchestrator.ts +7 -6
- package/src/web/tools/GestureHandlerWebDelegate.ts +115 -0
- package/src/web/tools/PointerEventManager.ts +46 -16
- package/src/web/tools/TouchEventManager.ts +3 -3
@@ -1,4 +1,4 @@
|
|
1
|
-
import { UserSelect } from '../handlers/gestureHandlerCommon';
|
1
|
+
import { UserSelect, ActiveCursor } from '../handlers/gestureHandlerCommon';
|
2
2
|
import { Directions } from '../Directions';
|
3
3
|
import { State } from '../State';
|
4
4
|
export interface HitSlop {
|
@@ -14,7 +14,7 @@ export interface HitSlop {
|
|
14
14
|
export interface Handler {
|
15
15
|
handlerTag: number;
|
16
16
|
}
|
17
|
-
declare type ConfigArgs = number | boolean | HitSlop | UserSelect | Directions | Handler[] | null | undefined;
|
17
|
+
declare 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;
|
@@ -22,6 +22,7 @@ export interface Config extends Record<string, ConfigArgs> {
|
|
22
22
|
hitSlop?: HitSlop;
|
23
23
|
shouldCancelWhenOutside?: boolean;
|
24
24
|
userSelect?: UserSelect;
|
25
|
+
activeCursor?: ActiveCursor;
|
25
26
|
activateAfterLongPress?: number;
|
26
27
|
failOffsetXStart?: number;
|
27
28
|
failOffsetYStart?: number;
|
@@ -120,7 +121,7 @@ export declare enum EventTypes {
|
|
120
121
|
ADDITIONAL_POINTER_UP = 3,
|
121
122
|
MOVE = 4,
|
122
123
|
ENTER = 5,
|
123
|
-
|
124
|
+
LEAVE = 6,
|
124
125
|
CANCEL = 7
|
125
126
|
}
|
126
127
|
export declare enum TouchEventType {
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { AdaptedEvent, EventTypes, TouchEventType } from '../interfaces';
|
2
|
-
export default abstract class EventManager {
|
3
|
-
protected readonly view:
|
2
|
+
export default abstract class EventManager<T> {
|
3
|
+
protected readonly view: T;
|
4
4
|
protected pointersInBounds: number[];
|
5
5
|
protected activePointersCounter: number;
|
6
|
-
constructor(view:
|
6
|
+
constructor(view: T);
|
7
7
|
abstract setListeners(): void;
|
8
8
|
protected abstract mapEvent(event: Event, eventType: EventTypes, index?: number, touchEventType?: TouchEventType): AdaptedEvent;
|
9
9
|
protected onPointerDown(_event: AdaptedEvent): void;
|
@@ -11,19 +11,23 @@ export default abstract class EventManager {
|
|
11
11
|
protected onPointerUp(_event: AdaptedEvent): void;
|
12
12
|
protected onPointerRemove(_event: AdaptedEvent): void;
|
13
13
|
protected onPointerMove(_event: AdaptedEvent): void;
|
14
|
-
protected
|
14
|
+
protected onPointerLeave(_event: AdaptedEvent): void;
|
15
15
|
protected onPointerEnter(_event: AdaptedEvent): void;
|
16
16
|
protected onPointerCancel(_event: AdaptedEvent): void;
|
17
17
|
protected onPointerOutOfBounds(_event: AdaptedEvent): void;
|
18
|
+
protected onPointerMoveOver(_event: AdaptedEvent): void;
|
19
|
+
protected onPointerMoveOut(_event: AdaptedEvent): void;
|
18
20
|
setOnPointerDown(callback: (event: AdaptedEvent) => void): void;
|
19
21
|
setOnPointerAdd(callback: (event: AdaptedEvent) => void): void;
|
20
22
|
setOnPointerUp(callback: (event: AdaptedEvent) => void): void;
|
21
23
|
setOnPointerRemove(callback: (event: AdaptedEvent) => void): void;
|
22
24
|
setOnPointerMove(callback: (event: AdaptedEvent) => void): void;
|
23
|
-
|
25
|
+
setOnPointerLeave(callback: (event: AdaptedEvent) => void): void;
|
24
26
|
setOnPointerEnter(callback: (event: AdaptedEvent) => void): void;
|
25
27
|
setOnPointerCancel(callback: (event: AdaptedEvent) => void): void;
|
26
28
|
setOnPointerOutOfBounds(callback: (event: AdaptedEvent) => void): void;
|
29
|
+
setOnPointerMoveOver(callback: (event: AdaptedEvent) => void): void;
|
30
|
+
setOnPointerMoveOut(callback: (event: AdaptedEvent) => void): void;
|
27
31
|
protected markAsInBounds(pointerId: number): void;
|
28
32
|
protected markAsOutOfBounds(pointerId: number): void;
|
29
33
|
resetManager(): void;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import type GestureHandler from '../handlers/GestureHandler';
|
2
|
+
export interface MeasureResult {
|
3
|
+
pageX: number;
|
4
|
+
pageY: number;
|
5
|
+
width: number;
|
6
|
+
height: number;
|
7
|
+
}
|
8
|
+
export interface GestureHandlerDelegate<T> {
|
9
|
+
getView(): T;
|
10
|
+
init(viewRef: number, handler: GestureHandler): void;
|
11
|
+
isPointerInBounds({ x, y }: {
|
12
|
+
x: number;
|
13
|
+
y: number;
|
14
|
+
}): boolean;
|
15
|
+
measureView(): MeasureResult;
|
16
|
+
reset(): void;
|
17
|
+
onBegin(): void;
|
18
|
+
onActivate(): void;
|
19
|
+
onEnd(): void;
|
20
|
+
onCancel(): void;
|
21
|
+
onFail(): void;
|
22
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import type GestureHandler from '../handlers/GestureHandler';
|
2
|
+
import { GestureHandlerDelegate, MeasureResult } from './GestureHandlerDelegate';
|
3
|
+
export declare class GestureHandlerWebDelegate implements GestureHandlerDelegate<HTMLElement> {
|
4
|
+
private view;
|
5
|
+
private gestureHandler;
|
6
|
+
private eventManagers;
|
7
|
+
getView(): HTMLElement;
|
8
|
+
init(viewRef: number, handler: GestureHandler): void;
|
9
|
+
isPointerInBounds({ x, y }: {
|
10
|
+
x: number;
|
11
|
+
y: number;
|
12
|
+
}): boolean;
|
13
|
+
measureView(): MeasureResult;
|
14
|
+
reset(): void;
|
15
|
+
tryResetCursor(): void;
|
16
|
+
onBegin(): void;
|
17
|
+
onActivate(): void;
|
18
|
+
onEnd(): void;
|
19
|
+
onCancel(): void;
|
20
|
+
onFail(): void;
|
21
|
+
}
|
@@ -2,10 +2,10 @@ import { ValueOf } from '../../typeUtils';
|
|
2
2
|
import { Gestures } from '../../RNGestureHandlerModule.web';
|
3
3
|
export default abstract class NodeManager {
|
4
4
|
private static gestures;
|
5
|
-
static getHandler(tag: number): import("../handlers/NativeViewGestureHandler").default | import("../handlers/PanGestureHandler").default | import("../handlers/TapGestureHandler").default | import("../handlers/LongPressGestureHandler").default | import("../handlers/PinchGestureHandler").default | import("../handlers/RotationGestureHandler").default | import("../handlers/FlingGestureHandler").default | import("../handlers/ManualGestureHandler").default;
|
5
|
+
static getHandler(tag: number): import("../handlers/NativeViewGestureHandler").default | import("../handlers/PanGestureHandler").default | import("../handlers/TapGestureHandler").default | import("../handlers/LongPressGestureHandler").default | import("../handlers/PinchGestureHandler").default | import("../handlers/RotationGestureHandler").default | import("../handlers/FlingGestureHandler").default | import("../handlers/ManualGestureHandler").default | import("../handlers/HoverGestureHandler").default;
|
6
6
|
static createGestureHandler(handlerTag: number, handler: InstanceType<ValueOf<typeof Gestures>>): void;
|
7
7
|
static dropGestureHandler(handlerTag: number): void;
|
8
8
|
static getNodes(): {
|
9
|
-
[x: number]: import("../handlers/NativeViewGestureHandler").default | import("../handlers/PanGestureHandler").default | import("../handlers/TapGestureHandler").default | import("../handlers/LongPressGestureHandler").default | import("../handlers/PinchGestureHandler").default | import("../handlers/RotationGestureHandler").default | import("../handlers/FlingGestureHandler").default | import("../handlers/ManualGestureHandler").default;
|
9
|
+
[x: number]: import("../handlers/NativeViewGestureHandler").default | import("../handlers/PanGestureHandler").default | import("../handlers/TapGestureHandler").default | import("../handlers/LongPressGestureHandler").default | import("../handlers/PinchGestureHandler").default | import("../handlers/RotationGestureHandler").default | import("../handlers/FlingGestureHandler").default | import("../handlers/ManualGestureHandler").default | import("../handlers/HoverGestureHandler").default;
|
10
10
|
};
|
11
11
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { AdaptedEvent, EventTypes } from '../interfaces';
|
2
2
|
import EventManager from './EventManager';
|
3
|
-
export default class PointerEventManager extends EventManager {
|
3
|
+
export default class PointerEventManager extends EventManager<HTMLElement> {
|
4
4
|
private trackedPointers;
|
5
5
|
setListeners(): void;
|
6
6
|
protected mapEvent(event: PointerEvent, eventType: EventTypes): AdaptedEvent;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { AdaptedEvent, EventTypes, TouchEventType } from '../interfaces';
|
2
2
|
import EventManager from './EventManager';
|
3
|
-
export default class TouchEventManager extends EventManager {
|
3
|
+
export default class TouchEventManager extends EventManager<HTMLElement> {
|
4
4
|
setListeners(): void;
|
5
5
|
protected mapEvent(event: TouchEvent, eventType: EventTypes, index: number, touchEventType: TouchEventType): AdaptedEvent;
|
6
6
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-native-gesture-handler",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.13.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",
|
@@ -88,7 +88,7 @@
|
|
88
88
|
"@typescript-eslint/parser": "^4.33.0",
|
89
89
|
"babel-jest": "^26.6.3",
|
90
90
|
"clang-format": "^1.8.0",
|
91
|
-
"eslint": "^7.
|
91
|
+
"eslint": "^7.32.0",
|
92
92
|
"eslint-config-satya164": "^3.1.8",
|
93
93
|
"eslint-import-resolver-babel-module": "^5.2.0",
|
94
94
|
"eslint-plugin-import": "^2.22.1",
|
@@ -23,6 +23,7 @@ import HammerPinchGestureHandler from './web_hammer/PinchGestureHandler';
|
|
23
23
|
import HammerRotationGestureHandler from './web_hammer/RotationGestureHandler';
|
24
24
|
import HammerFlingGestureHandler from './web_hammer/FlingGestureHandler';
|
25
25
|
import { Config } from './web/interfaces';
|
26
|
+
import { GestureHandlerWebDelegate } from './web/tools/GestureHandlerWebDelegate';
|
26
27
|
|
27
28
|
export const Gestures = {
|
28
29
|
NativeViewGestureHandler,
|
@@ -65,7 +66,10 @@ export default {
|
|
65
66
|
}
|
66
67
|
|
67
68
|
const GestureClass = Gestures[handlerName];
|
68
|
-
NodeManager.createGestureHandler(
|
69
|
+
NodeManager.createGestureHandler(
|
70
|
+
handlerTag,
|
71
|
+
new GestureClass(new GestureHandlerWebDelegate())
|
72
|
+
);
|
69
73
|
InteractionManager.getInstance().configureInteractions(
|
70
74
|
NodeManager.getHandler(handlerTag),
|
71
75
|
config as unknown as Config
|
@@ -14,6 +14,7 @@ import RotationGestureHandler from './web/handlers/RotationGestureHandler';
|
|
14
14
|
import FlingGestureHandler from './web/handlers/FlingGestureHandler';
|
15
15
|
import NativeViewGestureHandler from './web/handlers/NativeViewGestureHandler';
|
16
16
|
import ManualGestureHandler from './web/handlers/ManualGestureHandler';
|
17
|
+
import HoverGestureHandler from './web/handlers/HoverGestureHandler';
|
17
18
|
|
18
19
|
//Hammer Handlers
|
19
20
|
import * as HammerNodeManager from './web_hammer/NodeManager';
|
@@ -25,6 +26,7 @@ import HammerPinchGestureHandler from './web_hammer/PinchGestureHandler';
|
|
25
26
|
import HammerRotationGestureHandler from './web_hammer/RotationGestureHandler';
|
26
27
|
import HammerFlingGestureHandler from './web_hammer/FlingGestureHandler';
|
27
28
|
import { Config } from './web/interfaces';
|
29
|
+
import { GestureHandlerWebDelegate } from './web/tools/GestureHandlerWebDelegate';
|
28
30
|
|
29
31
|
export const Gestures = {
|
30
32
|
NativeViewGestureHandler,
|
@@ -35,6 +37,7 @@ export const Gestures = {
|
|
35
37
|
RotationGestureHandler,
|
36
38
|
FlingGestureHandler,
|
37
39
|
ManualGestureHandler,
|
40
|
+
HoverGestureHandler,
|
38
41
|
};
|
39
42
|
|
40
43
|
export const HammerGestures = {
|
@@ -67,7 +70,10 @@ export default {
|
|
67
70
|
}
|
68
71
|
|
69
72
|
const GestureClass = Gestures[handlerName];
|
70
|
-
NodeManager.createGestureHandler(
|
73
|
+
NodeManager.createGestureHandler(
|
74
|
+
handlerTag,
|
75
|
+
new GestureClass(new GestureHandlerWebDelegate())
|
76
|
+
);
|
71
77
|
InteractionManager.getInstance().configureInteractions(
|
72
78
|
NodeManager.getHandler(handlerTag),
|
73
79
|
config as unknown as Config
|
@@ -25,6 +25,7 @@ import HammerPinchGestureHandler from './web_hammer/PinchGestureHandler';
|
|
25
25
|
import HammerRotationGestureHandler from './web_hammer/RotationGestureHandler';
|
26
26
|
import HammerFlingGestureHandler from './web_hammer/FlingGestureHandler';
|
27
27
|
import { Config } from './web/interfaces';
|
28
|
+
import { GestureHandlerWebDelegate } from './web/tools/GestureHandlerWebDelegate';
|
28
29
|
|
29
30
|
export const Gestures = {
|
30
31
|
NativeViewGestureHandler,
|
@@ -67,7 +68,10 @@ export default {
|
|
67
68
|
}
|
68
69
|
|
69
70
|
const GestureClass = Gestures[handlerName];
|
70
|
-
NodeManager.createGestureHandler(
|
71
|
+
NodeManager.createGestureHandler(
|
72
|
+
handlerTag,
|
73
|
+
new GestureClass(new GestureHandlerWebDelegate())
|
74
|
+
);
|
71
75
|
InteractionManager.getInstance().configureInteractions(
|
72
76
|
NodeManager.getHandler(handlerTag),
|
73
77
|
config as unknown as Config
|
@@ -27,6 +27,7 @@ import {
|
|
27
27
|
GestureEvent,
|
28
28
|
HandlerStateChangeEvent,
|
29
29
|
UserSelect,
|
30
|
+
ActiveCursor,
|
30
31
|
} from '../handlers/gestureHandlerCommon';
|
31
32
|
import {
|
32
33
|
PanGestureHandler,
|
@@ -165,6 +166,13 @@ export interface DrawerLayoutProps {
|
|
165
166
|
* Values: 'none'|'text'|'auto'
|
166
167
|
*/
|
167
168
|
userSelect?: UserSelect;
|
169
|
+
|
170
|
+
/**
|
171
|
+
* @default 'auto'
|
172
|
+
* Defines which cursor property should be used when gesture activates.
|
173
|
+
* Values: see CSS cursor values
|
174
|
+
*/
|
175
|
+
activeCursor?: ActiveCursor;
|
168
176
|
}
|
169
177
|
|
170
178
|
export type DrawerLayoutState = {
|
@@ -691,6 +699,7 @@ export default class DrawerLayout extends Component<
|
|
691
699
|
<PanGestureHandler
|
692
700
|
// @ts-ignore could be fixed in handler types
|
693
701
|
userSelect={this.props.userSelect}
|
702
|
+
activeCursor={this.props.activeCursor}
|
694
703
|
ref={this.setPanGestureRef}
|
695
704
|
hitSlop={hitSlop}
|
696
705
|
activeOffsetX={gestureOrientation * minSwipeDistance!}
|
@@ -6,6 +6,7 @@ import {
|
|
6
6
|
StyleProp,
|
7
7
|
ViewStyle,
|
8
8
|
TouchableWithoutFeedbackProps,
|
9
|
+
Insets,
|
9
10
|
} from 'react-native';
|
10
11
|
|
11
12
|
import { State } from '../../State';
|
@@ -33,7 +34,8 @@ export const TOUCHABLE_STATE = {
|
|
33
34
|
|
34
35
|
type TouchableState = typeof TOUCHABLE_STATE[keyof typeof TOUCHABLE_STATE];
|
35
36
|
|
36
|
-
export interface GenericTouchableProps
|
37
|
+
export interface GenericTouchableProps
|
38
|
+
extends Omit<TouchableWithoutFeedbackProps, 'hitSlop'> {
|
37
39
|
// Decided to drop not used fields from RN's implementation.
|
38
40
|
// e.g. onBlur and onFocus as well as deprecated props. - TODO: this comment may be unuseful in this moment
|
39
41
|
|
@@ -48,6 +50,7 @@ export interface GenericTouchableProps extends TouchableWithoutFeedbackProps {
|
|
48
50
|
disallowInterruption?: boolean;
|
49
51
|
|
50
52
|
containerStyle?: StyleProp<ViewStyle>;
|
53
|
+
hitSlop?: Insets | number;
|
51
54
|
}
|
52
55
|
|
53
56
|
interface InternalProps {
|
@@ -272,9 +275,6 @@ export default class GenericTouchable extends Component<
|
|
272
275
|
onAccessibilityAction: this.props.onAccessibilityAction,
|
273
276
|
nativeID: this.props.nativeID,
|
274
277
|
onLayout: this.props.onLayout,
|
275
|
-
hitSlop: hitSlop as
|
276
|
-
| Animated.WithAnimatedObject<typeof hitSlop>
|
277
|
-
| undefined,
|
278
278
|
};
|
279
279
|
|
280
280
|
return (
|
@@ -7,7 +7,7 @@ import GenericTouchable, {
|
|
7
7
|
import {
|
8
8
|
StyleSheet,
|
9
9
|
View,
|
10
|
-
TouchableHighlightProps,
|
10
|
+
TouchableHighlightProps as RNTouchableHighlightProps,
|
11
11
|
ColorValue,
|
12
12
|
ViewProps,
|
13
13
|
} from 'react-native';
|
@@ -21,11 +21,14 @@ interface State {
|
|
21
21
|
};
|
22
22
|
}
|
23
23
|
|
24
|
+
export type TouchableHighlightProps = RNTouchableHighlightProps &
|
25
|
+
GenericTouchableProps;
|
26
|
+
|
24
27
|
/**
|
25
28
|
* TouchableHighlight follows RN's implementation
|
26
29
|
*/
|
27
30
|
export default class TouchableHighlight extends Component<
|
28
|
-
TouchableHighlightProps
|
31
|
+
TouchableHighlightProps,
|
29
32
|
State
|
30
33
|
> {
|
31
34
|
static defaultProps = {
|
@@ -35,7 +38,7 @@ export default class TouchableHighlight extends Component<
|
|
35
38
|
underlayColor: 'black',
|
36
39
|
};
|
37
40
|
|
38
|
-
constructor(props: TouchableHighlightProps
|
41
|
+
constructor(props: TouchableHighlightProps) {
|
39
42
|
super(props);
|
40
43
|
this.state = {
|
41
44
|
extraChildStyle: null,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import {
|
2
2
|
Platform,
|
3
|
-
TouchableNativeFeedbackProps,
|
3
|
+
TouchableNativeFeedbackProps as RNTouchableNativeFeedbackProps,
|
4
4
|
ColorValue,
|
5
5
|
} from 'react-native';
|
6
6
|
import * as React from 'react';
|
@@ -14,15 +14,16 @@ export type TouchableNativeFeedbackExtraProps = {
|
|
14
14
|
foreground?: boolean;
|
15
15
|
};
|
16
16
|
|
17
|
+
export type TouchableNativeFeedbackProps = RNTouchableNativeFeedbackProps &
|
18
|
+
GenericTouchableProps;
|
19
|
+
|
17
20
|
/**
|
18
21
|
* TouchableNativeFeedback behaves slightly different than RN's TouchableNativeFeedback.
|
19
22
|
* There's small difference with handling long press ripple since RN's implementation calls
|
20
23
|
* ripple animation via bridge. This solution leaves all animations' handling for native components so
|
21
24
|
* it follows native behaviours.
|
22
25
|
*/
|
23
|
-
export default class TouchableNativeFeedback extends Component<
|
24
|
-
TouchableNativeFeedbackProps & GenericTouchableProps
|
25
|
-
> {
|
26
|
+
export default class TouchableNativeFeedback extends Component<TouchableNativeFeedbackProps> {
|
26
27
|
static defaultProps = {
|
27
28
|
...GenericTouchable.defaultProps,
|
28
29
|
useForeground: true,
|
@@ -3,7 +3,7 @@ import {
|
|
3
3
|
Easing,
|
4
4
|
StyleSheet,
|
5
5
|
View,
|
6
|
-
TouchableOpacityProps,
|
6
|
+
TouchableOpacityProps as RNTouchableOpacityProps,
|
7
7
|
} from 'react-native';
|
8
8
|
import GenericTouchable, {
|
9
9
|
TOUCHABLE_STATE,
|
@@ -12,16 +12,15 @@ import GenericTouchable, {
|
|
12
12
|
import * as React from 'react';
|
13
13
|
import { Component } from 'react';
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
export type TouchableOpacityProps = RNTouchableOpacityProps &
|
16
|
+
GenericTouchableProps & {
|
17
|
+
useNativeAnimations?: boolean;
|
18
|
+
};
|
18
19
|
|
19
20
|
/**
|
20
21
|
* TouchableOpacity bases on timing animation which has been used in RN's core
|
21
22
|
*/
|
22
|
-
export default class TouchableOpacity extends Component<
|
23
|
-
TouchableOpacityProps & GenericTouchableProps & GHTouchableOpacityProps
|
24
|
-
> {
|
23
|
+
export default class TouchableOpacity extends Component<TouchableOpacityProps> {
|
25
24
|
static defaultProps = {
|
26
25
|
...GenericTouchable.defaultProps,
|
27
26
|
activeOpacity: 0.2,
|
@@ -2,8 +2,10 @@ 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;
|
6
|
+
|
5
7
|
const TouchableWithoutFeedback = React.forwardRef<
|
6
|
-
|
8
|
+
TouchableWithoutFeedbackProps,
|
7
9
|
PropsWithChildren<GenericTouchableProps>
|
8
10
|
>((props, ref) => <GenericTouchable ref={ref} {...props} />);
|
9
11
|
|
@@ -1,3 +1,6 @@
|
|
1
|
+
export type { TouchableHighlightProps } from './TouchableHighlight';
|
2
|
+
export type { TouchableOpacityProps } from './TouchableOpacity';
|
3
|
+
export type { TouchableWithoutFeedbackProps } from './TouchableWithoutFeedback';
|
1
4
|
export { default as TouchableNativeFeedback } from './TouchableNativeFeedback';
|
2
5
|
export { default as TouchableWithoutFeedback } from './TouchableWithoutFeedback';
|
3
6
|
export { default as TouchableOpacity } from './TouchableOpacity';
|
@@ -329,8 +329,10 @@ export default function createHandler<
|
|
329
329
|
|
330
330
|
const actionType = (() => {
|
331
331
|
if (
|
332
|
-
this.props?.onGestureEvent &&
|
333
|
-
|
332
|
+
(this.props?.onGestureEvent &&
|
333
|
+
'current' in this.props.onGestureEvent) ||
|
334
|
+
(this.props?.onHandlerStateChange &&
|
335
|
+
'current' in this.props.onHandlerStateChange)
|
334
336
|
) {
|
335
337
|
// Reanimated worklet
|
336
338
|
return ActionType.REANIMATED_WORKLET;
|
@@ -19,6 +19,7 @@ const commonProps = [
|
|
19
19
|
'hitSlop',
|
20
20
|
'cancelsTouchesInView',
|
21
21
|
'userSelect',
|
22
|
+
'activeCursor',
|
22
23
|
] as const;
|
23
24
|
|
24
25
|
const componentInteractionProps = ['waitFor', 'simultaneousHandlers'] as const;
|
@@ -64,6 +65,43 @@ export type HitSlop =
|
|
64
65
|
| Record<'height' | 'bottom', number>;
|
65
66
|
|
66
67
|
export type UserSelect = 'none' | 'auto' | 'text';
|
68
|
+
export type ActiveCursor =
|
69
|
+
| 'auto'
|
70
|
+
| 'default'
|
71
|
+
| 'none'
|
72
|
+
| 'context-menu'
|
73
|
+
| 'help'
|
74
|
+
| 'pointer'
|
75
|
+
| 'progress'
|
76
|
+
| 'wait'
|
77
|
+
| 'cell'
|
78
|
+
| 'crosshair'
|
79
|
+
| 'text'
|
80
|
+
| 'vertical-text'
|
81
|
+
| 'alias'
|
82
|
+
| 'copy'
|
83
|
+
| 'move'
|
84
|
+
| 'no-drop'
|
85
|
+
| 'not-allowed'
|
86
|
+
| 'grab'
|
87
|
+
| 'grabbing'
|
88
|
+
| 'e-resize'
|
89
|
+
| 'n-resize'
|
90
|
+
| 'ne-resize'
|
91
|
+
| 'nw-resize'
|
92
|
+
| 's-resize'
|
93
|
+
| 'se-resize'
|
94
|
+
| 'sw-resize'
|
95
|
+
| 'w-resize'
|
96
|
+
| 'ew-resize'
|
97
|
+
| 'ns-resize'
|
98
|
+
| 'nesw-resize'
|
99
|
+
| 'nwse-resize'
|
100
|
+
| 'col-resize'
|
101
|
+
| 'row-resize'
|
102
|
+
| 'all-scroll'
|
103
|
+
| 'zoom-in'
|
104
|
+
| 'zoom-out';
|
67
105
|
|
68
106
|
//TODO(TS) events in handlers
|
69
107
|
|
@@ -105,6 +143,7 @@ export type CommonGestureConfig = {
|
|
105
143
|
shouldCancelWhenOutside?: boolean;
|
106
144
|
hitSlop?: HitSlop;
|
107
145
|
userSelect?: UserSelect;
|
146
|
+
activeCursor?: ActiveCursor;
|
108
147
|
};
|
109
148
|
|
110
149
|
// Events payloads are types instead of interfaces due to TS limitation.
|
@@ -32,6 +32,7 @@ import {
|
|
32
32
|
panGestureHandlerCustomNativeProps,
|
33
33
|
} from '../PanGestureHandler';
|
34
34
|
import { tapGestureHandlerProps } from '../TapGestureHandler';
|
35
|
+
import { hoverGestureHandlerProps } from './hoverGesture';
|
35
36
|
import { State } from '../../State';
|
36
37
|
import { TouchEventType } from '../../TouchEventType';
|
37
38
|
import { ComposedGesture } from './gestureComposition';
|
@@ -63,6 +64,7 @@ const ALLOWED_PROPS = [
|
|
63
64
|
...longPressGestureHandlerProps,
|
64
65
|
...forceTouchGestureHandlerProps,
|
65
66
|
...flingGestureHandlerProps,
|
67
|
+
...hoverGestureHandlerProps,
|
66
68
|
...nativeViewGestureHandlerProps,
|
67
69
|
];
|
68
70
|
|
@@ -6,6 +6,7 @@ import {
|
|
6
6
|
GestureTouchEvent,
|
7
7
|
GestureStateChangeEvent,
|
8
8
|
GestureUpdateEvent,
|
9
|
+
ActiveCursor,
|
9
10
|
} from '../gestureHandlerCommon';
|
10
11
|
import { getNextHandlerTag } from '../handlersRegistry';
|
11
12
|
import { GestureStateManagerType } from './gestureStateManager';
|
@@ -250,6 +251,11 @@ export abstract class BaseGesture<
|
|
250
251
|
return this;
|
251
252
|
}
|
252
253
|
|
254
|
+
activeCursor(activeCursor: ActiveCursor) {
|
255
|
+
this.config.activeCursor = activeCursor;
|
256
|
+
return this;
|
257
|
+
}
|
258
|
+
|
253
259
|
runOnJS(runOnJS: boolean) {
|
254
260
|
this.config.runOnJS = runOnJS;
|
255
261
|
return this;
|
@@ -13,6 +13,7 @@ import { RotationGesture } from './rotationGesture';
|
|
13
13
|
import { TapGesture } from './tapGesture';
|
14
14
|
import { NativeGesture } from './nativeGesture';
|
15
15
|
import { ManualGesture } from './manualGesture';
|
16
|
+
import { HoverGesture } from './hoverGesture';
|
16
17
|
|
17
18
|
export const GestureObjects = {
|
18
19
|
Tap: () => {
|
@@ -51,6 +52,10 @@ export const GestureObjects = {
|
|
51
52
|
return new ManualGesture();
|
52
53
|
},
|
53
54
|
|
55
|
+
Hover: () => {
|
56
|
+
return new HoverGesture();
|
57
|
+
},
|
58
|
+
|
54
59
|
/**
|
55
60
|
* Builds a composed gesture consisting of gestures provided as parameters.
|
56
61
|
* The first one that becomes active cancels the rest of gestures.
|
@@ -0,0 +1,83 @@
|
|
1
|
+
import { BaseGestureConfig, ContinousBaseGesture } from './gesture';
|
2
|
+
import { GestureUpdateEvent } from '../gestureHandlerCommon';
|
3
|
+
|
4
|
+
export type HoverGestureHandlerEventPayload = {
|
5
|
+
x: number;
|
6
|
+
y: number;
|
7
|
+
absoluteX: number;
|
8
|
+
absoluteY: number;
|
9
|
+
};
|
10
|
+
|
11
|
+
export type HoverGestureChangeEventPayload = {
|
12
|
+
changeX: number;
|
13
|
+
changeY: number;
|
14
|
+
};
|
15
|
+
|
16
|
+
export enum HoverEffect {
|
17
|
+
NONE = 0,
|
18
|
+
LIFT = 1,
|
19
|
+
HIGHLIGHT = 2,
|
20
|
+
}
|
21
|
+
|
22
|
+
export interface HoverGestureConfig {
|
23
|
+
hoverEffect?: HoverEffect;
|
24
|
+
}
|
25
|
+
|
26
|
+
export const hoverGestureHandlerProps = ['hoverEffect'] as const;
|
27
|
+
|
28
|
+
function changeEventCalculator(
|
29
|
+
current: GestureUpdateEvent<HoverGestureHandlerEventPayload>,
|
30
|
+
previous?: GestureUpdateEvent<HoverGestureHandlerEventPayload>
|
31
|
+
) {
|
32
|
+
'worklet';
|
33
|
+
let changePayload: HoverGestureChangeEventPayload;
|
34
|
+
if (previous === undefined) {
|
35
|
+
changePayload = {
|
36
|
+
changeX: current.x,
|
37
|
+
changeY: current.y,
|
38
|
+
};
|
39
|
+
} else {
|
40
|
+
changePayload = {
|
41
|
+
changeX: current.x - previous.x,
|
42
|
+
changeY: current.y - previous.y,
|
43
|
+
};
|
44
|
+
}
|
45
|
+
|
46
|
+
return { ...current, ...changePayload };
|
47
|
+
}
|
48
|
+
|
49
|
+
export class HoverGesture extends ContinousBaseGesture<
|
50
|
+
HoverGestureHandlerEventPayload,
|
51
|
+
HoverGestureChangeEventPayload
|
52
|
+
> {
|
53
|
+
public config: BaseGestureConfig & HoverGestureConfig = {};
|
54
|
+
|
55
|
+
constructor() {
|
56
|
+
super();
|
57
|
+
|
58
|
+
this.handlerName = 'HoverGestureHandler';
|
59
|
+
}
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Sets the visual hover effect.
|
63
|
+
* iOS only
|
64
|
+
*/
|
65
|
+
effect(effect: HoverEffect) {
|
66
|
+
this.config.hoverEffect = effect;
|
67
|
+
return this;
|
68
|
+
}
|
69
|
+
|
70
|
+
onChange(
|
71
|
+
callback: (
|
72
|
+
event: GestureUpdateEvent<
|
73
|
+
HoverGestureHandlerEventPayload & HoverGestureChangeEventPayload
|
74
|
+
>
|
75
|
+
) => void
|
76
|
+
) {
|
77
|
+
// @ts-ignore TS being overprotective, HoverGestureHandlerEventPayload is Record
|
78
|
+
this.handlers.changeEventCalculator = changeEventCalculator;
|
79
|
+
return super.onChange(callback);
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
export type HoverGestureType = InstanceType<typeof HoverGesture>;
|