react-native-gesture-handler 2.20.2 → 2.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RNGestureHandler.podspec +9 -0
- package/ReanimatedDrawerLayout/package.json +6 -0
- package/android/build.gradle +19 -0
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +6 -2
- package/android/src/main/java/com/swmansion/gesturehandler/core/RotationGestureDetector.kt +53 -21
- package/apple/RNGestureHandlerPointerTracker.m +4 -2
- package/lib/commonjs/RNGestureHandlerModule.web.js +15 -2
- package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/commonjs/components/Pressable/Pressable.js +2 -6
- package/lib/commonjs/components/Pressable/Pressable.js.map +1 -1
- package/lib/commonjs/components/ReanimatedDrawerLayout.js +389 -0
- package/lib/commonjs/components/ReanimatedDrawerLayout.js.map +1 -0
- package/lib/commonjs/components/ReanimatedSwipeable.js +117 -148
- package/lib/commonjs/components/ReanimatedSwipeable.js.map +1 -1
- package/lib/commonjs/findNodeHandle.js +12 -0
- package/lib/commonjs/findNodeHandle.js.map +1 -0
- package/lib/commonjs/findNodeHandle.web.js +40 -0
- package/lib/commonjs/findNodeHandle.web.js.map +1 -0
- package/lib/commonjs/handlers/createHandler.js +4 -2
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/Wrap.web.js +51 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/Wrap.web.js.map +1 -0
- package/lib/commonjs/handlers/gestures/GestureDetector/index.js +3 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/index.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/useDetectorUpdater.js +5 -3
- package/lib/commonjs/handlers/gestures/GestureDetector/useDetectorUpdater.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/useViewRefHandler.js +4 -2
- package/lib/commonjs/handlers/gestures/GestureDetector/useViewRefHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/GestureHandler.js +4 -0
- package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/PanGestureHandler.js +59 -0
- package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/web/interfaces.js +10 -1
- package/lib/commonjs/web/interfaces.js.map +1 -1
- package/lib/commonjs/web/tools/EventManager.js +6 -0
- package/lib/commonjs/web/tools/EventManager.js.map +1 -1
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js +1 -3
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js +5 -2
- package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js.map +1 -1
- package/lib/commonjs/web/tools/KeyboardEventManager.js +2 -2
- package/lib/commonjs/web/tools/KeyboardEventManager.js.map +1 -1
- package/lib/commonjs/web/tools/PointerTracker.js +6 -30
- package/lib/commonjs/web/tools/PointerTracker.js.map +1 -1
- package/lib/commonjs/web/tools/WheelEventManager.js +74 -0
- package/lib/commonjs/web/tools/WheelEventManager.js.map +1 -0
- package/lib/commonjs/web/utils.js +16 -0
- package/lib/commonjs/web/utils.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.web.js +16 -3
- package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/module/components/Pressable/Pressable.js +2 -6
- package/lib/module/components/Pressable/Pressable.js.map +1 -1
- package/lib/module/components/ReanimatedDrawerLayout.js +365 -0
- package/lib/module/components/ReanimatedDrawerLayout.js.map +1 -0
- package/lib/module/components/ReanimatedSwipeable.js +119 -145
- package/lib/module/components/ReanimatedSwipeable.js.map +1 -1
- package/lib/module/findNodeHandle.js +3 -0
- package/lib/module/findNodeHandle.js.map +1 -0
- package/lib/module/findNodeHandle.web.js +32 -0
- package/lib/module/findNodeHandle.web.js.map +1 -0
- package/lib/module/handlers/createHandler.js +2 -1
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/Wrap.web.js +34 -0
- package/lib/module/handlers/gestures/GestureDetector/Wrap.web.js.map +1 -0
- package/lib/module/handlers/gestures/GestureDetector/index.js +2 -1
- package/lib/module/handlers/gestures/GestureDetector/index.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js +2 -2
- package/lib/module/handlers/gestures/GestureDetector/useDetectorUpdater.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/useViewRefHandler.js +1 -1
- package/lib/module/handlers/gestures/GestureDetector/useViewRefHandler.js.map +1 -1
- package/lib/module/web/handlers/GestureHandler.js +4 -0
- package/lib/module/web/handlers/GestureHandler.js.map +1 -1
- package/lib/module/web/handlers/PanGestureHandler.js +58 -0
- package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/web/interfaces.js +8 -0
- package/lib/module/web/interfaces.js.map +1 -1
- package/lib/module/web/tools/EventManager.js +6 -0
- package/lib/module/web/tools/EventManager.js.map +1 -1
- package/lib/module/web/tools/GestureHandlerOrchestrator.js +1 -3
- package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/module/web/tools/GestureHandlerWebDelegate.js +3 -1
- package/lib/module/web/tools/GestureHandlerWebDelegate.js.map +1 -1
- package/lib/module/web/tools/KeyboardEventManager.js +2 -2
- package/lib/module/web/tools/KeyboardEventManager.js.map +1 -1
- package/lib/module/web/tools/PointerTracker.js +6 -30
- package/lib/module/web/tools/PointerTracker.js.map +1 -1
- package/lib/module/web/tools/WheelEventManager.js +60 -0
- package/lib/module/web/tools/WheelEventManager.js.map +1 -0
- package/lib/module/web/utils.js +15 -0
- package/lib/module/web/utils.js.map +1 -1
- package/lib/typescript/components/ReanimatedDrawerLayout.d.ts +162 -0
- package/lib/typescript/components/ReanimatedSwipeable.d.ts +22 -16
- package/lib/typescript/findNodeHandle.d.ts +2 -0
- package/lib/typescript/findNodeHandle.web.d.ts +2 -0
- package/lib/typescript/handlers/gestures/GestureDetector/Wrap.web.d.ts +7 -0
- package/lib/typescript/web/handlers/GestureHandler.d.ts +2 -1
- package/lib/typescript/web/handlers/PanGestureHandler.d.ts +5 -0
- package/lib/typescript/web/interfaces.d.ts +16 -0
- package/lib/typescript/web/tools/EventManager.d.ts +2 -0
- package/lib/typescript/web/tools/PointerTracker.d.ts +2 -8
- package/lib/typescript/web/tools/WheelEventManager.d.ts +11 -0
- package/lib/typescript/web/utils.d.ts +2 -1
- package/package.json +3 -2
- package/src/RNGestureHandlerModule.web.ts +23 -4
- package/src/components/Pressable/Pressable.tsx +2 -6
- package/src/components/ReanimatedDrawerLayout.tsx +741 -0
- package/src/components/ReanimatedSwipeable.tsx +361 -305
- package/src/findNodeHandle.ts +3 -0
- package/src/findNodeHandle.web.ts +35 -0
- package/src/handlers/createHandler.tsx +2 -1
- package/src/handlers/gestures/GestureDetector/Wrap.web.tsx +44 -0
- package/src/handlers/gestures/GestureDetector/index.tsx +2 -1
- package/src/handlers/gestures/GestureDetector/useDetectorUpdater.ts +1 -1
- package/src/handlers/gestures/GestureDetector/useViewRefHandler.ts +1 -1
- package/src/web/handlers/GestureHandler.ts +5 -1
- package/src/web/handlers/PanGestureHandler.ts +69 -1
- package/src/web/interfaces.ts +17 -0
- package/src/web/tools/EventManager.ts +4 -0
- package/src/web/tools/GestureHandlerOrchestrator.ts +1 -7
- package/src/web/tools/GestureHandlerWebDelegate.ts +3 -1
- package/src/web/tools/KeyboardEventManager.ts +2 -2
- package/src/web/tools/PointerTracker.ts +6 -28
- package/src/web/tools/WheelEventManager.ts +48 -0
- package/src/web/utils.ts +47 -1
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { StatusBarAnimation, StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import { SharedValue } from 'react-native-reanimated';
|
|
4
|
+
import { UserSelect, ActiveCursor, MouseButton } from '../handlers/gestureHandlerCommon';
|
|
5
|
+
export declare enum DrawerPosition {
|
|
6
|
+
LEFT = 0,
|
|
7
|
+
RIGHT = 1
|
|
8
|
+
}
|
|
9
|
+
export declare enum DrawerState {
|
|
10
|
+
IDLE = 0,
|
|
11
|
+
DRAGGING = 1,
|
|
12
|
+
SETTLING = 2
|
|
13
|
+
}
|
|
14
|
+
export declare enum DrawerType {
|
|
15
|
+
FRONT = 0,
|
|
16
|
+
BACK = 1,
|
|
17
|
+
SLIDE = 2
|
|
18
|
+
}
|
|
19
|
+
export declare enum DrawerLockMode {
|
|
20
|
+
UNLOCKED = 0,
|
|
21
|
+
LOCKED_CLOSED = 1,
|
|
22
|
+
LOCKED_OPEN = 2
|
|
23
|
+
}
|
|
24
|
+
export declare enum DrawerKeyboardDismissMode {
|
|
25
|
+
NONE = 0,
|
|
26
|
+
ON_DRAG = 1
|
|
27
|
+
}
|
|
28
|
+
export interface DrawerLayoutProps {
|
|
29
|
+
/**
|
|
30
|
+
* This attribute is present in the native android implementation already and is one
|
|
31
|
+
* of the required params. The gesture handler version of DrawerLayout makes it
|
|
32
|
+
* possible for the function passed as `renderNavigationView` to take an
|
|
33
|
+
* Animated value as a parameter that indicates the progress of drawer
|
|
34
|
+
* opening/closing animation (progress value is 0 when closed and 1 when
|
|
35
|
+
* opened). This can be used by the drawer component to animated its children
|
|
36
|
+
* while the drawer is opening or closing.
|
|
37
|
+
*/
|
|
38
|
+
renderNavigationView: (progressAnimatedValue: SharedValue<number>) => ReactNode;
|
|
39
|
+
/**
|
|
40
|
+
* Determines the side from which the drawer will open.
|
|
41
|
+
*/
|
|
42
|
+
drawerPosition?: DrawerPosition;
|
|
43
|
+
/**
|
|
44
|
+
* Width of the drawer.
|
|
45
|
+
*/
|
|
46
|
+
drawerWidth?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Background color of the drawer.
|
|
49
|
+
*/
|
|
50
|
+
drawerBackgroundColor?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Specifies the lock mode of the drawer.
|
|
53
|
+
* Programatic opening/closing isn't affected by the lock mode. Defaults to `UNLOCKED`.
|
|
54
|
+
* - `UNLOCKED` - the drawer will respond to gestures.
|
|
55
|
+
* - `LOCKED_CLOSED` - the drawer will move freely until it settles in a closed position, then the gestures will be disabled.
|
|
56
|
+
* - `LOCKED_OPEN` - the drawer will move freely until it settles in an opened position, then the gestures will be disabled.
|
|
57
|
+
*/
|
|
58
|
+
drawerLockMode?: DrawerLockMode;
|
|
59
|
+
/**
|
|
60
|
+
* Determines if system keyboard should be closed upon dragging the drawer.
|
|
61
|
+
*/
|
|
62
|
+
keyboardDismissMode?: DrawerKeyboardDismissMode;
|
|
63
|
+
/**
|
|
64
|
+
* Called when the drawer is closed.
|
|
65
|
+
*/
|
|
66
|
+
onDrawerClose?: () => void;
|
|
67
|
+
/**
|
|
68
|
+
* Called when the drawer is opened.
|
|
69
|
+
*/
|
|
70
|
+
onDrawerOpen?: () => void;
|
|
71
|
+
/**
|
|
72
|
+
* Called when the status of the drawer changes.
|
|
73
|
+
*/
|
|
74
|
+
onDrawerStateChanged?: (newState: DrawerState, drawerWillShow: boolean) => void;
|
|
75
|
+
/**
|
|
76
|
+
* Type of animation that will play when opening the drawer.
|
|
77
|
+
*/
|
|
78
|
+
drawerType?: DrawerType;
|
|
79
|
+
/**
|
|
80
|
+
* Defines how far from the edge of the content view the gesture should
|
|
81
|
+
* activate.
|
|
82
|
+
*/
|
|
83
|
+
edgeWidth?: number;
|
|
84
|
+
/**
|
|
85
|
+
* Minimal distance to swipe before the drawer starts moving.
|
|
86
|
+
*/
|
|
87
|
+
minSwipeDistance?: number;
|
|
88
|
+
/**
|
|
89
|
+
* When set to true Drawer component will use
|
|
90
|
+
* {@link https://reactnative.dev/docs/statusbar StatusBar} API to hide the OS
|
|
91
|
+
* status bar whenever the drawer is pulled or when its in an "open" state.
|
|
92
|
+
*/
|
|
93
|
+
hideStatusBar?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* @default 'slide'
|
|
96
|
+
*
|
|
97
|
+
* Can be used when hideStatusBar is set to true and will select the animation
|
|
98
|
+
* used for hiding/showing the status bar. See
|
|
99
|
+
* {@link https://reactnative.dev/docs/statusbar StatusBar} documentation for
|
|
100
|
+
* more details
|
|
101
|
+
*/
|
|
102
|
+
statusBarAnimation?: StatusBarAnimation;
|
|
103
|
+
/**
|
|
104
|
+
* @default 'rgba(0, 0, 0, 0.7)'
|
|
105
|
+
*
|
|
106
|
+
* Color of the background overlay.
|
|
107
|
+
* Animated from `0%` to `100%` as the drawer opens.
|
|
108
|
+
*/
|
|
109
|
+
overlayColor?: string;
|
|
110
|
+
/**
|
|
111
|
+
* Style wrapping the content.
|
|
112
|
+
*/
|
|
113
|
+
contentContainerStyle?: StyleProp<ViewStyle>;
|
|
114
|
+
/**
|
|
115
|
+
* Style wrapping the drawer.
|
|
116
|
+
*/
|
|
117
|
+
drawerContainerStyle?: StyleProp<ViewStyle>;
|
|
118
|
+
/**
|
|
119
|
+
* Enables two-finger gestures on supported devices, for example iPads with
|
|
120
|
+
* trackpads. If not enabled the gesture will require click + drag, with
|
|
121
|
+
* `enableTrackpadTwoFingerGesture` swiping with two fingers will also trigger
|
|
122
|
+
* the gesture.
|
|
123
|
+
*/
|
|
124
|
+
enableTrackpadTwoFingerGesture?: boolean;
|
|
125
|
+
onDrawerSlide?: (position: number) => void;
|
|
126
|
+
/**
|
|
127
|
+
* Elements that will be rendered inside the content view.
|
|
128
|
+
*/
|
|
129
|
+
children?: ReactNode | ((openValue?: SharedValue<number>) => ReactNode);
|
|
130
|
+
/**
|
|
131
|
+
* @default 'none'
|
|
132
|
+
* Sets whether the text inside both the drawer and the context window can be selected.
|
|
133
|
+
* Values: 'none' | 'text' | 'auto'
|
|
134
|
+
*/
|
|
135
|
+
userSelect?: UserSelect;
|
|
136
|
+
/**
|
|
137
|
+
* @default 'auto'
|
|
138
|
+
* Sets the displayed cursor pictogram when the drawer is being dragged.
|
|
139
|
+
* Values: see CSS cursor values
|
|
140
|
+
*/
|
|
141
|
+
activeCursor?: ActiveCursor;
|
|
142
|
+
/**
|
|
143
|
+
* @default 'MouseButton.LEFT'
|
|
144
|
+
* Allows to choose which mouse button should underlying pan handler react to.
|
|
145
|
+
*/
|
|
146
|
+
mouseButton?: MouseButton;
|
|
147
|
+
/**
|
|
148
|
+
* @default 'false if MouseButton.RIGHT is specified'
|
|
149
|
+
* Allows to enable/disable context menu.
|
|
150
|
+
*/
|
|
151
|
+
enableContextMenu?: boolean;
|
|
152
|
+
}
|
|
153
|
+
export type DrawerMovementOption = {
|
|
154
|
+
initialVelocity?: number;
|
|
155
|
+
animationSpeed?: number;
|
|
156
|
+
};
|
|
157
|
+
export interface DrawerLayoutMethods {
|
|
158
|
+
openDrawer: (options?: DrawerMovementOption) => void;
|
|
159
|
+
closeDrawer: (options?: DrawerMovementOption) => void;
|
|
160
|
+
}
|
|
161
|
+
declare const DrawerLayout: React.ForwardRefExoticComponent<DrawerLayoutProps & React.RefAttributes<DrawerLayoutMethods>>;
|
|
162
|
+
export default DrawerLayout;
|
|
@@ -3,6 +3,10 @@ import type { PanGestureHandlerProps } from '../handlers/PanGestureHandler';
|
|
|
3
3
|
import { SharedValue } from 'react-native-reanimated';
|
|
4
4
|
import { StyleProp, ViewStyle } from 'react-native';
|
|
5
5
|
type SwipeableExcludes = Exclude<keyof PanGestureHandlerProps, 'onGestureEvent' | 'onHandlerStateChange'>;
|
|
6
|
+
declare enum SwipeDirection {
|
|
7
|
+
LEFT = "left",
|
|
8
|
+
RIGHT = "right"
|
|
9
|
+
}
|
|
6
10
|
export interface SwipeableProps extends Pick<PanGestureHandlerProps, SwipeableExcludes> {
|
|
7
11
|
/**
|
|
8
12
|
* Enables two-finger gestures on supported devices, for example iPads with
|
|
@@ -61,47 +65,49 @@ export interface SwipeableProps extends Pick<PanGestureHandlerProps, SwipeableEx
|
|
|
61
65
|
/**
|
|
62
66
|
* Called when action panel gets open (either right or left).
|
|
63
67
|
*/
|
|
64
|
-
onSwipeableOpen?: (direction:
|
|
68
|
+
onSwipeableOpen?: (direction: SwipeDirection.LEFT | SwipeDirection.RIGHT) => void;
|
|
65
69
|
/**
|
|
66
70
|
* Called when action panel is closed.
|
|
67
71
|
*/
|
|
68
|
-
onSwipeableClose?: (direction:
|
|
72
|
+
onSwipeableClose?: (direction: SwipeDirection.LEFT | SwipeDirection.RIGHT) => void;
|
|
69
73
|
/**
|
|
70
74
|
* Called when action panel starts animating on open (either right or left).
|
|
71
75
|
*/
|
|
72
|
-
onSwipeableWillOpen?: (direction:
|
|
76
|
+
onSwipeableWillOpen?: (direction: SwipeDirection.LEFT | SwipeDirection.RIGHT) => void;
|
|
73
77
|
/**
|
|
74
78
|
* Called when action panel starts animating on close.
|
|
75
79
|
*/
|
|
76
|
-
onSwipeableWillClose?: (direction:
|
|
80
|
+
onSwipeableWillClose?: (direction: SwipeDirection.LEFT | SwipeDirection.RIGHT) => void;
|
|
77
81
|
/**
|
|
78
82
|
* Called when action panel starts being shown on dragging to open.
|
|
79
83
|
*/
|
|
80
|
-
onSwipeableOpenStartDrag?: (direction:
|
|
84
|
+
onSwipeableOpenStartDrag?: (direction: SwipeDirection.LEFT | SwipeDirection.RIGHT) => void;
|
|
81
85
|
/**
|
|
82
86
|
* Called when action panel starts being shown on dragging to close.
|
|
83
87
|
*/
|
|
84
|
-
onSwipeableCloseStartDrag?: (direction:
|
|
88
|
+
onSwipeableCloseStartDrag?: (direction: SwipeDirection.LEFT | SwipeDirection.RIGHT) => void;
|
|
85
89
|
/**
|
|
90
|
+
* `progress`: Equals `0` when `swipeable` is closed, `1` when `swipeable` is opened.
|
|
91
|
+
* - When the element overshoots it's opened position the value tends towards `Infinity`.
|
|
92
|
+
* - Goes back to `1` when `swipeable` is released.
|
|
86
93
|
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* progressAnimatedValue: [0, 1] dragAnimatedValue: [0, +]
|
|
94
|
+
* `translation`: a horizontal offset of the `swipeable` relative to its closed position.\
|
|
95
|
+
* `swipeableMethods`: provides an object exposing methods for controlling the `swipeable`.
|
|
91
96
|
*
|
|
92
97
|
* To support `rtl` flexbox layouts use `flexDirection` styling.
|
|
93
98
|
* */
|
|
94
|
-
renderLeftActions?: (
|
|
99
|
+
renderLeftActions?: (progress: SharedValue<number>, translation: SharedValue<number>, swipeableMethods: SwipeableMethods) => React.ReactNode;
|
|
95
100
|
/**
|
|
101
|
+
* `progress`: Equals `0` when `swipeable` is closed, `1` when `swipeable` is opened.
|
|
102
|
+
* - When the element overshoots it's opened position the value tends towards `Infinity`.
|
|
103
|
+
* - Goes back to `1` when `swipeable` is released.
|
|
96
104
|
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* progressAnimatedValue: [0, 1] dragAnimatedValue: [0, -]
|
|
105
|
+
* `translation`: a horizontal offset of the `swipeable` relative to its closed position.\
|
|
106
|
+
* `swipeableMethods`: provides an object exposing methods for controlling the `swipeable`.
|
|
101
107
|
*
|
|
102
108
|
* To support `rtl` flexbox layouts use `flexDirection` styling.
|
|
103
109
|
* */
|
|
104
|
-
renderRightActions?: (
|
|
110
|
+
renderRightActions?: (progress: SharedValue<number>, translation: SharedValue<number>, swipeableMethods: SwipeableMethods) => React.ReactNode;
|
|
105
111
|
animationOptions?: Record<string, unknown>;
|
|
106
112
|
/**
|
|
107
113
|
* Style object for the container (`Animated.View`), for example to override
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const Wrap: React.ForwardRefExoticComponent<{
|
|
3
|
+
children?: React.ReactNode;
|
|
4
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
5
|
+
export declare const AnimatedWrap: React.ForwardRefExoticComponent<{
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -67,7 +67,8 @@ export default abstract class GestureHandler implements IGestureHandler {
|
|
|
67
67
|
protected onPointerOutOfBounds(event: AdaptedEvent): void;
|
|
68
68
|
protected onPointerMoveOver(_event: AdaptedEvent): void;
|
|
69
69
|
protected onPointerMoveOut(_event: AdaptedEvent): void;
|
|
70
|
-
|
|
70
|
+
protected onWheel(_event: AdaptedEvent): void;
|
|
71
|
+
protected tryToSendMoveEvent(out: boolean, event: AdaptedEvent): void;
|
|
71
72
|
protected tryToSendTouchEvent(event: AdaptedEvent): void;
|
|
72
73
|
sendTouchEvent(event: AdaptedEvent): void;
|
|
73
74
|
sendEvent: (newState: State, oldState: State) => void;
|
|
@@ -28,6 +28,9 @@ export default class PanGestureHandler extends GestureHandler {
|
|
|
28
28
|
private stylusData;
|
|
29
29
|
private activateAfterLongPress;
|
|
30
30
|
private activationTimeout;
|
|
31
|
+
private enableTrackpadTwoFingerGesture;
|
|
32
|
+
private endWheelTimeout;
|
|
33
|
+
private wheelDevice;
|
|
31
34
|
init(ref: number, propsRef: React.RefObject<unknown>): void;
|
|
32
35
|
updateGestureConfig({ enabled, ...props }: Config): void;
|
|
33
36
|
protected resetConfig(): void;
|
|
@@ -47,6 +50,8 @@ export default class PanGestureHandler extends GestureHandler {
|
|
|
47
50
|
protected onPointerRemove(event: AdaptedEvent): void;
|
|
48
51
|
protected onPointerMove(event: AdaptedEvent): void;
|
|
49
52
|
protected onPointerOutOfBounds(event: AdaptedEvent): void;
|
|
53
|
+
private scheduleWheelEnd;
|
|
54
|
+
protected onWheel(event: AdaptedEvent): void;
|
|
50
55
|
private shouldActivate;
|
|
51
56
|
private shouldFail;
|
|
52
57
|
private tryBegin;
|
|
@@ -58,6 +58,7 @@ export interface Config extends Record<string, ConfigArgs> {
|
|
|
58
58
|
shouldActivateOnStart?: boolean;
|
|
59
59
|
disallowInterruption?: boolean;
|
|
60
60
|
direction?: Directions;
|
|
61
|
+
enableTrackpadTwoFingerGesture?: boolean;
|
|
61
62
|
}
|
|
62
63
|
type NativeEventArgs = number | State | boolean | undefined;
|
|
63
64
|
interface NativeEvent extends Record<string, NativeEventArgs> {
|
|
@@ -120,6 +121,7 @@ export interface AdaptedEvent {
|
|
|
120
121
|
time: number;
|
|
121
122
|
button?: MouseButton;
|
|
122
123
|
stylusData?: StylusData;
|
|
124
|
+
wheelDeltaY?: number;
|
|
123
125
|
}
|
|
124
126
|
export declare enum EventTypes {
|
|
125
127
|
DOWN = 0,
|
|
@@ -138,4 +140,18 @@ export declare enum TouchEventType {
|
|
|
138
140
|
UP = 3,
|
|
139
141
|
CANCELLED = 4
|
|
140
142
|
}
|
|
143
|
+
export declare enum WheelDevice {
|
|
144
|
+
UNDETERMINED = 0,
|
|
145
|
+
MOUSE = 1,
|
|
146
|
+
TOUCHPAD = 2
|
|
147
|
+
}
|
|
148
|
+
export type GestureHandlerRef = {
|
|
149
|
+
viewTag: GestureHandlerRef;
|
|
150
|
+
current: HTMLElement;
|
|
151
|
+
};
|
|
152
|
+
export type SVGRef = {
|
|
153
|
+
elementRef: {
|
|
154
|
+
current: SVGElement;
|
|
155
|
+
};
|
|
156
|
+
};
|
|
141
157
|
export {};
|
|
@@ -19,6 +19,7 @@ export default abstract class EventManager<T> {
|
|
|
19
19
|
protected onPointerOutOfBounds(_event: AdaptedEvent): void;
|
|
20
20
|
protected onPointerMoveOver(_event: AdaptedEvent): void;
|
|
21
21
|
protected onPointerMoveOut(_event: AdaptedEvent): void;
|
|
22
|
+
protected onWheel(_event: AdaptedEvent): void;
|
|
22
23
|
setOnPointerDown(callback: PointerEventCallback): void;
|
|
23
24
|
setOnPointerAdd(callback: PointerEventCallback): void;
|
|
24
25
|
setOnPointerUp(callback: PointerEventCallback): void;
|
|
@@ -30,6 +31,7 @@ export default abstract class EventManager<T> {
|
|
|
30
31
|
setOnPointerOutOfBounds(callback: PointerEventCallback): void;
|
|
31
32
|
setOnPointerMoveOver(callback: PointerEventCallback): void;
|
|
32
33
|
setOnPointerMoveOut(callback: PointerEventCallback): void;
|
|
34
|
+
setOnWheel(callback: PointerEventCallback): void;
|
|
33
35
|
protected markAsInBounds(pointerId: number): void;
|
|
34
36
|
protected markAsOutOfBounds(pointerId: number): void;
|
|
35
37
|
resetManager(): void;
|
|
@@ -24,14 +24,8 @@ export default class PointerTracker {
|
|
|
24
24
|
x: number;
|
|
25
25
|
y: number;
|
|
26
26
|
};
|
|
27
|
-
getLastAbsoluteCoords(pointerId?: number):
|
|
28
|
-
|
|
29
|
-
y: number;
|
|
30
|
-
};
|
|
31
|
-
getLastRelativeCoords(pointerId?: number): {
|
|
32
|
-
x: number;
|
|
33
|
-
y: number;
|
|
34
|
-
};
|
|
27
|
+
getLastAbsoluteCoords(pointerId?: number): Point;
|
|
28
|
+
getLastRelativeCoords(pointerId?: number): Point;
|
|
35
29
|
getAbsoluteCoordsAverage(): {
|
|
36
30
|
x: number;
|
|
37
31
|
y: number;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import EventManager from './EventManager';
|
|
2
|
+
import { AdaptedEvent } from '../interfaces';
|
|
3
|
+
export default class WheelEventManager extends EventManager<HTMLElement> {
|
|
4
|
+
private wheelDelta;
|
|
5
|
+
private resetDelta;
|
|
6
|
+
private wheelCallback;
|
|
7
|
+
registerListeners(): void;
|
|
8
|
+
unregisterListeners(): void;
|
|
9
|
+
protected mapEvent(event: WheelEvent): AdaptedEvent;
|
|
10
|
+
resetManager(): void;
|
|
11
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PointerType } from '../PointerType';
|
|
2
|
-
import type { Point, StylusData } from './interfaces';
|
|
2
|
+
import type { GestureHandlerRef, Point, StylusData, SVGRef } from './interfaces';
|
|
3
3
|
export declare function isPointerInBounds(view: HTMLElement, { x, y }: Point): boolean;
|
|
4
4
|
export declare const PointerTypeMapping: Map<string, PointerType>;
|
|
5
5
|
export declare const degToRad: (degrees: number) => number;
|
|
@@ -9,3 +9,4 @@ export declare function calculateViewScale(view: HTMLElement): {
|
|
|
9
9
|
scaleY: number;
|
|
10
10
|
};
|
|
11
11
|
export declare function tryExtractStylusData(event: PointerEvent): StylusData | undefined;
|
|
12
|
+
export declare function isRNSVGElement(viewRef: SVGRef | GestureHandlerRef): boolean;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-gesture-handler",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.21.1",
|
|
4
|
+
"description": "Declarative API exposing native platform touch and gesture system to React Native",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepare": "bob build && husky install",
|
|
7
7
|
"test": "jest",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"ReanimatedSwipeable/",
|
|
45
45
|
"jest-utils/",
|
|
46
46
|
"DrawerLayout/",
|
|
47
|
+
"ReanimatedDrawerLayout/",
|
|
47
48
|
"README.md",
|
|
48
49
|
"jestSetup.js",
|
|
49
50
|
"RNGestureHandler.podspec"
|
|
@@ -9,6 +9,13 @@ import NodeManager from './web/tools/NodeManager';
|
|
|
9
9
|
import * as HammerNodeManager from './web_hammer/NodeManager';
|
|
10
10
|
import { GestureHandlerWebDelegate } from './web/tools/GestureHandlerWebDelegate';
|
|
11
11
|
|
|
12
|
+
// init method is called inside attachGestureHandler function. However, this function may
|
|
13
|
+
// fail when received view is not valid HTML element. On the other hand, dropGestureHandler
|
|
14
|
+
// will be called even if attach failed, which will result in crash.
|
|
15
|
+
//
|
|
16
|
+
// We use this flag to check whether or not dropGestureHandler should be called.
|
|
17
|
+
let shouldPreventDrop = false;
|
|
18
|
+
|
|
12
19
|
export default {
|
|
13
20
|
handleSetJSResponder(tag: number, blockNativeResponder: boolean) {
|
|
14
21
|
console.warn('handleSetJSResponder: ', tag, blockNativeResponder);
|
|
@@ -60,10 +67,18 @@ export default {
|
|
|
60
67
|
_actionType: ActionType,
|
|
61
68
|
propsRef: React.RefObject<unknown>
|
|
62
69
|
) {
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
70
|
+
if (!(newView instanceof Element || newView instanceof React.Component)) {
|
|
71
|
+
shouldPreventDrop = true;
|
|
72
|
+
|
|
73
|
+
const handler = isNewWebImplementationEnabled()
|
|
74
|
+
? NodeManager.getHandler(handlerTag)
|
|
75
|
+
: HammerNodeManager.getHandler(handlerTag);
|
|
76
|
+
|
|
77
|
+
const handlerName = handler.constructor.name;
|
|
78
|
+
|
|
79
|
+
throw new Error(
|
|
80
|
+
`${handlerName} with tag ${handlerTag} received child that is not valid HTML element.`
|
|
81
|
+
);
|
|
67
82
|
}
|
|
68
83
|
|
|
69
84
|
if (isNewWebImplementationEnabled()) {
|
|
@@ -94,6 +109,10 @@ export default {
|
|
|
94
109
|
}
|
|
95
110
|
},
|
|
96
111
|
dropGestureHandler(handlerTag: number) {
|
|
112
|
+
if (shouldPreventDrop) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
97
116
|
if (isNewWebImplementationEnabled()) {
|
|
98
117
|
NodeManager.dropGestureHandler(handlerTag);
|
|
99
118
|
} else {
|
|
@@ -302,7 +302,7 @@ export default function Pressable(props: PressableProps) {
|
|
|
302
302
|
Gesture.Native()
|
|
303
303
|
.onBegin(() => {
|
|
304
304
|
// Android sets BEGAN state on press down
|
|
305
|
-
if (Platform.OS === 'android') {
|
|
305
|
+
if (Platform.OS === 'android' || Platform.OS === 'macos') {
|
|
306
306
|
isTouchPropagationAllowed.current = true;
|
|
307
307
|
}
|
|
308
308
|
})
|
|
@@ -358,11 +358,7 @@ export default function Pressable(props: PressableProps) {
|
|
|
358
358
|
gesture.enabled(isPressableEnabled);
|
|
359
359
|
gesture.runOnJS(true);
|
|
360
360
|
gesture.hitSlop(appliedHitSlop);
|
|
361
|
-
gesture.shouldCancelWhenOutside(false);
|
|
362
|
-
|
|
363
|
-
if (Platform.OS !== 'web') {
|
|
364
|
-
gesture.shouldCancelWhenOutside(true);
|
|
365
|
-
}
|
|
361
|
+
gesture.shouldCancelWhenOutside(Platform.OS === 'web' ? false : true);
|
|
366
362
|
}
|
|
367
363
|
|
|
368
364
|
// Uses different hitSlop, to activate on hitSlop area instead of pressRetentionOffset area
|