Skip to content

Commit f3198f5

Browse files
committed
moved forAnimated to config
1 parent 2443971 commit f3198f5

File tree

6 files changed

+35
-42
lines changed

6 files changed

+35
-42
lines changed

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

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

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

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

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

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

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ import { PropsRef } from '../web/interfaces';
66

77
export interface GestureHandlerDetectorProps extends PropsRef {
88
handlerTags: number[];
9-
dispatchesAnimatedEvents: boolean;
109
moduleId: number;
1110
children?: React.ReactNode;
1211
}
1312

1413
const HostGestureDetector = (props: GestureHandlerDetectorProps) => {
15-
const { handlerTags, dispatchesAnimatedEvents, children } = props;
14+
const { handlerTags, children } = props;
1615

1716
const viewRef = useRef(null);
1817
const propsRef = useRef<PropsRef>(props);
@@ -24,29 +23,25 @@ const HostGestureDetector = (props: GestureHandlerDetectorProps) => {
2423
});
2524
}, []);
2625

27-
const attachHandlers = useCallback(
28-
(currentHandlerTags: Set<number>) => {
29-
const oldHandlerTags =
30-
attachedHandlerTags.current.difference(currentHandlerTags);
31-
const newHandlerTags = currentHandlerTags.difference(
32-
attachedHandlerTags.current
26+
const attachHandlers = useCallback((currentHandlerTags: Set<number>) => {
27+
const oldHandlerTags =
28+
attachedHandlerTags.current.difference(currentHandlerTags);
29+
const newHandlerTags = currentHandlerTags.difference(
30+
attachedHandlerTags.current
31+
);
32+
33+
detachHandlers(oldHandlerTags);
34+
35+
newHandlerTags.forEach((tag) => {
36+
RNGestureHandlerModule.attachGestureHandler(
37+
tag,
38+
viewRef.current,
39+
ActionType.NATIVE_DETECTOR,
40+
propsRef
3341
);
34-
35-
detachHandlers(oldHandlerTags);
36-
37-
newHandlerTags.forEach((tag) => {
38-
RNGestureHandlerModule.attachGestureHandler(
39-
tag,
40-
viewRef.current,
41-
ActionType.NATIVE_DETECTOR,
42-
propsRef,
43-
dispatchesAnimatedEvents
44-
);
45-
});
46-
attachedHandlerTags.current = currentHandlerTags;
47-
},
48-
[dispatchesAnimatedEvents]
49-
);
42+
});
43+
attachedHandlerTags.current = currentHandlerTags;
44+
}, []);
5045

5146
useEffect(() => {
5247
attachHandlers(new Set(handlerTags));

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,8 +615,16 @@ export default abstract class GestureHandler implements IGestureHandler {
615615
// Handling config
616616
//
617617

618-
public updateGestureConfig({ enabled = true, ...props }: Config): void {
619-
this._config = { enabled: enabled, ...props };
618+
public updateGestureConfig({
619+
enabled = true,
620+
dispatchesAnimatedEvents = false,
621+
...props
622+
}: Config): void {
623+
this._config = {
624+
enabled: enabled,
625+
dispatchesAnimatedEvents: dispatchesAnimatedEvents,
626+
...props,
627+
};
620628

621629
if (this.enabled !== enabled) {
622630
this.delegate.onEnabledChange(enabled);
@@ -628,6 +636,7 @@ export default abstract class GestureHandler implements IGestureHandler {
628636
this.shouldCancelWhenOutside = this.config.shouldCancelWhenOutside;
629637
}
630638

639+
this.forAnimated = dispatchesAnimatedEvents;
631640
this.validateHitSlops();
632641

633642
if (this.enabled) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export interface Config extends Record<string, ConfigArgs> {
4848
enableContextMenu?: boolean;
4949
touchAction?: TouchAction;
5050
manualActivation?: boolean;
51+
dispatchesAnimatedEvents?: false;
5152

5253
activateAfterLongPress?: number;
5354
failOffsetXStart?: number;

packages/react-native-gesture-handler/src/web/tools/GestureHandlerWebDelegate.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { Config } from '../interfaces';
1212
import { MouseButton } from '../../handlers/gestureHandlerCommon';
1313
import KeyboardEventManager from './KeyboardEventManager';
1414
import WheelEventManager from './WheelEventManager';
15-
import { tagMessage } from '../../utils';
1615

1716
interface DefaultViewStyles {
1817
userSelect: string;
@@ -234,11 +233,7 @@ export class GestureHandlerWebDelegate
234233
}
235234

236235
public get view() {
237-
if (!this._view) {
238-
throw new Error(tagMessage("component's view is null"));
239-
}
240-
241-
return this._view;
236+
return this._view!;
242237
}
243238
public set view(value: HTMLElement) {
244239
this._view = value;

0 commit comments

Comments
 (0)