UNPKG

1.15 kBPlain TextView Raw
1'use strict';
2import { isChromeDebugger, isJest, shouldBeUseWeb } from '../PlatformChecker';
3
4type SetGestureState = (handlerTag: number, newState: number) => void;
5
6export let setGestureState: SetGestureState;
7
8function setGestureStateNative(handlerTag: number, newState: number) {
9 'worklet';
10 if (!_WORKLET) {
11 console.warn(
12 '[Reanimated] You can not use setGestureState in non-worklet function.'
13 );
14 return;
15 }
16 global._setGestureState(handlerTag, newState);
17}
18
19function setGestureStateJest() {
20 console.warn('[Reanimated] setGestureState() cannot be used with Jest.');
21}
22
23function setGestureStateChromeDebugger() {
24 console.warn(
25 '[Reanimated] setGestureState() cannot be used with Chrome Debugger.'
26 );
27}
28
29function setGestureStateDefault() {
30 console.warn(
31 '[Reanimated] setGestureState() is not supported on this configuration.'
32 );
33}
34
35if (!shouldBeUseWeb()) {
36 setGestureState = setGestureStateNative;
37} else if (isJest()) {
38 setGestureState = setGestureStateJest;
39} else if (isChromeDebugger()) {
40 setGestureState = setGestureStateChromeDebugger;
41} else {
42 setGestureState = setGestureStateDefault;
43}