Skip to content

Commit 8c03f58

Browse files
committed
worklets
1 parent a90b83c commit 8c03f58

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

packages/react-native-gesture-handler/src/v3/NativeDetector.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { Animated, StyleSheet } from 'react-native';
1313
import HostGestureDetector from './HostGestureDetector';
1414
import { tagMessage } from '../utils';
1515
import { LogicDetectorProps } from './LogicDetector';
16+
import { runOnJS } from 'react-native-reanimated';
1617

1718
export interface NativeDetectorProps {
1819
children?: React.ReactNode;
@@ -94,21 +95,27 @@ export function NativeDetector({ gesture, children }: NativeDetectorProps) {
9495
gesture.gestureEvents.onGestureHandlerTouchEvent
9596
}
9697
onGestureHandlerLogicEvent={(e) => {
97-
logicMethods.current
98-
.get(e.nativeEvent.childTag)
99-
?.onGestureHandlerEvent(e);
98+
const logicMethod = logicMethods.current.get(
99+
e.nativeEvent.childTag
100+
)?.onGestureHandlerEvent;
101+
if (logicMethod) {
102+
runOnJS(logicMethod);
103+
}
100104
}}
101105
onGestureHandlerLogicStateChange={(e) => {
102-
logicMethods.current
103-
.get(e.nativeEvent.childTag)
104-
?.onGestureHandlerStateChange(e);
106+
const logicMethod = logicMethods.current.get(
107+
e.nativeEvent.childTag
108+
)?.onGestureHandlerStateChange;
109+
if (logicMethod) {
110+
runOnJS(logicMethod);
111+
}
105112
}}
106113
onGestureHandlerLogicTouchEvent={(e) => {
107-
const touchEvent = logicMethods.current.get(
114+
const logicMethod = logicMethods.current.get(
108115
e.nativeEvent.childTag
109116
)?.onGestureHandlerTouchEvent;
110-
if (touchEvent) {
111-
touchEvent(e);
117+
if (logicMethod) {
118+
runOnJS(logicMethod);
112119
}
113120
}}
114121
moduleId={globalThis._RNGH_MODULE_ID}

0 commit comments

Comments
 (0)