Skip to content

Commit 7d205dc

Browse files
committed
removed action type native detector animated event
1 parent 532f35a commit 7d205dc

File tree

10 files changed

+37
-40
lines changed

10 files changed

+37
-40
lines changed

packages/react-native-gesture-handler/src/ActionType.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,7 @@ export const ActionType = {
44
JS_FUNCTION_OLD_API: 3,
55
JS_FUNCTION_NEW_API: 4,
66
NATIVE_DETECTOR: 5,
7-
NATIVE_DETECTOR_ANIMATED_EVENT: 6,
87
} as const;
98

10-
export function isNativeDetectorActionType(type: ActionType | null): boolean {
11-
return (
12-
type === ActionType.NATIVE_ANIMATED_EVENT ||
13-
type === ActionType.NATIVE_DETECTOR_ANIMATED_EVENT
14-
);
15-
}
16-
17-
export function isAnimatedActionType(type: ActionType | null): boolean {
18-
return (
19-
type === ActionType.NATIVE_DETECTOR ||
20-
type === ActionType.NATIVE_DETECTOR_ANIMATED_EVENT
21-
);
22-
}
23-
249
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; it can be used as a type and as a value
2510
export type ActionType = (typeof ActionType)[keyof typeof ActionType];

packages/react-native-gesture-handler/src/RNGestureHandlerModule.web.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ export default {
4848
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4949
newView: any,
5050
actionType: ActionType,
51-
propsRef: React.RefObject<PropsRef>
51+
propsRef: React.RefObject<PropsRef>,
52+
forAnimated: boolean
5253
) {
5354
if (!(newView instanceof Element || newView instanceof React.Component)) {
5455
shouldPreventDrop = true;
@@ -63,7 +64,12 @@ export default {
6364
}
6465

6566
// @ts-ignore Types should be HTMLElement or React.Component
66-
NodeManager.getHandler(handlerTag).init(newView, propsRef, actionType);
67+
NodeManager.getHandler(handlerTag).init(
68+
newView,
69+
propsRef,
70+
actionType,
71+
forAnimated
72+
);
6773
},
6874
detachGestureHandler(handlerTag: number) {
6975
if (shouldPreventDrop) {

packages/react-native-gesture-handler/src/handlers/createHandler.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ type AttachGestureHandlerWeb = (
160160
// eslint-disable-next-line @typescript-eslint/no-explicit-any
161161
newView: any,
162162
_actionType: ActionType,
163-
propsRef: React.RefObject<unknown>
163+
propsRef: React.RefObject<unknown>,
164+
forAnimated: boolean
164165
) => void;
165166

166167
const UNRESOLVED_REFS_RETRY_LIMIT = 1;
@@ -349,7 +350,8 @@ export default function createHandler<
349350
this.handlerTag,
350351
newViewTag,
351352
ActionType.JS_FUNCTION_OLD_API, // ignored on web
352-
this.propsRef
353+
this.propsRef,
354+
false
353355
);
354356
} else {
355357
registerOldGestureHandler(this.handlerTag, {

packages/react-native-gesture-handler/src/handlers/gestures/GestureDetector/attachHandlers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ export function attachHandlers({
8686
gesture.handlerTag,
8787
viewTag,
8888
ActionType.JS_FUNCTION_OLD_API, // Ignored on web
89-
webEventHandlersRef
89+
webEventHandlersRef,
90+
false
9091
);
9192
} else {
9293
RNGestureHandlerModule.attachGestureHandler(

packages/react-native-gesture-handler/src/v3/HostGestureDetector.web.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ const HostGestureDetector = (props: GestureHandlerDetectorProps) => {
2929
RNGestureHandlerModule.attachGestureHandler(
3030
tag,
3131
viewRef.current,
32+
ActionType.NATIVE_DETECTOR,
33+
propsRef,
3234
dispatchesAnimatedEvents
33-
? ActionType.NATIVE_DETECTOR_ANIMATED_EVENT
34-
: ActionType.NATIVE_DETECTOR,
35-
propsRef
3635
);
3736
});
3837
}, [handlerTags, dispatchesAnimatedEvents]);

packages/react-native-gesture-handler/src/web/handlers/GestureHandler.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ import IGestureHandler from './IGestureHandler';
1818
import { MouseButton } from '../../handlers/gestureHandlerCommon';
1919
import { PointerType } from '../../PointerType';
2020
import { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate';
21-
import {
22-
ActionType,
23-
isAnimatedActionType,
24-
isNativeDetectorActionType,
25-
} from '../../ActionType';
21+
import { ActionType } from '../../ActionType';
2622
import { tagMessage } from '../../utils';
2723

2824
export default abstract class GestureHandler implements IGestureHandler {
@@ -37,6 +33,7 @@ export default abstract class GestureHandler implements IGestureHandler {
3733
private viewRef: number | null = null;
3834
private propsRef: React.RefObject<PropsRef> | null = null;
3935
private actionType: ActionType | null = null;
36+
private forAnimated: boolean | null = null;
4037
private _handlerTag!: number;
4138
private _config: Config = { enabled: false };
4239

@@ -50,7 +47,6 @@ export default abstract class GestureHandler implements IGestureHandler {
5047

5148
private _shouldResetProgress = false;
5249
private _pointerType: PointerType = PointerType.MOUSE;
53-
5450
private _delegate: GestureHandlerDelegate<unknown, IGestureHandler>;
5551

5652
public constructor(
@@ -66,12 +62,14 @@ export default abstract class GestureHandler implements IGestureHandler {
6662
protected init(
6763
viewRef: number,
6864
propsRef: React.RefObject<PropsRef>,
69-
actionType: ActionType
65+
actionType: ActionType,
66+
forAnimated: boolean
7067
) {
7168
this.propsRef = propsRef;
7269
this.viewRef = viewRef;
7370
this.actionType = actionType;
7471
this.state = State.UNDETERMINED;
72+
this.forAnimated = forAnimated;
7573

7674
this.delegate.init(viewRef, this);
7775
}
@@ -86,6 +84,7 @@ export default abstract class GestureHandler implements IGestureHandler {
8684
this.viewRef = null;
8785
this.actionType = null;
8886
this.state = State.UNDETERMINED;
87+
this.forAnimated = null;
8988

9089
this.delegate.detach();
9190
}
@@ -374,7 +373,7 @@ export default abstract class GestureHandler implements IGestureHandler {
374373
if (touchEvent) {
375374
if (
376375
onGestureHandlerTouchEvent &&
377-
isNativeDetectorActionType(this.actionType)
376+
this.actionType === ActionType.NATIVE_DETECTOR
378377
) {
379378
invokeNullableMethod(onGestureHandlerTouchEvent, touchEvent);
380379
} else {
@@ -412,7 +411,8 @@ export default abstract class GestureHandler implements IGestureHandler {
412411
resultEvent.nativeEvent.oldState = undefined;
413412
if (
414413
onGestureHandlerAnimatedEvent &&
415-
isAnimatedActionType(this.actionType)
414+
(this.actionType === ActionType.NATIVE_ANIMATED_EVENT ||
415+
this.forAnimated)
416416
) {
417417
invokeNullableMethod(onGestureHandlerAnimatedEvent, resultEvent);
418418
}

packages/react-native-gesture-handler/src/web/handlers/LongPressGestureHandler.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@ export default class LongPressGestureHandler extends GestureHandler {
2525
public init(
2626
ref: number,
2727
propsRef: React.RefObject<PropsRef>,
28-
actionType: ActionType
28+
actionType: ActionType,
29+
forAnimated: boolean
2930
) {
3031
if (this.config.enableContextMenu === undefined) {
3132
this.config.enableContextMenu = false;
3233
}
3334

34-
super.init(ref, propsRef, actionType);
35+
super.init(ref, propsRef, actionType, forAnimated);
3536
}
3637

3738
protected transformNativeEvent() {

packages/react-native-gesture-handler/src/web/handlers/NativeViewGestureHandler.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ export default class NativeViewGestureHandler extends GestureHandler {
2020
public init(
2121
ref: number,
2222
propsRef: React.RefObject<PropsRef>,
23-
actionType: ActionType
23+
actionType: ActionType,
24+
forAnimated: boolean
2425
): void {
25-
super.init(ref, propsRef, actionType);
26+
super.init(ref, propsRef, actionType, forAnimated);
2627

2728
this.shouldCancelWhenOutside = true;
2829

packages/react-native-gesture-handler/src/web/handlers/PinchGestureHandler.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ export default class PinchGestureHandler extends GestureHandler {
5252
public init(
5353
ref: number,
5454
propsRef: React.RefObject<PropsRef>,
55-
actionType: ActionType
55+
actionType: ActionType,
56+
forAnimated: boolean
5657
) {
57-
super.init(ref, propsRef, actionType);
58+
super.init(ref, propsRef, actionType, forAnimated);
5859

5960
this.shouldCancelWhenOutside = false;
6061
}

packages/react-native-gesture-handler/src/web/handlers/RotationGestureHandler.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ export default class RotationGestureHandler extends GestureHandler {
4848
public init(
4949
ref: number,
5050
propsRef: React.RefObject<PropsRef>,
51-
actionType: ActionType
51+
actionType: ActionType,
52+
forAnimated: boolean
5253
): void {
53-
super.init(ref, propsRef, actionType);
54+
super.init(ref, propsRef, actionType, forAnimated);
5455

5556
this.shouldCancelWhenOutside = false;
5657
}

0 commit comments

Comments
 (0)