react-native-gesture-handler 2.27.2 → 2.29.0
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/README.md +1 -0
- package/RNGestureHandler.podspec +3 -2
- package/android/build.gradle +3 -10
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +8 -13
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +2 -2
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt +2 -2
- package/android/src/main/jni/CMakeLists.txt +5 -0
- package/android/src/main/jni/cpp-adapter.cpp +6 -0
- package/apple/Handlers/RNFlingHandler.m +7 -1
- package/apple/Handlers/RNLongPressHandler.m +6 -4
- package/apple/Handlers/RNPanHandler.m +4 -1
- package/apple/Handlers/RNTapHandler.m +2 -1
- package/apple/RNGestureHandlerModule.mm +5 -0
- package/lib/commonjs/components/Pressable/Pressable.js +12 -4
- package/lib/commonjs/components/Pressable/Pressable.js.map +1 -1
- package/lib/commonjs/components/Pressable/stateDefinitions.js +1 -0
- package/lib/commonjs/components/Pressable/stateDefinitions.js.map +1 -1
- package/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeable.js +9 -9
- package/lib/commonjs/components/ReanimatedSwipeable/ReanimatedSwipeable.js.map +1 -1
- package/lib/commonjs/components/gestureHandlerRootHOC.js +4 -1
- package/lib/commonjs/components/gestureHandlerRootHOC.js.map +1 -1
- package/lib/commonjs/handlers/NativeViewGestureHandler.js +32 -0
- package/lib/commonjs/handlers/NativeViewGestureHandler.js.map +1 -0
- package/lib/commonjs/handlers/createHandler.js +1 -1
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/index.js +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/index.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/useAnimatedGesture.js +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector/useAnimatedGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/flingGesture.js +1 -1
- package/lib/commonjs/handlers/gestures/gestureStateManager.js +1 -0
- package/lib/commonjs/handlers/gestures/gestureStateManager.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gestureStateManager.web.js +1 -0
- package/lib/commonjs/handlers/gestures/gestureStateManager.web.js.map +1 -1
- package/lib/commonjs/handlers/gestures/nativeGesture.js +34 -0
- package/lib/commonjs/handlers/gestures/nativeGesture.js.map +1 -0
- package/lib/commonjs/specs/NativeRNGestureHandlerModule.js +9 -0
- package/lib/commonjs/specs/NativeRNGestureHandlerModule.js.map +1 -0
- package/lib/commonjs/web/handlers/GestureHandler.js +4 -2
- package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/handlers/{NativeViewGestureHandler.ts → NativeViewGestureHandler.js} +53 -87
- package/lib/commonjs/web/handlers/NativeViewGestureHandler.js.map +1 -0
- package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js +0 -5
- package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js.map +1 -1
- package/lib/commonjs/web/tools/KeyboardEventManager.js +34 -8
- package/lib/commonjs/web/tools/KeyboardEventManager.js.map +1 -1
- package/lib/commonjs/web_hammer/NativeViewGestureHandler.js +57 -0
- package/lib/commonjs/web_hammer/NativeViewGestureHandler.js.map +1 -0
- package/lib/module/components/Pressable/Pressable.js +12 -4
- package/lib/module/components/Pressable/Pressable.js.map +1 -1
- package/lib/module/components/Pressable/stateDefinitions.js +1 -0
- package/lib/module/components/Pressable/stateDefinitions.js.map +1 -1
- package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeable.js +1 -1
- package/lib/module/components/ReanimatedSwipeable/ReanimatedSwipeable.js.map +1 -1
- package/lib/module/components/gestureHandlerRootHOC.js +5 -0
- package/lib/module/components/gestureHandlerRootHOC.js.map +1 -1
- package/lib/module/handlers/NativeViewGestureHandler.js +27 -0
- package/lib/module/handlers/NativeViewGestureHandler.js.map +1 -0
- package/lib/module/handlers/createHandler.js +1 -1
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/index.js +1 -1
- package/lib/module/handlers/gestures/GestureDetector/index.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector/useAnimatedGesture.js +1 -1
- package/lib/module/handlers/gestures/GestureDetector/useAnimatedGesture.js.map +1 -1
- package/lib/module/handlers/gestures/flingGesture.js +1 -1
- package/lib/module/handlers/gestures/gestureStateManager.js +1 -0
- package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -1
- package/lib/module/handlers/gestures/gestureStateManager.web.js +1 -0
- package/lib/module/handlers/gestures/gestureStateManager.web.js.map +1 -1
- package/lib/module/handlers/gestures/nativeGesture.js +29 -0
- package/lib/module/handlers/gestures/nativeGesture.js.map +1 -0
- package/lib/module/specs/NativeRNGestureHandlerModule.js +5 -0
- package/lib/module/specs/NativeRNGestureHandlerModule.js.map +1 -0
- package/lib/module/web/handlers/GestureHandler.js +4 -2
- package/lib/module/web/handlers/GestureHandler.js.map +1 -1
- package/lib/module/web/handlers/{NativeViewGestureHandler.ts → NativeViewGestureHandler.js} +36 -76
- package/lib/module/web/handlers/NativeViewGestureHandler.js.map +1 -0
- package/lib/module/web/tools/GestureHandlerWebDelegate.js +0 -5
- package/lib/module/web/tools/GestureHandlerWebDelegate.js.map +1 -1
- package/lib/module/web/tools/KeyboardEventManager.js +34 -8
- package/lib/module/web/tools/KeyboardEventManager.js.map +1 -1
- package/lib/module/web_hammer/NativeViewGestureHandler.js +51 -0
- package/lib/module/web_hammer/NativeViewGestureHandler.js.map +1 -0
- package/lib/typescript/components/Pressable/Pressable.d.ts.map +1 -1
- package/lib/typescript/components/Pressable/stateDefinitions.d.ts +2 -1
- package/lib/typescript/components/Pressable/stateDefinitions.d.ts.map +1 -1
- package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeable.d.ts +1 -1
- package/lib/typescript/components/ReanimatedSwipeable/ReanimatedSwipeable.d.ts.map +1 -1
- package/lib/typescript/components/gestureHandlerRootHOC.d.ts +4 -0
- package/lib/typescript/components/gestureHandlerRootHOC.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/GestureDetector/useAnimatedGesture.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/flingGesture.d.ts +1 -1
- package/lib/typescript/handlers/gestures/gestureStateManager.d.ts +2 -0
- package/lib/typescript/handlers/gestures/gestureStateManager.d.ts.map +1 -1
- package/lib/typescript/handlers/gestures/gestureStateManager.web.d.ts.map +1 -1
- package/lib/typescript/web/handlers/GestureHandler.d.ts.map +1 -1
- package/lib/typescript/web/tools/GestureHandlerWebDelegate.d.ts.map +1 -1
- package/lib/typescript/web/tools/KeyboardEventManager.d.ts +6 -3
- package/lib/typescript/web/tools/KeyboardEventManager.d.ts.map +1 -1
- package/package.json +8 -7
- package/scripts/gesture_handler_utils.rb +25 -0
- package/src/components/Pressable/Pressable.tsx +12 -4
- package/src/components/Pressable/stateDefinitions.ts +1 -0
- package/src/components/ReanimatedSwipeable/ReanimatedSwipeable.tsx +5 -1
- package/src/components/gestureHandlerRootHOC.tsx +4 -0
- package/src/handlers/createHandler.tsx +1 -1
- package/src/handlers/gestures/GestureDetector/index.tsx +1 -1
- package/src/handlers/gestures/GestureDetector/useAnimatedGesture.ts +4 -1
- package/src/handlers/gestures/flingGesture.ts +1 -1
- package/src/handlers/gestures/gestureStateManager.ts +4 -0
- package/src/handlers/gestures/gestureStateManager.web.ts +2 -0
- package/src/web/handlers/GestureHandler.ts +7 -3
- package/src/web/tools/GestureHandlerWebDelegate.ts +0 -5
- package/src/web/tools/KeyboardEventManager.ts +50 -8
- package/lib/commonjs/handlers/NativeViewGestureHandler.ts +0 -59
- package/lib/commonjs/handlers/gestures/nativeGesture.ts +0 -33
- package/lib/commonjs/specs/NativeRNGestureHandlerModule.ts +0 -26
- package/lib/commonjs/web_hammer/NativeViewGestureHandler.ts +0 -47
- package/lib/module/handlers/NativeViewGestureHandler.ts +0 -59
- package/lib/module/handlers/gestures/nativeGesture.ts +0 -33
- package/lib/module/specs/NativeRNGestureHandlerModule.ts +0 -26
- package/lib/module/web_hammer/NativeViewGestureHandler.ts +0 -47
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
def try_to_parse_react_native_package_json(node_modules_dir)
|
|
2
|
+
react_native_package_json_path = File.join(node_modules_dir, 'react-native/package.json')
|
|
3
|
+
|
|
4
|
+
if !File.exist?(react_native_package_json_path)
|
|
5
|
+
return nil
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
return JSON.parse(File.read(react_native_package_json_path))
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def get_react_native_minor_version()
|
|
12
|
+
react_native_node_modules_dir = File.join(File.dirname(`cd "#{Pod::Config.instance.installation_root.to_s}" && node --print "require.resolve('react-native/package.json')"`), '..')
|
|
13
|
+
react_native_json = try_to_parse_react_native_package_json(react_native_node_modules_dir)
|
|
14
|
+
|
|
15
|
+
if react_native_json == nil
|
|
16
|
+
node_modules_dir = ENV["REACT_NATIVE_NODE_MODULES_DIR"]
|
|
17
|
+
react_native_json = try_to_parse_react_native_package_json(node_modules_dir)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
if react_native_json == nil
|
|
21
|
+
raise '[react-native-gesture-handler] Unable to recognize your `react-native` version. Please set environmental variable with `react-native` location: `export REACT_NATIVE_NODE_MODULES_DIR="<path to react-native>" && pod install`.'
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
return react_native_json['version'].split('.')[1].to_i
|
|
25
|
+
end
|
|
@@ -270,9 +270,13 @@ const Pressable = (props: PressableProps) => {
|
|
|
270
270
|
stateMachine.reset();
|
|
271
271
|
handlePressOut(pressableEvent, false);
|
|
272
272
|
})
|
|
273
|
-
.onFinalize(() => {
|
|
273
|
+
.onFinalize((_event, success) => {
|
|
274
274
|
if (Platform.OS === 'web') {
|
|
275
|
-
|
|
275
|
+
if (success) {
|
|
276
|
+
stateMachine.handleEvent(StateMachineEvent.FINALIZE);
|
|
277
|
+
} else {
|
|
278
|
+
stateMachine.handleEvent(StateMachineEvent.CANCEL);
|
|
279
|
+
}
|
|
276
280
|
handleFinalize();
|
|
277
281
|
}
|
|
278
282
|
}),
|
|
@@ -301,11 +305,15 @@ const Pressable = (props: PressableProps) => {
|
|
|
301
305
|
stateMachine.handleEvent(StateMachineEvent.NATIVE_START);
|
|
302
306
|
}
|
|
303
307
|
})
|
|
304
|
-
.onFinalize(() => {
|
|
308
|
+
.onFinalize((_event, success) => {
|
|
305
309
|
if (Platform.OS !== 'web') {
|
|
306
310
|
// On Web we use LongPress().onFinalize() instead of Native().onFinalize(),
|
|
307
311
|
// as Native cancels on mouse move, and LongPress does not.
|
|
308
|
-
|
|
312
|
+
if (success) {
|
|
313
|
+
stateMachine.handleEvent(StateMachineEvent.FINALIZE);
|
|
314
|
+
} else {
|
|
315
|
+
stateMachine.handleEvent(StateMachineEvent.CANCEL);
|
|
316
|
+
}
|
|
309
317
|
handleFinalize();
|
|
310
318
|
}
|
|
311
319
|
}),
|
|
@@ -11,7 +11,11 @@ import Animated, {
|
|
|
11
11
|
runOnUI,
|
|
12
12
|
useAnimatedStyle,
|
|
13
13
|
} from 'react-native-reanimated';
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
SwipeableProps,
|
|
16
|
+
SwipeableMethods,
|
|
17
|
+
SwipeDirection,
|
|
18
|
+
} from './ReanimatedSwipeableProps';
|
|
15
19
|
import { Gesture } from '../..';
|
|
16
20
|
import {
|
|
17
21
|
GestureStateChangeEvent,
|
|
@@ -3,6 +3,10 @@ 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
|
+
/**
|
|
7
|
+
* @deprecated `gestureHandlerRootHOC` is deprecated and will be removed in the future version of Gesture Handler.
|
|
8
|
+
* Use `GestureHandlerRootView` directly instead.
|
|
9
|
+
*/
|
|
6
10
|
export default function gestureHandlerRootHOC<P extends object>(
|
|
7
11
|
Component: React.ComponentType<P>,
|
|
8
12
|
containerStyles?: StyleProp<ViewStyle>
|
|
@@ -446,7 +446,7 @@ export default function createHandler<
|
|
|
446
446
|
if (__DEV__ && !this.context && !isTestEnv() && Platform.OS !== 'web') {
|
|
447
447
|
throw new Error(
|
|
448
448
|
name +
|
|
449
|
-
' must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/installation for more details.'
|
|
449
|
+
' must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/installation for more details.'
|
|
450
450
|
);
|
|
451
451
|
}
|
|
452
452
|
|
|
@@ -96,7 +96,7 @@ export const GestureDetector = (props: GestureDetectorProps) => {
|
|
|
96
96
|
const rootViewContext = useContext(GestureHandlerRootViewContext);
|
|
97
97
|
if (__DEV__ && !rootViewContext && !isTestEnv() && Platform.OS !== 'web') {
|
|
98
98
|
throw new Error(
|
|
99
|
-
'GestureDetector must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/installation for more details.'
|
|
99
|
+
'GestureDetector must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/installation for more details.'
|
|
100
100
|
);
|
|
101
101
|
}
|
|
102
102
|
|
|
@@ -163,7 +163,10 @@ export function useAnimatedGesture(
|
|
|
163
163
|
runWorklet(CALLBACK_TYPE.FINALIZE, gesture, event, false);
|
|
164
164
|
}
|
|
165
165
|
} else if (isTouchEvent(event)) {
|
|
166
|
-
if (
|
|
166
|
+
if (
|
|
167
|
+
!stateControllers[i] ||
|
|
168
|
+
stateControllers[i].handlerTag !== event.handlerTag
|
|
169
|
+
) {
|
|
167
170
|
stateControllers[i] = GestureStateManager.create(event.handlerTag);
|
|
168
171
|
}
|
|
169
172
|
|
|
@@ -23,7 +23,7 @@ export class FlingGesture extends BaseGesture<FlingGestureHandlerEventPayload> {
|
|
|
23
23
|
/**
|
|
24
24
|
* Expressed allowed direction of movement.
|
|
25
25
|
* Expected values are exported as constants in the Directions object.
|
|
26
|
-
* Arguments can be combined using `|` operator. Default value is set to `
|
|
26
|
+
* Arguments can be combined using `|` operator. Default value is set to `Directions.RIGHT`.
|
|
27
27
|
* @param direction
|
|
28
28
|
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/fling-gesture/#directionvalue-directions
|
|
29
29
|
*/
|
|
@@ -7,6 +7,8 @@ export interface GestureStateManagerType {
|
|
|
7
7
|
activate: () => void;
|
|
8
8
|
fail: () => void;
|
|
9
9
|
end: () => void;
|
|
10
|
+
/** @internal */
|
|
11
|
+
handlerTag: number;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
const warningMessage = tagMessage(
|
|
@@ -21,6 +23,8 @@ const setGestureState = Reanimated?.setGestureState;
|
|
|
21
23
|
function create(handlerTag: number): GestureStateManagerType {
|
|
22
24
|
'worklet';
|
|
23
25
|
return {
|
|
26
|
+
handlerTag,
|
|
27
|
+
|
|
24
28
|
begin: () => {
|
|
25
29
|
'worklet';
|
|
26
30
|
if (REANIMATED_AVAILABLE) {
|
|
@@ -566,9 +566,12 @@ export default abstract class GestureHandler implements IGestureHandler {
|
|
|
566
566
|
|
|
567
567
|
public updateGestureConfig({ enabled = true, ...props }: Config): void {
|
|
568
568
|
this._config = { enabled: enabled, ...props };
|
|
569
|
-
this.enabled = enabled;
|
|
570
569
|
|
|
571
|
-
this.
|
|
570
|
+
if (this.enabled !== enabled) {
|
|
571
|
+
this.delegate.onEnabledChange(enabled);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
this.enabled = enabled;
|
|
572
575
|
|
|
573
576
|
if (this.config.shouldCancelWhenOutside !== undefined) {
|
|
574
577
|
this.shouldCancelWhenOutside = this.config.shouldCancelWhenOutside;
|
|
@@ -682,8 +685,9 @@ export default abstract class GestureHandler implements IGestureHandler {
|
|
|
682
685
|
}
|
|
683
686
|
|
|
684
687
|
if (this.config.hitSlop.bottom !== undefined) {
|
|
685
|
-
bottom =
|
|
688
|
+
bottom = height + this.config.hitSlop.bottom;
|
|
686
689
|
}
|
|
690
|
+
|
|
687
691
|
if (this.config.hitSlop.width !== undefined) {
|
|
688
692
|
if (this.config.hitSlop.left !== undefined) {
|
|
689
693
|
right = left + this.config.hitSlop.width;
|
|
@@ -174,11 +174,6 @@ export class GestureHandlerWebDelegate
|
|
|
174
174
|
|
|
175
175
|
if (enabled) {
|
|
176
176
|
this.eventManagers.forEach((manager) => {
|
|
177
|
-
// It may look like managers will be registered twice when handler is mounted for the first time.
|
|
178
|
-
// However, `init` method is called AFTER `updateGestureConfig` - it means that delegate has not
|
|
179
|
-
// been initialized yet, so this code won't be executed.
|
|
180
|
-
//
|
|
181
|
-
// Also, because we use defined functions, not lambdas, they will not be registered multiple times.
|
|
182
177
|
manager.registerListeners();
|
|
183
178
|
});
|
|
184
179
|
} else {
|
|
@@ -3,25 +3,47 @@ import EventManager from './EventManager';
|
|
|
3
3
|
import { PointerType } from '../../PointerType';
|
|
4
4
|
|
|
5
5
|
export default class KeyboardEventManager extends EventManager<HTMLElement> {
|
|
6
|
-
private activationKeys = ['Enter', ' '];
|
|
7
|
-
private cancelationKeys = ['Tab'];
|
|
6
|
+
private static activationKeys = ['Enter', ' '];
|
|
7
|
+
private static cancelationKeys = ['Tab'];
|
|
8
8
|
private isPressed = false;
|
|
9
|
+
private static registeredStaticListeners = false;
|
|
10
|
+
private static instances: Set<KeyboardEventManager> = new Set();
|
|
11
|
+
|
|
12
|
+
private static keyUpStaticCallback = (event: KeyboardEvent): void => {
|
|
13
|
+
// We need a global listener, as in some cases, keyUp event gets stop-propagated.
|
|
14
|
+
// Then, if we used only component-level listeners the gesture would never end,
|
|
15
|
+
// causing other gestues to fail.
|
|
16
|
+
|
|
17
|
+
if (this.activationKeys.indexOf(event.key) === -1) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
this.instances.forEach((item) => {
|
|
22
|
+
item.onKeyUp(event);
|
|
23
|
+
});
|
|
24
|
+
};
|
|
9
25
|
|
|
10
26
|
private keyDownCallback = (event: KeyboardEvent): void => {
|
|
11
|
-
if (
|
|
27
|
+
if (
|
|
28
|
+
KeyboardEventManager.cancelationKeys.indexOf(event.key) !== -1 &&
|
|
29
|
+
this.isPressed
|
|
30
|
+
) {
|
|
12
31
|
this.dispatchEvent(event, EventTypes.CANCEL);
|
|
13
32
|
return;
|
|
14
33
|
}
|
|
15
34
|
|
|
16
|
-
if (
|
|
35
|
+
if (KeyboardEventManager.activationKeys.indexOf(event.key) === -1) {
|
|
17
36
|
return;
|
|
18
37
|
}
|
|
19
38
|
|
|
20
39
|
this.dispatchEvent(event, EventTypes.DOWN);
|
|
21
40
|
};
|
|
22
41
|
|
|
23
|
-
private
|
|
24
|
-
if (
|
|
42
|
+
private onKeyUp = (event: KeyboardEvent): void => {
|
|
43
|
+
if (
|
|
44
|
+
KeyboardEventManager.activationKeys.indexOf(event.key) === -1 ||
|
|
45
|
+
!this.isPressed
|
|
46
|
+
) {
|
|
25
47
|
return;
|
|
26
48
|
}
|
|
27
49
|
|
|
@@ -53,12 +75,32 @@ export default class KeyboardEventManager extends EventManager<HTMLElement> {
|
|
|
53
75
|
|
|
54
76
|
public registerListeners(): void {
|
|
55
77
|
this.view.addEventListener('keydown', this.keyDownCallback);
|
|
56
|
-
|
|
78
|
+
|
|
79
|
+
KeyboardEventManager.instances.add(this);
|
|
80
|
+
|
|
81
|
+
if (!KeyboardEventManager.registeredStaticListeners) {
|
|
82
|
+
KeyboardEventManager.registeredStaticListeners = true;
|
|
83
|
+
document.addEventListener(
|
|
84
|
+
'keyup',
|
|
85
|
+
KeyboardEventManager.keyUpStaticCallback,
|
|
86
|
+
{ capture: true }
|
|
87
|
+
);
|
|
88
|
+
}
|
|
57
89
|
}
|
|
58
90
|
|
|
59
91
|
public unregisterListeners(): void {
|
|
60
92
|
this.view.removeEventListener('keydown', this.keyDownCallback);
|
|
61
|
-
|
|
93
|
+
|
|
94
|
+
KeyboardEventManager.instances.delete(this);
|
|
95
|
+
|
|
96
|
+
if (KeyboardEventManager.instances.size === 0) {
|
|
97
|
+
document.removeEventListener(
|
|
98
|
+
'keyup',
|
|
99
|
+
KeyboardEventManager.keyUpStaticCallback,
|
|
100
|
+
{ capture: true }
|
|
101
|
+
);
|
|
102
|
+
KeyboardEventManager.registeredStaticListeners = false;
|
|
103
|
+
}
|
|
62
104
|
}
|
|
63
105
|
|
|
64
106
|
protected mapEvent(
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { NativeViewGestureHandlerPayload } from './GestureHandlerEventPayload';
|
|
2
|
-
import createHandler from './createHandler';
|
|
3
|
-
import {
|
|
4
|
-
BaseGestureHandlerProps,
|
|
5
|
-
baseGestureHandlerProps,
|
|
6
|
-
} from './gestureHandlerCommon';
|
|
7
|
-
|
|
8
|
-
export const nativeViewGestureHandlerProps = [
|
|
9
|
-
'shouldActivateOnStart',
|
|
10
|
-
'disallowInterruption',
|
|
11
|
-
] as const;
|
|
12
|
-
|
|
13
|
-
export interface NativeViewGestureConfig {
|
|
14
|
-
/**
|
|
15
|
-
* Android only.
|
|
16
|
-
*
|
|
17
|
-
* Determines whether the handler should check for an existing touch event on
|
|
18
|
-
* instantiation.
|
|
19
|
-
*/
|
|
20
|
-
shouldActivateOnStart?: boolean;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* When `true`, cancels all other gesture handlers when this
|
|
24
|
-
* `NativeViewGestureHandler` receives an `ACTIVE` state event.
|
|
25
|
-
*/
|
|
26
|
-
disallowInterruption?: boolean;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @deprecated NativeViewGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Native()` instead.
|
|
31
|
-
*/
|
|
32
|
-
export interface NativeViewGestureHandlerProps
|
|
33
|
-
extends BaseGestureHandlerProps<NativeViewGestureHandlerPayload>,
|
|
34
|
-
NativeViewGestureConfig {}
|
|
35
|
-
|
|
36
|
-
export const nativeViewProps = [
|
|
37
|
-
...baseGestureHandlerProps,
|
|
38
|
-
...nativeViewGestureHandlerProps,
|
|
39
|
-
] as const;
|
|
40
|
-
|
|
41
|
-
export const nativeViewHandlerName = 'NativeViewGestureHandler';
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @deprecated NativeViewGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Native()` instead.
|
|
45
|
-
*/
|
|
46
|
-
export type NativeViewGestureHandler = typeof NativeViewGestureHandler;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* @deprecated NativeViewGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Native()` instead.
|
|
50
|
-
*/
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
|
|
52
|
-
export const NativeViewGestureHandler = createHandler<
|
|
53
|
-
NativeViewGestureHandlerProps,
|
|
54
|
-
NativeViewGestureHandlerPayload
|
|
55
|
-
>({
|
|
56
|
-
name: nativeViewHandlerName,
|
|
57
|
-
allowedProps: nativeViewProps,
|
|
58
|
-
config: {},
|
|
59
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { BaseGestureConfig, BaseGesture } from './gesture';
|
|
2
|
-
import { NativeViewGestureConfig } from '../NativeViewGestureHandler';
|
|
3
|
-
import type { NativeViewGestureHandlerPayload } from '../GestureHandlerEventPayload';
|
|
4
|
-
|
|
5
|
-
export class NativeGesture extends BaseGesture<NativeViewGestureHandlerPayload> {
|
|
6
|
-
public config: BaseGestureConfig & NativeViewGestureConfig = {};
|
|
7
|
-
|
|
8
|
-
constructor() {
|
|
9
|
-
super();
|
|
10
|
-
|
|
11
|
-
this.handlerName = 'NativeViewGestureHandler';
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* When true, underlying handler will activate unconditionally when in `BEGAN` or `UNDETERMINED` state.
|
|
16
|
-
* @param value
|
|
17
|
-
*/
|
|
18
|
-
shouldActivateOnStart(value: boolean) {
|
|
19
|
-
this.config.shouldActivateOnStart = value;
|
|
20
|
-
return this;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* When true, cancels all other gesture handlers when this `NativeViewGestureHandler` receives an `ACTIVE` state event.
|
|
25
|
-
* @param value
|
|
26
|
-
*/
|
|
27
|
-
disallowInterruption(value: boolean) {
|
|
28
|
-
this.config.disallowInterruption = value;
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export type NativeGestureType = InstanceType<typeof NativeGesture>;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { TurboModuleRegistry, TurboModule } from 'react-native';
|
|
2
|
-
import { Double } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
|
-
|
|
4
|
-
export interface Spec extends TurboModule {
|
|
5
|
-
handleSetJSResponder: (tag: Double, blockNativeResponder: boolean) => void;
|
|
6
|
-
handleClearJSResponder: () => void;
|
|
7
|
-
createGestureHandler: (
|
|
8
|
-
handlerName: string,
|
|
9
|
-
handlerTag: Double,
|
|
10
|
-
// Record<> is not supported by codegen
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
12
|
-
config: Object
|
|
13
|
-
) => void;
|
|
14
|
-
attachGestureHandler: (
|
|
15
|
-
handlerTag: Double,
|
|
16
|
-
newView: Double,
|
|
17
|
-
actionType: Double
|
|
18
|
-
) => void;
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
20
|
-
updateGestureHandler: (handlerTag: Double, newConfig: Object) => void;
|
|
21
|
-
dropGestureHandler: (handlerTag: Double) => void;
|
|
22
|
-
install: () => boolean;
|
|
23
|
-
flushOperations: () => void;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export default TurboModuleRegistry.getEnforcing<Spec>('RNGestureHandlerModule');
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import DiscreteGestureHandler from './DiscreteGestureHandler';
|
|
2
|
-
import { HammerInputExt } from './GestureHandler';
|
|
3
|
-
import * as NodeManager from './NodeManager';
|
|
4
|
-
import PressGestureHandler from './PressGestureHandler';
|
|
5
|
-
import { TEST_MIN_IF_NOT_NAN, VEC_LEN_SQ } from './utils';
|
|
6
|
-
|
|
7
|
-
class NativeViewGestureHandler extends PressGestureHandler {
|
|
8
|
-
get isNative() {
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
onRawEvent(ev: HammerInputExt) {
|
|
13
|
-
super.onRawEvent(ev);
|
|
14
|
-
if (!ev.isFinal) {
|
|
15
|
-
// if (this.ref instanceof ScrollView) {
|
|
16
|
-
if (TEST_MIN_IF_NOT_NAN(VEC_LEN_SQ({ x: ev.deltaX, y: ev.deltaY }), 10)) {
|
|
17
|
-
// @ts-ignore FIXME(TS) config type
|
|
18
|
-
if (this.config.disallowInterruption) {
|
|
19
|
-
const gestures = Object.values(NodeManager.getNodes()).filter(
|
|
20
|
-
(gesture) => {
|
|
21
|
-
const { handlerTag, view, isGestureRunning } = gesture;
|
|
22
|
-
return (
|
|
23
|
-
// Check if this gesture isn't self
|
|
24
|
-
handlerTag !== this.handlerTag &&
|
|
25
|
-
// Ensure the gesture needs to be cancelled
|
|
26
|
-
isGestureRunning &&
|
|
27
|
-
// ScrollView can cancel discrete gestures like taps and presses
|
|
28
|
-
gesture instanceof DiscreteGestureHandler &&
|
|
29
|
-
// Ensure a view exists and is a child of the current view
|
|
30
|
-
view &&
|
|
31
|
-
// @ts-ignore FIXME(TS) view type
|
|
32
|
-
this.view.contains(view)
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
);
|
|
36
|
-
// Cancel all of the gestures that passed the filter
|
|
37
|
-
for (const gesture of gestures) {
|
|
38
|
-
// TODO: Bacon: Send some cached event.
|
|
39
|
-
gesture.forceInvalidate(ev);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export default NativeViewGestureHandler;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { NativeViewGestureHandlerPayload } from './GestureHandlerEventPayload';
|
|
2
|
-
import createHandler from './createHandler';
|
|
3
|
-
import {
|
|
4
|
-
BaseGestureHandlerProps,
|
|
5
|
-
baseGestureHandlerProps,
|
|
6
|
-
} from './gestureHandlerCommon';
|
|
7
|
-
|
|
8
|
-
export const nativeViewGestureHandlerProps = [
|
|
9
|
-
'shouldActivateOnStart',
|
|
10
|
-
'disallowInterruption',
|
|
11
|
-
] as const;
|
|
12
|
-
|
|
13
|
-
export interface NativeViewGestureConfig {
|
|
14
|
-
/**
|
|
15
|
-
* Android only.
|
|
16
|
-
*
|
|
17
|
-
* Determines whether the handler should check for an existing touch event on
|
|
18
|
-
* instantiation.
|
|
19
|
-
*/
|
|
20
|
-
shouldActivateOnStart?: boolean;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* When `true`, cancels all other gesture handlers when this
|
|
24
|
-
* `NativeViewGestureHandler` receives an `ACTIVE` state event.
|
|
25
|
-
*/
|
|
26
|
-
disallowInterruption?: boolean;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @deprecated NativeViewGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Native()` instead.
|
|
31
|
-
*/
|
|
32
|
-
export interface NativeViewGestureHandlerProps
|
|
33
|
-
extends BaseGestureHandlerProps<NativeViewGestureHandlerPayload>,
|
|
34
|
-
NativeViewGestureConfig {}
|
|
35
|
-
|
|
36
|
-
export const nativeViewProps = [
|
|
37
|
-
...baseGestureHandlerProps,
|
|
38
|
-
...nativeViewGestureHandlerProps,
|
|
39
|
-
] as const;
|
|
40
|
-
|
|
41
|
-
export const nativeViewHandlerName = 'NativeViewGestureHandler';
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @deprecated NativeViewGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Native()` instead.
|
|
45
|
-
*/
|
|
46
|
-
export type NativeViewGestureHandler = typeof NativeViewGestureHandler;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* @deprecated NativeViewGestureHandler will be removed in the future version of Gesture Handler. Use `Gesture.Native()` instead.
|
|
50
|
-
*/
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
|
|
52
|
-
export const NativeViewGestureHandler = createHandler<
|
|
53
|
-
NativeViewGestureHandlerProps,
|
|
54
|
-
NativeViewGestureHandlerPayload
|
|
55
|
-
>({
|
|
56
|
-
name: nativeViewHandlerName,
|
|
57
|
-
allowedProps: nativeViewProps,
|
|
58
|
-
config: {},
|
|
59
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { BaseGestureConfig, BaseGesture } from './gesture';
|
|
2
|
-
import { NativeViewGestureConfig } from '../NativeViewGestureHandler';
|
|
3
|
-
import type { NativeViewGestureHandlerPayload } from '../GestureHandlerEventPayload';
|
|
4
|
-
|
|
5
|
-
export class NativeGesture extends BaseGesture<NativeViewGestureHandlerPayload> {
|
|
6
|
-
public config: BaseGestureConfig & NativeViewGestureConfig = {};
|
|
7
|
-
|
|
8
|
-
constructor() {
|
|
9
|
-
super();
|
|
10
|
-
|
|
11
|
-
this.handlerName = 'NativeViewGestureHandler';
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* When true, underlying handler will activate unconditionally when in `BEGAN` or `UNDETERMINED` state.
|
|
16
|
-
* @param value
|
|
17
|
-
*/
|
|
18
|
-
shouldActivateOnStart(value: boolean) {
|
|
19
|
-
this.config.shouldActivateOnStart = value;
|
|
20
|
-
return this;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* When true, cancels all other gesture handlers when this `NativeViewGestureHandler` receives an `ACTIVE` state event.
|
|
25
|
-
* @param value
|
|
26
|
-
*/
|
|
27
|
-
disallowInterruption(value: boolean) {
|
|
28
|
-
this.config.disallowInterruption = value;
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export type NativeGestureType = InstanceType<typeof NativeGesture>;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { TurboModuleRegistry, TurboModule } from 'react-native';
|
|
2
|
-
import { Double } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
|
-
|
|
4
|
-
export interface Spec extends TurboModule {
|
|
5
|
-
handleSetJSResponder: (tag: Double, blockNativeResponder: boolean) => void;
|
|
6
|
-
handleClearJSResponder: () => void;
|
|
7
|
-
createGestureHandler: (
|
|
8
|
-
handlerName: string,
|
|
9
|
-
handlerTag: Double,
|
|
10
|
-
// Record<> is not supported by codegen
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
12
|
-
config: Object
|
|
13
|
-
) => void;
|
|
14
|
-
attachGestureHandler: (
|
|
15
|
-
handlerTag: Double,
|
|
16
|
-
newView: Double,
|
|
17
|
-
actionType: Double
|
|
18
|
-
) => void;
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
20
|
-
updateGestureHandler: (handlerTag: Double, newConfig: Object) => void;
|
|
21
|
-
dropGestureHandler: (handlerTag: Double) => void;
|
|
22
|
-
install: () => boolean;
|
|
23
|
-
flushOperations: () => void;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export default TurboModuleRegistry.getEnforcing<Spec>('RNGestureHandlerModule');
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import DiscreteGestureHandler from './DiscreteGestureHandler';
|
|
2
|
-
import { HammerInputExt } from './GestureHandler';
|
|
3
|
-
import * as NodeManager from './NodeManager';
|
|
4
|
-
import PressGestureHandler from './PressGestureHandler';
|
|
5
|
-
import { TEST_MIN_IF_NOT_NAN, VEC_LEN_SQ } from './utils';
|
|
6
|
-
|
|
7
|
-
class NativeViewGestureHandler extends PressGestureHandler {
|
|
8
|
-
get isNative() {
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
onRawEvent(ev: HammerInputExt) {
|
|
13
|
-
super.onRawEvent(ev);
|
|
14
|
-
if (!ev.isFinal) {
|
|
15
|
-
// if (this.ref instanceof ScrollView) {
|
|
16
|
-
if (TEST_MIN_IF_NOT_NAN(VEC_LEN_SQ({ x: ev.deltaX, y: ev.deltaY }), 10)) {
|
|
17
|
-
// @ts-ignore FIXME(TS) config type
|
|
18
|
-
if (this.config.disallowInterruption) {
|
|
19
|
-
const gestures = Object.values(NodeManager.getNodes()).filter(
|
|
20
|
-
(gesture) => {
|
|
21
|
-
const { handlerTag, view, isGestureRunning } = gesture;
|
|
22
|
-
return (
|
|
23
|
-
// Check if this gesture isn't self
|
|
24
|
-
handlerTag !== this.handlerTag &&
|
|
25
|
-
// Ensure the gesture needs to be cancelled
|
|
26
|
-
isGestureRunning &&
|
|
27
|
-
// ScrollView can cancel discrete gestures like taps and presses
|
|
28
|
-
gesture instanceof DiscreteGestureHandler &&
|
|
29
|
-
// Ensure a view exists and is a child of the current view
|
|
30
|
-
view &&
|
|
31
|
-
// @ts-ignore FIXME(TS) view type
|
|
32
|
-
this.view.contains(view)
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
);
|
|
36
|
-
// Cancel all of the gestures that passed the filter
|
|
37
|
-
for (const gesture of gestures) {
|
|
38
|
-
// TODO: Bacon: Send some cached event.
|
|
39
|
-
gesture.forceInvalidate(ev);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export default NativeViewGestureHandler;
|