diff --git a/src/handlers/gestures/gestureStateManager.ts b/src/handlers/gestures/gestureStateManager.ts index 35ff56acf0..7dee92bbfe 100644 --- a/src/handlers/gestures/gestureStateManager.ts +++ b/src/handlers/gestures/gestureStateManager.ts @@ -18,45 +18,47 @@ const warningMessage = tagMessage( const REANIMATED_AVAILABLE = Reanimated?.useSharedValue !== undefined; const setGestureState = Reanimated?.setGestureState; +function create(handlerTag: number): GestureStateManagerType { + 'worklet'; + return { + begin: () => { + 'worklet'; + if (REANIMATED_AVAILABLE) { + setGestureState(handlerTag, State.BEGAN); + } else { + console.warn(warningMessage); + } + }, + + activate: () => { + 'worklet'; + if (REANIMATED_AVAILABLE) { + setGestureState(handlerTag, State.ACTIVE); + } else { + console.warn(warningMessage); + } + }, + + fail: () => { + 'worklet'; + if (REANIMATED_AVAILABLE) { + setGestureState(handlerTag, State.FAILED); + } else { + console.warn(warningMessage); + } + }, + + end: () => { + 'worklet'; + if (REANIMATED_AVAILABLE) { + setGestureState(handlerTag, State.END); + } else { + console.warn(warningMessage); + } + }, + }; +} + export const GestureStateManager = { - create(handlerTag: number): GestureStateManagerType { - 'worklet'; - return { - begin: () => { - 'worklet'; - if (REANIMATED_AVAILABLE) { - setGestureState(handlerTag, State.BEGAN); - } else { - console.warn(warningMessage); - } - }, - - activate: () => { - 'worklet'; - if (REANIMATED_AVAILABLE) { - setGestureState(handlerTag, State.ACTIVE); - } else { - console.warn(warningMessage); - } - }, - - fail: () => { - 'worklet'; - if (REANIMATED_AVAILABLE) { - setGestureState(handlerTag, State.FAILED); - } else { - console.warn(warningMessage); - } - }, - - end: () => { - 'worklet'; - if (REANIMATED_AVAILABLE) { - setGestureState(handlerTag, State.END); - } else { - console.warn(warningMessage); - } - }, - }; - }, + create, };