react-native-gesture-handler 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- package/RNGestureHandler.podspec +2 -1
- package/android/build.gradle +10 -2
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.kt +14 -2
- package/android/noreanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt +10 -0
- package/android/reanimated/src/main/java/com/swmansion/gesturehandler/ReanimatedEventDispatcher.kt +17 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +11 -3
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEnabledRootView.kt +3 -41
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.kt +6 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +10 -54
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt +2 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.kt +6 -0
- package/ios/RNGHTouchEventType.h +9 -0
- package/ios/RNGestureHandler.h +2 -2
- package/ios/RNGestureHandler.m +21 -8
- package/ios/RNGestureHandler.xcodeproj/project.xcworkspace/xcuserdata/jakubpiasecki.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RNGestureHandler.xcodeproj/xcuserdata/jakubpiasecki.xcuserdatad/xcschemes/xcschememanagement.plist +19 -0
- package/ios/RNGestureHandlerButton.h +1 -0
- package/ios/RNGestureHandlerButton.m +9 -1
- package/ios/RNGestureHandlerButtonComponentView.mm +14 -1
- package/ios/RNGestureHandlerButtonManager.m +4 -1
- package/ios/RNGestureHandlerEvents.h +2 -2
- package/ios/RNGestureHandlerEvents.m +2 -2
- package/ios/RNGestureHandlerManager.h +2 -0
- package/ios/RNGestureHandlerManager.mm +30 -20
- package/ios/RNGestureHandlerModule.mm +18 -0
- package/ios/RNGestureHandlerPointerTracker.h +2 -2
- package/ios/RNGestureHandlerPointerTracker.m +9 -6
- package/ios/RNGestureHandlerRegistry.h +1 -0
- package/ios/RNGestureHandlerRegistry.m +10 -0
- package/jest-utils/package.json +6 -0
- package/lib/commonjs/GestureHandlerRootView.android.js +7 -1
- package/lib/commonjs/GestureHandlerRootView.android.js.map +1 -1
- package/lib/commonjs/GestureHandlerRootView.js +6 -0
- package/lib/commonjs/GestureHandlerRootView.js.map +1 -1
- package/lib/commonjs/GestureHandlerRootView.web.js +19 -0
- package/lib/commonjs/GestureHandlerRootView.web.js.map +1 -0
- package/lib/commonjs/RNGestureHandlerModule.js +5 -0
- package/lib/commonjs/RNGestureHandlerModule.js.map +1 -1
- package/lib/commonjs/RNGestureHandlerModule.web.js +4 -1
- package/lib/commonjs/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/commonjs/{EventType.js → TouchEventType.js} +4 -4
- package/lib/commonjs/TouchEventType.js.map +1 -0
- package/lib/commonjs/components/GestureButtons.js.map +1 -1
- package/lib/commonjs/components/GestureHandlerButton.js +1 -1
- package/lib/commonjs/components/GestureHandlerButton.js.map +1 -1
- package/lib/commonjs/components/touchables/GenericTouchable.js +2 -0
- package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/commonjs/components/touchables/TouchableOpacity.js +3 -1
- package/lib/commonjs/components/touchables/TouchableOpacity.js.map +1 -1
- package/lib/commonjs/fabric/RNGestureHandlerButtonNativeComponent.js +4 -6
- package/lib/commonjs/fabric/RNGestureHandlerButtonNativeComponent.js.map +1 -1
- package/lib/commonjs/fabric/RNGestureHandlerRootViewNativeComponent.js +4 -6
- package/lib/commonjs/fabric/RNGestureHandlerRootViewNativeComponent.js.map +1 -1
- package/lib/commonjs/getShadowNodeFromRef.js +12 -9
- package/lib/commonjs/getShadowNodeFromRef.js.map +1 -1
- package/lib/commonjs/handlers/createHandler.js +10 -14
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/gestureHandlerCommon.js +18 -1
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector.js +41 -21
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/commonjs/handlers/gestures/eventReceiver.js +6 -5
- package/lib/commonjs/handlers/gestures/eventReceiver.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gesture.js +11 -2
- package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
- package/lib/commonjs/index.js +0 -14
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/init.js +10 -1
- package/lib/commonjs/init.js.map +1 -1
- package/lib/commonjs/jestUtils/index.js +20 -0
- package/lib/commonjs/jestUtils/index.js.map +1 -0
- package/lib/commonjs/{jestUtils.js → jestUtils/jestUtils.js} +12 -12
- package/lib/commonjs/jestUtils/jestUtils.js.map +1 -0
- package/lib/commonjs/utils.js +23 -1
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/GestureHandler.js +4 -1
- package/lib/commonjs/web/GestureHandler.js.map +1 -1
- package/lib/module/GestureHandlerRootView.android.js +7 -2
- package/lib/module/GestureHandlerRootView.android.js.map +1 -1
- package/lib/module/GestureHandlerRootView.js +5 -0
- package/lib/module/GestureHandlerRootView.js.map +1 -1
- package/lib/module/GestureHandlerRootView.web.js +6 -0
- package/lib/module/GestureHandlerRootView.web.js.map +1 -0
- package/lib/module/RNGestureHandlerModule.js +5 -0
- package/lib/module/RNGestureHandlerModule.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.web.js +4 -1
- package/lib/module/RNGestureHandlerModule.web.js.map +1 -1
- package/lib/module/{EventType.js → TouchEventType.js} +2 -2
- package/lib/module/TouchEventType.js.map +1 -0
- package/lib/module/components/GestureButtons.js.map +1 -1
- package/lib/module/components/GestureHandlerButton.js +2 -2
- package/lib/module/components/GestureHandlerButton.js.map +1 -1
- package/lib/module/components/touchables/GenericTouchable.js +2 -0
- package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/module/components/touchables/TouchableOpacity.js +4 -2
- package/lib/module/components/touchables/TouchableOpacity.js.map +1 -1
- package/lib/module/fabric/RNGestureHandlerButtonNativeComponent.js +5 -7
- package/lib/module/fabric/RNGestureHandlerButtonNativeComponent.js.map +1 -1
- package/lib/module/fabric/RNGestureHandlerRootViewNativeComponent.js +5 -8
- package/lib/module/fabric/RNGestureHandlerRootViewNativeComponent.js.map +1 -1
- package/lib/module/getShadowNodeFromRef.js +11 -8
- package/lib/module/getShadowNodeFromRef.js.map +1 -1
- package/lib/module/handlers/createHandler.js +10 -17
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/gestureHandlerCommon.js +11 -1
- package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector.js +41 -22
- package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/module/handlers/gestures/eventReceiver.js +6 -7
- package/lib/module/handlers/gestures/eventReceiver.js.map +1 -1
- package/lib/module/handlers/gestures/gesture.js +10 -2
- package/lib/module/handlers/gestures/gesture.js.map +1 -1
- package/lib/module/index.js +0 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/init.js +6 -1
- package/lib/module/init.js.map +1 -1
- package/lib/module/jestUtils/index.js +2 -0
- package/lib/module/jestUtils/index.js.map +1 -0
- package/lib/module/{jestUtils.js → jestUtils/jestUtils.js} +12 -12
- package/lib/module/jestUtils/jestUtils.js.map +1 -0
- package/lib/module/utils.js +17 -1
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/GestureHandler.js +4 -1
- package/lib/module/web/GestureHandler.js.map +1 -1
- package/lib/typescript/GestureHandlerRootView.web.d.ts +5 -0
- package/lib/typescript/RNGestureHandlerModule.d.ts +1 -0
- package/lib/typescript/RNGestureHandlerModule.web.d.ts +1 -0
- package/lib/typescript/{EventType.d.ts → TouchEventType.d.ts} +2 -2
- package/lib/typescript/components/GestureButtons.d.ts +18 -6
- package/lib/typescript/components/touchables/TouchableOpacity.d.ts +5 -1
- package/lib/typescript/fabric/RNGestureHandlerButtonNativeComponent.d.ts +13 -0
- package/lib/typescript/fabric/RNGestureHandlerRootViewNativeComponent.d.ts +5 -0
- package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +1 -1
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +5 -3
- package/lib/typescript/handlers/gestures/GestureDetector.d.ts +0 -3
- package/lib/typescript/handlers/gestures/eventReceiver.d.ts +2 -0
- package/lib/typescript/handlers/gestures/gesture.d.ts +2 -0
- package/lib/typescript/index.d.ts +0 -1
- package/lib/typescript/init.d.ts +1 -0
- package/lib/typescript/jestUtils/index.d.ts +1 -0
- package/lib/typescript/{jestUtils.d.ts → jestUtils/jestUtils.d.ts} +18 -18
- package/lib/typescript/utils.d.ts +2 -0
- package/lib/typescript/web/GestureHandler.d.ts +1 -1
- package/package.json +5 -2
- package/src/GestureHandlerRootView.android.tsx +8 -2
- package/src/GestureHandlerRootView.tsx +6 -0
- package/src/GestureHandlerRootView.web.tsx +12 -0
- package/src/RNGestureHandlerModule.ts +7 -0
- package/src/RNGestureHandlerModule.web.ts +2 -0
- package/src/{EventType.ts → TouchEventType.ts} +2 -2
- package/src/components/GestureButtons.tsx +21 -7
- package/src/components/GestureHandlerButton.tsx +2 -2
- package/src/components/touchables/GenericTouchable.tsx +2 -0
- package/src/components/touchables/TouchableOpacity.tsx +6 -2
- package/src/fabric/RNGestureHandlerButtonNativeComponent.ts +27 -0
- package/src/fabric/RNGestureHandlerRootViewNativeComponent.ts +12 -0
- package/src/getShadowNodeFromRef.ts +12 -9
- package/src/handlers/createHandler.ts +7 -17
- package/src/handlers/gestureHandlerCommon.ts +19 -2
- package/src/handlers/gestures/GestureDetector.tsx +64 -31
- package/src/handlers/gestures/eventReceiver.ts +6 -6
- package/src/handlers/gestures/gesture.ts +13 -2
- package/src/index.ts +0 -1
- package/src/init.ts +8 -1
- package/src/jestUtils/index.ts +1 -0
- package/src/{jestUtils.ts → jestUtils/jestUtils.ts} +21 -21
- package/src/utils.ts +20 -0
- package/src/web/GestureHandler.ts +7 -1
- package/ios/RNTouchEventType.h +0 -9
- package/lib/commonjs/EventType.js.map +0 -1
- package/lib/commonjs/jestUtils.js.map +0 -1
- package/lib/module/EventType.js.map +0 -1
- package/lib/module/jestUtils.js.map +0 -1
- package/src/fabric/RNGestureHandlerButtonNativeComponent.js +0 -27
- package/src/fabric/RNGestureHandlerRootViewNativeComponent.js +0 -19
@@ -34,11 +34,13 @@ class TouchableOpacity extends React.Component {
|
|
34
34
|
_defineProperty(this, "opacity", new _reactNative.Animated.Value(this.getChildStyleOpacityWithDefault()));
|
35
35
|
|
36
36
|
_defineProperty(this, "setOpacityTo", (value, duration) => {
|
37
|
+
var _this$props$useNative;
|
38
|
+
|
37
39
|
_reactNative.Animated.timing(this.opacity, {
|
38
40
|
toValue: value,
|
39
41
|
duration: duration,
|
40
42
|
easing: _reactNative.Easing.inOut(_reactNative.Easing.quad),
|
41
|
-
useNativeDriver:
|
43
|
+
useNativeDriver: (_this$props$useNative = this.props.useNativeAnimations) !== null && _this$props$useNative !== void 0 ? _this$props$useNative : true
|
42
44
|
}).start();
|
43
45
|
});
|
44
46
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["TouchableOpacity.tsx"],"names":["TouchableOpacity","Component","childStyle","StyleSheet","flatten","props","style","opacity","Animated","Value","getChildStyleOpacityWithDefault","value","duration","timing","toValue","easing","Easing","inOut","quad","useNativeDriver","start","_from","to","TOUCHABLE_STATE","BEGAN","setOpacityTo","activeOpacity","UNDETERMINED","MOVED_OUTSIDE","render","rest","onStateChange","children","GenericTouchable","defaultProps"],"mappings":";;;;;;;AAAA;;AAOA;;AAIA;;;;;;;;;;
|
1
|
+
{"version":3,"sources":["TouchableOpacity.tsx"],"names":["TouchableOpacity","Component","childStyle","StyleSheet","flatten","props","style","opacity","Animated","Value","getChildStyleOpacityWithDefault","value","duration","timing","toValue","easing","Easing","inOut","quad","useNativeDriver","useNativeAnimations","start","_from","to","TOUCHABLE_STATE","BEGAN","setOpacityTo","activeOpacity","UNDETERMINED","MOVED_OUTSIDE","render","rest","onStateChange","children","GenericTouchable","defaultProps"],"mappings":";;;;;;;AAAA;;AAOA;;AAIA;;;;;;;;;;AAOA;AACA;AACA;AACe,MAAMA,gBAAN,SAA+BC,eAA/B,CAEb;AAAA;AAAA;;AAAA,6DAOkC,MAAM;AACtC,YAAMC,UAAU,GAAGC,wBAAWC,OAAX,CAAmB,KAAKC,KAAL,CAAWC,KAA9B,KAAwC,EAA3D;AACA,aAAOJ,UAAU,CAACK,OAAX,IAAsB,IAAtB,GAA6B,CAA7B,GAAiCL,UAAU,CAACK,OAAnD;AACD,KAVD;;AAAA,qCAYU,IAAIC,sBAASC,KAAb,CAAmB,KAAKC,+BAAL,EAAnB,CAZV;;AAAA,0CAce,CAACC,KAAD,EAAgBC,QAAhB,KAAqC;AAAA;;AAClDJ,4BAASK,MAAT,CAAgB,KAAKN,OAArB,EAA8B;AAC5BO,QAAAA,OAAO,EAAEH,KADmB;AAE5BC,QAAAA,QAAQ,EAAEA,QAFkB;AAG5BG,QAAAA,MAAM,EAAEC,oBAAOC,KAAP,CAAaD,oBAAOE,IAApB,CAHoB;AAI5BC,QAAAA,eAAe,2BAAE,KAAKd,KAAL,CAAWe,mBAAb,yEAAoC;AAJvB,OAA9B,EAKGC,KALH;AAMD,KArBD;;AAAA,2CAuBgB,CAACC,KAAD,EAAgBC,EAAhB,KAA+B;AAC7C,UAAIA,EAAE,KAAKC,kCAAgBC,KAA3B,EAAkC;AAChC,aAAKC,YAAL,CAAkB,KAAKrB,KAAL,CAAWsB,aAA7B,EAA6C,CAA7C;AACD,OAFD,MAEO,IACLJ,EAAE,KAAKC,kCAAgBI,YAAvB,IACAL,EAAE,KAAKC,kCAAgBK,aAFlB,EAGL;AACA,aAAKH,YAAL,CAAkB,KAAKhB,+BAAL,EAAlB,EAA0D,GAA1D;AACD;AACF,KAhCD;AAAA;;AAkCAoB,EAAAA,MAAM,GAAG;AACP,UAAM;AAAExB,MAAAA,KAAK,GAAG,EAAV;AAAc,SAAGyB;AAAjB,QAA0B,KAAK1B,KAArC;AACA,wBACE,oBAAC,yBAAD,eACM0B,IADN;AAEE,MAAA,KAAK,EAAE,CACLzB,KADK,EAEL;AACEC,QAAAA,OAAO,EAAG,KAAKA,OADjB,CACgD;;AADhD,OAFK,CAFT;AAQE,MAAA,aAAa,EAAE,KAAKyB;AARtB,QASG,KAAK3B,KAAL,CAAW4B,QAAX,GAAsB,KAAK5B,KAAL,CAAW4B,QAAjC,gBAA4C,oBAAC,iBAAD,OAT/C,CADF;AAaD;;AAjDD;;;;gBAFmBjC,gB,kBAGG,EACpB,GAAGkC,0BAAiBC,YADA;AAEpBR,EAAAA,aAAa,EAAE;AAFK,C","sourcesContent":["import {\n Animated,\n Easing,\n StyleSheet,\n View,\n TouchableOpacityProps,\n} from 'react-native';\nimport GenericTouchable, {\n TOUCHABLE_STATE,\n GenericTouchableProps,\n} from './GenericTouchable';\nimport * as React from 'react';\nimport { Component } from 'react';\n\ninterface GHTouchableOpacityProps {\n useNativeAnimations?: boolean;\n}\n\n/**\n * TouchableOpacity bases on timing animation which has been used in RN's core\n */\nexport default class TouchableOpacity extends Component<\n TouchableOpacityProps & GenericTouchableProps & GHTouchableOpacityProps\n> {\n static defaultProps = {\n ...GenericTouchable.defaultProps,\n activeOpacity: 0.2,\n };\n\n // opacity is 1 one by default but could be overwritten\n getChildStyleOpacityWithDefault = () => {\n const childStyle = StyleSheet.flatten(this.props.style) || {};\n return childStyle.opacity == null ? 1 : childStyle.opacity;\n };\n\n opacity = new Animated.Value(this.getChildStyleOpacityWithDefault());\n\n setOpacityTo = (value: number, duration: number) => {\n Animated.timing(this.opacity, {\n toValue: value,\n duration: duration,\n easing: Easing.inOut(Easing.quad),\n useNativeDriver: this.props.useNativeAnimations ?? true,\n }).start();\n };\n\n onStateChange = (_from: number, to: number) => {\n if (to === TOUCHABLE_STATE.BEGAN) {\n this.setOpacityTo(this.props.activeOpacity!, 0);\n } else if (\n to === TOUCHABLE_STATE.UNDETERMINED ||\n to === TOUCHABLE_STATE.MOVED_OUTSIDE\n ) {\n this.setOpacityTo(this.getChildStyleOpacityWithDefault(), 150);\n }\n };\n\n render() {\n const { style = {}, ...rest } = this.props;\n return (\n <GenericTouchable\n {...rest}\n style={[\n style,\n {\n opacity: (this.opacity as unknown) as number, // TODO: fix this\n },\n ]}\n onStateChange={this.onStateChange}>\n {this.props.children ? this.props.children : <View />}\n </GenericTouchable>\n );\n }\n}\n"]}
|
@@ -9,13 +9,11 @@ var _codegenNativeComponent = _interopRequireDefault(require("react-native/Libra
|
|
9
9
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
*/
|
12
|
+
// @ts-ignore TODO: remove once there is a .d.ts file with definitions
|
13
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
14
|
+
const codegenNativeComponent = _codegenNativeComponent.default;
|
16
15
|
|
17
|
-
|
18
|
-
var _default = (0, _codegenNativeComponent.default)('RNGestureHandlerButton', {});
|
16
|
+
var _default = codegenNativeComponent('RNGestureHandlerButton');
|
19
17
|
|
20
18
|
exports.default = _default;
|
21
19
|
//# sourceMappingURL=RNGestureHandlerButtonNativeComponent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["RNGestureHandlerButtonNativeComponent.
|
1
|
+
{"version":3,"sources":["RNGestureHandlerButtonNativeComponent.ts"],"names":["codegenNativeComponent","codegenNativeComponentUntyped"],"mappings":";;;;;;;AACA;;;;AADA;AAYA;AACA,MAAMA,sBAAsB,GAAGC,+BAA/B;;eAaeD,sBAAsB,CAAc,wBAAd,C","sourcesContent":["// @ts-ignore TODO: remove once there is a .d.ts file with definitions\nimport codegenNativeComponentUntyped from 'react-native/Libraries/Utilities/codegenNativeComponent';\n// @ts-ignore TODO: remove once there is a .d.ts file with definitions\nimport type {\n Int32,\n WithDefault,\n // @ts-ignore TODO: remove once there is a .d.ts file with definitions\n} from 'react-native/Libraries/Types/CodegenTypes';\nimport type { ViewProps, HostComponent } from 'react-native';\n// @ts-ignore TODO: remove once there is a .d.ts file with definitions\nimport type { ColorValue } from 'react-native/Libraries/StyleSheet/StyleSheet';\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nconst codegenNativeComponent = codegenNativeComponentUntyped as <T extends {}>(\n name: string\n) => HostComponent<T>;\n\ninterface NativeProps extends ViewProps {\n exclusive?: WithDefault<boolean, true>;\n foreground?: boolean;\n borderless?: boolean;\n enabled?: WithDefault<boolean, true>;\n rippleColor?: ColorValue;\n rippleRadius?: Int32;\n}\n\nexport default codegenNativeComponent<NativeProps>('RNGestureHandlerButton');\n"]}
|
@@ -9,13 +9,11 @@ var _codegenNativeComponent = _interopRequireDefault(require("react-native/Libra
|
|
9
9
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
*/
|
12
|
+
// @ts-ignore TODO: remove once there is a .d.ts file with definitions
|
13
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
14
|
+
const codegenNativeComponent = _codegenNativeComponent.default;
|
16
15
|
|
17
|
-
|
18
|
-
var _default = (0, _codegenNativeComponent.default)('RNGestureHandlerRootView', {});
|
16
|
+
var _default = codegenNativeComponent('RNGestureHandlerRootView');
|
19
17
|
|
20
18
|
exports.default = _default;
|
21
19
|
//# sourceMappingURL=RNGestureHandlerRootViewNativeComponent.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["RNGestureHandlerRootViewNativeComponent.
|
1
|
+
{"version":3,"sources":["RNGestureHandlerRootViewNativeComponent.ts"],"names":["codegenNativeComponent","codegenNativeComponentUntyped"],"mappings":";;;;;;;AACA;;;;AADA;AAIA;AACA,MAAMA,sBAAsB,GAAGC,+BAA/B;;eAMeD,sBAAsB,CAAc,0BAAd,C","sourcesContent":["// @ts-ignore TODO: remove once there is a .d.ts file with definitions\nimport codegenNativeComponentUntyped from 'react-native/Libraries/Utilities/codegenNativeComponent';\nimport type { ViewProps, HostComponent } from 'react-native';\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nconst codegenNativeComponent = codegenNativeComponentUntyped as <T extends {}>(\n name: string\n) => HostComponent<T>;\n\ninterface NativeProps extends ViewProps {}\n\nexport default codegenNativeComponent<NativeProps>('RNGestureHandlerRootView');\n"]}
|
@@ -4,21 +4,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.getShadowNodeFromRef = getShadowNodeFromRef;
|
7
|
-
|
8
7
|
// Used by GestureDetector (unsupported on web at the moment) to check whether the
|
9
8
|
// attached view may get flattened on Fabric. This implementation causes errors
|
10
9
|
// on web due to the static resolution of `require` statements by webpack breaking
|
11
10
|
// the conditional importing. Solved by making .web file.
|
12
|
-
let findHostInstance_DEPRECATED
|
13
|
-
|
14
|
-
try {
|
15
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
16
|
-
findHostInstance_DEPRECATED = require('react-native/Libraries/Renderer/shims/ReactFabric').findHostInstance_DEPRECATED;
|
17
|
-
} catch (e) {// do nothing
|
18
|
-
}
|
11
|
+
let findHostInstance_DEPRECATED;
|
19
12
|
|
20
13
|
function getShadowNodeFromRef(ref) {
|
21
|
-
//
|
14
|
+
// load findHostInstance_DEPRECATED lazily because it may not be available before render
|
15
|
+
if (findHostInstance_DEPRECATED === undefined) {
|
16
|
+
try {
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
18
|
+
findHostInstance_DEPRECATED = require('react-native/Libraries/Renderer/shims/ReactFabric').findHostInstance_DEPRECATED;
|
19
|
+
} catch (e) {
|
20
|
+
findHostInstance_DEPRECATED = _ref => null;
|
21
|
+
}
|
22
|
+
} // @ts-ignore Fabric
|
23
|
+
|
24
|
+
|
22
25
|
return findHostInstance_DEPRECATED(ref)._internalInstanceHandle.stateNode.node;
|
23
26
|
}
|
24
27
|
//# sourceMappingURL=getShadowNodeFromRef.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["getShadowNodeFromRef.ts"],"names":["findHostInstance_DEPRECATED","
|
1
|
+
{"version":3,"sources":["getShadowNodeFromRef.ts"],"names":["findHostInstance_DEPRECATED","getShadowNodeFromRef","ref","undefined","require","e","_ref","_internalInstanceHandle","stateNode","node"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA,IAAIA,2BAAJ;;AAEO,SAASC,oBAAT,CAA8BC,GAA9B,EAAwC;AAC7C;AACA,MAAIF,2BAA2B,KAAKG,SAApC,EAA+C;AAC7C,QAAI;AACF;AACAH,MAAAA,2BAA2B,GAAGI,OAAO,CAAC,mDAAD,CAAP,CAC3BJ,2BADH;AAED,KAJD,CAIE,OAAOK,CAAP,EAAU;AACVL,MAAAA,2BAA2B,GAAIM,IAAD,IAAe,IAA7C;AACD;AACF,GAV4C,CAY7C;;;AACA,SAAON,2BAA2B,CAACE,GAAD,CAA3B,CAAiCK,uBAAjC,CAAyDC,SAAzD,CACJC,IADH;AAED","sourcesContent":["// Used by GestureDetector (unsupported on web at the moment) to check whether the\n// attached view may get flattened on Fabric. This implementation causes errors\n// on web due to the static resolution of `require` statements by webpack breaking\n// the conditional importing. Solved by making .web file.\nlet findHostInstance_DEPRECATED: (ref: any) => void;\n\nexport function getShadowNodeFromRef(ref: any) {\n // load findHostInstance_DEPRECATED lazily because it may not be available before render\n if (findHostInstance_DEPRECATED === undefined) {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n findHostInstance_DEPRECATED = require('react-native/Libraries/Renderer/shims/ReactFabric')\n .findHostInstance_DEPRECATED;\n } catch (e) {\n findHostInstance_DEPRECATED = (_ref: any) => null;\n }\n }\n\n // @ts-ignore Fabric\n return findHostInstance_DEPRECATED(ref)._internalInstanceHandle.stateNode\n .node;\n}\n"]}
|
@@ -128,16 +128,8 @@ const stateToPropMappings = {
|
|
128
128
|
[_State.State.ACTIVE]: 'onActivated',
|
129
129
|
[_State.State.END]: 'onEnded'
|
130
130
|
};
|
131
|
-
let showedRngh2Notice = false;
|
132
|
-
|
133
|
-
function showRngh2NoticeIfNeeded() {
|
134
|
-
if (!showedRngh2Notice) {
|
135
|
-
console.warn((0, _utils.tagMessage)("Seems like you're using an old API with gesture components, check out new Gestures system!"));
|
136
|
-
showedRngh2Notice = true;
|
137
|
-
}
|
138
|
-
} // TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.
|
139
|
-
|
140
131
|
|
132
|
+
// TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.
|
141
133
|
function createHandler({
|
142
134
|
name,
|
143
135
|
allowedProps = [],
|
@@ -252,12 +244,16 @@ function createHandler({
|
|
252
244
|
|
253
245
|
_RNGestureHandlerModule.default.attachGestureHandler(this.handlerTag, newViewTag, actionType);
|
254
246
|
}
|
247
|
+
|
248
|
+
(0, _gestureHandlerCommon.scheduleFlushOperations)();
|
255
249
|
});
|
256
250
|
|
257
251
|
_defineProperty(this, "updateGestureHandler", newConfig => {
|
258
252
|
this.config = newConfig;
|
259
253
|
|
260
254
|
_RNGestureHandlerModule.default.updateGestureHandler(this.handlerTag, newConfig);
|
255
|
+
|
256
|
+
(0, _gestureHandlerCommon.scheduleFlushOperations)();
|
261
257
|
});
|
262
258
|
|
263
259
|
this.handlerTag = (0, _handlersRegistry.getNextHandlerTag)();
|
@@ -274,10 +270,6 @@ function createHandler({
|
|
274
270
|
|
275
271
|
_handlersRegistry.handlerIDToTag[props.id] = this.handlerTag;
|
276
272
|
}
|
277
|
-
|
278
|
-
if (__DEV__ && !(0, _utils.isJestEnv)()) {
|
279
|
-
showRngh2NoticeIfNeeded();
|
280
|
-
}
|
281
273
|
}
|
282
274
|
|
283
275
|
componentDidMount() {
|
@@ -326,6 +318,8 @@ function createHandler({
|
|
326
318
|
|
327
319
|
_RNGestureHandlerModule.default.dropGestureHandler(this.handlerTag);
|
328
320
|
|
321
|
+
(0, _gestureHandlerCommon.scheduleFlushOperations)();
|
322
|
+
|
329
323
|
if (this.updateEnqueued) {
|
330
324
|
clearImmediate(this.updateEnqueued);
|
331
325
|
} // We can't use this.props.id directly due to TS generic type narrowing bug, see https://github.com/microsoft/TypeScript/issues/13995 for more context
|
@@ -356,6 +350,8 @@ function createHandler({
|
|
356
350
|
}
|
357
351
|
|
358
352
|
render() {
|
353
|
+
var _this$props$testID;
|
354
|
+
|
359
355
|
let gestureEventHandler = this.onGestureHandlerEvent; // Another instance of https://github.com/microsoft/TypeScript/issues/13995
|
360
356
|
|
361
357
|
const {
|
@@ -423,7 +419,7 @@ function createHandler({
|
|
423
419
|
handlerType: name,
|
424
420
|
handlerTag: this.handlerTag
|
425
421
|
} : {}),
|
426
|
-
testID: this.props.testID,
|
422
|
+
testID: (_this$props$testID = this.props.testID) !== null && _this$props$testID !== void 0 ? _this$props$testID : child.props.testID,
|
427
423
|
...events
|
428
424
|
}, grandChildren);
|
429
425
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["createHandler.ts"],"names":["UIManagerAny","UIManager","customGHEventsConfigFabricAndroid","topOnGestureHandlerEvent","registrationName","topOnGestureHandlerStateChange","customGHEventsConfig","onGestureHandlerEvent","onGestureHandlerStateChange","Platform","OS","genericDirectEventTypes","UIManagerConstants","getViewManagerConfig","getConstants","setJSResponder","oldSetJSResponder","clearJSResponder","oldClearJSResponder","tag","blockNativeResponder","RNGestureHandlerModule","handleSetJSResponder","handleClearJSResponder","allowTouches","DEV_ON_ANDROID","__DEV__","DeviceEventEmitter","addListener","hasUnresolvedRefs","props","extract","refs","Array","isArray","current","some","r","stateToPropMappings","State","UNDETERMINED","undefined","BEGAN","FAILED","CANCELLED","ACTIVE","END","showedRngh2Notice","showRngh2NoticeIfNeeded","console","warn","createHandler","name","allowedProps","config","transformProps","customNativeProps","Handler","React","Component","constructor","event","nativeEvent","handlerTag","onGestureEvent","onHandlerStateChange","state","stateEventName","eventHandler","node","viewNode","child","Children","only","children","ref","newConfig","createGestureHandler","newViewTag","viewTag","attachGestureHandler","ActionType","JS_FUNCTION_OLD_API","propsRef","onGestureStateChange","actionType","REANIMATED_WORKLET","NATIVE_ANIMATED_EVENT","updateGestureHandler","createRef","id","handlerIDToTag","Error","componentDidMount","inspectorToggleListener","setState","_","update","updateEnqueued","setImmediate","componentDidUpdate","componentWillUnmount","remove","dropGestureHandler","clearImmediate","handlerID","setNativeProps","updates","mergedProps","render","gestureEventHandler","gestureStateEventHandler","events","grandChildren","Touchable","TOUCH_TARGET_DEBUG","type","displayName","toArray","push","renderDebugView","color","hitSlop","cloneElement","refHandler","collapsable","handlerType","testID"],"mappings":";;;;;;;AAAA;;AACA;;AAQA;;AACA;;AAEA;;AACA;;AAMA;;AAQA;;AACA;;;;;;;;;;;;AAEA,MAAMA,YAAY,GAAGC,sBAArB;AAEA,MAAMC,iCAAiC,GAAG;AACxCC,EAAAA,wBAAwB,EAAE;AAAEC,IAAAA,gBAAgB,EAAE;AAApB,GADc;AAExCC,EAAAA,8BAA8B,EAAE;AAC9BD,IAAAA,gBAAgB,EAAE;AADY;AAFQ,CAA1C;AAOA,MAAME,oBAAoB,GAAG;AAC3BC,EAAAA,qBAAqB,EAAE;AAAEH,IAAAA,gBAAgB,EAAE;AAApB,GADI;AAE3BI,EAAAA,2BAA2B,EAAE;AAC3BJ,IAAAA,gBAAgB,EAAE;AADS,GAFF;AAM3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAI,0BACFK,sBAASC,EAAT,KAAgB,SADd,IAEFR,iCAFF;AAd2B,CAA7B,C,CAmBA;AACA;AACA;AACA;;AACAF,YAAY,CAACW,uBAAb,GAAuC,EACrC,GAAGX,YAAY,CAACW,uBADqB;AAErC,KAAGL;AAFkC,CAAvC,C,CAIA;AACA;AACA;;AACA,MAAMM,kBAAkB,sDACtBZ,YAAY,CA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AW4C,QAA/B,CAAnB;AACA,UAAIuC,aAAa,GAAG1C,KAAK,CAACzC,KAAN,CAAY4C,QAAhC;;AACA,UACEwC,uBAAUC,kBAAV,IACA5C,KAAK,CAAC6C,IADN,KAEC7C,KAAK,CAAC6C,IAAN,KAAe,wBAAf,IACC7C,KAAK,CAAC6C,IAAN,CAAWhE,IAAX,KAAoB,MADrB,IAECmB,KAAK,CAAC6C,IAAN,CAAWC,WAAX,KAA2B,MAJ7B,CADF,EAME;AACAJ,QAAAA,aAAa,GAAGvD,KAAK,CAACc,QAAN,CAAe8C,OAAf,CAAuBL,aAAvB,CAAhB;AACAA,QAAAA,aAAa,CAACM,IAAd,CACEL,uBAAUM,eAAV,CAA0B;AACxBC,UAAAA,KAAK,EAAE,mBADiB;AAExBC,UAAAA,OAAO,EAAEnD,KAAK,CAACzC,KAAN,CAAY4F;AAFG,SAA1B,CADF;AAMD;;AAED,0BAAOhE,KAAK,CAACiE,YAAN,CACLpD,KADK,EAEL;AACEI,QAAAA,GAAG,EAAE,KAAKiD,UADZ;AAEEC,QAAAA,WAAW,EAAE,KAFf;AAGE,YAAI,0BACA;AACEC,UAAAA,WAAW,EAAE1E,IADf;AAEEW,UAAAA,UAAU,EAAE,KAAKA;AAFnB,SADA,GAKA,EALJ,CAHF;AASEgE,QAAAA,MAAM,EAAE,KAAKjG,KAAL,CAAWiG,MATrB;AAUE,WAAGf;AAVL,OAFK,EAcLC,aAdK,CAAP;AAgBD;;AAnUD;;AAPwE,kBAIpExD,OAJoE,iBAQnDL,IARmD;;AA4U1E,SAAOK,OAAP;AACD","sourcesContent":["import * as React from 'react';\nimport {\n Platform,\n Touchable,\n UIManager,\n DeviceEventEmitter,\n EmitterSubscription,\n} from 'react-native';\n// @ts-ignore - it isn't typed by TS & don't have definitelyTyped types\nimport deepEqual from 'lodash/isEqual';\nimport RNGestureHandlerModule from '../RNGestureHandlerModule';\nimport type RNGestureHandlerModuleWeb from '../RNGestureHandlerModule.web';\nimport { State } from '../State';\nimport {\n handlerIDToTag,\n getNextHandlerTag,\n registerOldGestureHandler,\n} from './handlersRegistry';\n\nimport {\n BaseGestureHandlerProps,\n filterConfig,\n GestureEvent,\n HandlerStateChangeEvent,\n findNodeHandle,\n} from './gestureHandlerCommon';\nimport { ValueOf } from '../typeUtils';\nimport { isFabric, isJestEnv, tagMessage } from '../utils';\nimport { ActionType } from '../ActionType';\n\nconst UIManagerAny = UIManager as any;\n\nconst customGHEventsConfigFabricAndroid = {\n topOnGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },\n topOnGestureHandlerStateChange: {\n registrationName: 'onGestureHandlerStateChange',\n },\n};\n\nconst customGHEventsConfig = {\n onGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },\n onGestureHandlerStateChange: {\n registrationName: 'onGestureHandlerStateChange',\n },\n\n // When using React Native Gesture Handler for Animated.event with useNativeDriver: true\n // on Android with Fabric enabled, the native part still sends the native events to JS\n // but prefixed with \"top\". We cannot simply rename the events above so they are prefixed\n // with \"top\" instead of \"on\" because in such case Animated.events would not be registered.\n // That's why we need to register another pair of event names.\n // The incoming events will be queued but never handled.\n // Without this piece of code below, you'll get the following JS error:\n // Unsupported top level event type \"topOnGestureHandlerEvent\" dispatched\n ...(isFabric() &&\n Platform.OS === 'android' &&\n customGHEventsConfigFabricAndroid),\n};\n\n// Add gesture specific events to genericDirectEventTypes object exported from UIManager\n// native module.\n// Once new event types are registered with react it is possible to dispatch these\n// events to all kind of native views.\nUIManagerAny.genericDirectEventTypes = {\n ...UIManagerAny.genericDirectEventTypes,\n ...customGHEventsConfig,\n};\n// In newer versions of RN the `genericDirectEventTypes` is located in the object\n// returned by UIManager.getViewManagerConfig('getConstants') or in older RN UIManager.getConstants(), we need to add it there as well to make\n// it compatible with RN 61+\nconst UIManagerConstants =\n UIManagerAny.getViewManagerConfig?.('getConstants') ??\n UIManagerAny.getConstants?.();\n\nif (UIManagerConstants) {\n UIManagerConstants.genericDirectEventTypes = {\n ...UIManagerConstants.genericDirectEventTypes,\n ...customGHEventsConfig,\n };\n}\n\n// Wrap JS responder calls and notify gesture handler manager\nconst {\n setJSResponder: oldSetJSResponder = () => {\n //no operation\n },\n clearJSResponder: oldClearJSResponder = () => {\n //no operation\n },\n} = UIManagerAny;\nUIManagerAny.setJSResponder = (tag: number, blockNativeResponder: boolean) => {\n RNGestureHandlerModule.handleSetJSResponder(tag, blockNativeResponder);\n oldSetJSResponder(tag, blockNativeResponder);\n};\nUIManagerAny.clearJSResponder = () => {\n RNGestureHandlerModule.handleClearJSResponder();\n oldClearJSResponder();\n};\n\nlet allowTouches = true;\nconst DEV_ON_ANDROID = __DEV__ && Platform.OS === 'android';\n// Toggled inspector blocks touch events in order to allow inspecting on Android\n// This needs to be a global variable in order to set initial state for `allowTouches` property in Handler component\nif (DEV_ON_ANDROID) {\n DeviceEventEmitter.addListener('toggleElementInspector', () => {\n allowTouches = !allowTouches;\n });\n}\n\ntype HandlerProps<T extends Record<string, unknown>> = Readonly<\n React.PropsWithChildren<BaseGestureHandlerProps<T>>\n>;\nfunction hasUnresolvedRefs<T extends Record<string, unknown>>(\n props: HandlerProps<T>\n) {\n // TODO(TS) - add type for extract arg\n const extract = (refs: any | any[]) => {\n if (!Array.isArray(refs)) {\n return refs && refs.current === null;\n }\n return refs.some((r) => r && r.current === null);\n };\n return extract(props['simultaneousHandlers']) || extract(props['waitFor']);\n}\n\nconst stateToPropMappings = {\n [State.UNDETERMINED]: undefined,\n [State.BEGAN]: 'onBegan',\n [State.FAILED]: 'onFailed',\n [State.CANCELLED]: 'onCancelled',\n [State.ACTIVE]: 'onActivated',\n [State.END]: 'onEnded',\n} as const;\n\ntype CreateHandlerArgs<\n HandlerPropsT extends Record<string, unknown>\n> = Readonly<{\n name: string;\n allowedProps: Readonly<Extract<keyof HandlerPropsT, string>[]>;\n config: Readonly<Record<string, unknown>>;\n transformProps?: (props: HandlerPropsT) => HandlerPropsT;\n customNativeProps?: Readonly<string[]>;\n}>;\n\n// TODO(TS) fix event types\ntype InternalEventHandlers = {\n onGestureHandlerEvent?: (event: any) => void;\n onGestureHandlerStateChange?: (event: any) => void;\n};\n\nlet showedRngh2Notice = false;\nfunction showRngh2NoticeIfNeeded() {\n if (!showedRngh2Notice) {\n console.warn(\n tagMessage(\n \"Seems like you're using an old API with gesture components, check out new Gestures system!\"\n )\n );\n showedRngh2Notice = true;\n }\n}\n\n// TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.\nexport default function createHandler<\n T extends BaseGestureHandlerProps<U>,\n U extends Record<string, unknown>\n>({\n name,\n allowedProps = [],\n config = {},\n transformProps,\n customNativeProps = [],\n}: CreateHandlerArgs<T>): React.ComponentType<T & React.RefAttributes<any>> {\n interface HandlerState {\n allowTouches: boolean;\n }\n class Handler extends React.Component<\n T & InternalEventHandlers,\n HandlerState\n > {\n static displayName = name;\n\n private handlerTag: number;\n private config: Record<string, unknown>;\n private propsRef: React.MutableRefObject<unknown>;\n private viewNode: any;\n private viewTag?: number;\n private updateEnqueued: ReturnType<typeof setImmediate> | null = null;\n private inspectorToggleListener?: EmitterSubscription;\n\n constructor(props: T & InternalEventHandlers) {\n super(props);\n this.handlerTag = getNextHandlerTag();\n this.config = {};\n this.propsRef = React.createRef();\n this.state = { allowTouches };\n if (props.id) {\n if (handlerIDToTag[props.id] !== undefined) {\n throw new Error(`Handler with ID \"${props.id}\" already registered`);\n }\n handlerIDToTag[props.id] = this.handlerTag;\n }\n if (__DEV__ && !isJestEnv()) {\n showRngh2NoticeIfNeeded();\n }\n }\n\n componentDidMount() {\n const props: HandlerProps<U> = this.props;\n\n if (DEV_ON_ANDROID) {\n this.inspectorToggleListener = DeviceEventEmitter.addListener(\n 'toggleElementInspector',\n () => {\n this.setState((_) => ({ allowTouches }));\n this.update();\n }\n );\n }\n if (hasUnresolvedRefs(props)) {\n // If there are unresolved refs (e.g. \".current\" has not yet been set)\n // passed as `simultaneousHandlers` or `waitFor`, we enqueue a call to\n // _update method that will try to update native handler props using\n // setImmediate. This makes it so update() function gets called after all\n // react components are mounted and we expect the missing ref object to\n // be resolved by then.\n this.updateEnqueued = setImmediate(() => {\n this.updateEnqueued = null;\n this.update();\n });\n }\n\n this.createGestureHandler(\n filterConfig(\n transformProps ? transformProps(this.props) : this.props,\n [...allowedProps, ...customNativeProps],\n config\n )\n );\n\n this.attachGestureHandler(findNodeHandle(this.viewNode) as number); // TODO(TS) - check if this can be null\n }\n\n componentDidUpdate() {\n const viewTag = findNodeHandle(this.viewNode);\n if (this.viewTag !== viewTag) {\n this.attachGestureHandler(viewTag as number); // TODO(TS) - check interaction between _viewTag & findNodeHandle\n }\n this.update();\n }\n\n componentWillUnmount() {\n this.inspectorToggleListener?.remove();\n RNGestureHandlerModule.dropGestureHandler(this.handlerTag);\n if (this.updateEnqueued) {\n clearImmediate(this.updateEnqueued);\n }\n // We can't use this.props.id directly due to TS generic type narrowing bug, see https://github.com/microsoft/TypeScript/issues/13995 for more context\n const handlerID: string | undefined = this.props.id;\n if (handlerID) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete handlerIDToTag[handlerID];\n }\n }\n\n private onGestureHandlerEvent = (event: GestureEvent<U>) => {\n if (event.nativeEvent.handlerTag === this.handlerTag) {\n if (typeof this.props.onGestureEvent === 'function') {\n this.props.onGestureEvent?.(event);\n }\n } else {\n this.props.onGestureHandlerEvent?.(event);\n }\n };\n\n // TODO(TS) - make sure this is right type for event\n private onGestureHandlerStateChange = (\n event: HandlerStateChangeEvent<U>\n ) => {\n if (event.nativeEvent.handlerTag === this.handlerTag) {\n if (typeof this.props.onHandlerStateChange === 'function') {\n this.props.onHandlerStateChange?.(event);\n }\n\n const state: ValueOf<typeof State> = event.nativeEvent.state;\n const stateEventName = stateToPropMappings[state];\n const eventHandler = stateEventName && this.props[stateEventName];\n if (eventHandler && typeof eventHandler === 'function') {\n eventHandler(event);\n }\n } else {\n this.props.onGestureHandlerStateChange?.(event);\n }\n };\n\n private refHandler = (node: any) => {\n this.viewNode = node;\n\n const child = React.Children.only(this.props.children);\n // TODO(TS) fix ref type\n const { ref }: any = child;\n if (ref !== null) {\n if (typeof ref === 'function') {\n ref(node);\n } else {\n ref.current = node;\n }\n }\n };\n\n private createGestureHandler = (\n newConfig: Readonly<Record<string, unknown>>\n ) => {\n this.config = newConfig;\n\n RNGestureHandlerModule.createGestureHandler(\n name,\n this.handlerTag,\n newConfig\n );\n };\n\n private attachGestureHandler = (newViewTag: number) => {\n this.viewTag = newViewTag;\n\n if (Platform.OS === 'web') {\n // typecast due to dynamic resolution, attachGestureHandler should have web version signature in this branch\n (RNGestureHandlerModule.attachGestureHandler as typeof RNGestureHandlerModuleWeb.attachGestureHandler)(\n this.handlerTag,\n newViewTag,\n ActionType.JS_FUNCTION_OLD_API, // ignored on web\n this.propsRef\n );\n } else {\n registerOldGestureHandler(this.handlerTag, {\n onGestureEvent: this.onGestureHandlerEvent,\n onGestureStateChange: this.onGestureHandlerStateChange,\n });\n\n const actionType = (() => {\n if (\n this.props?.onGestureEvent &&\n 'current' in this.props.onGestureEvent\n ) {\n // Reanimated worklet\n return ActionType.REANIMATED_WORKLET;\n } else if (\n this.props?.onGestureEvent &&\n '__isNative' in this.props.onGestureEvent\n ) {\n // Animated.event with useNativeDriver: true\n return ActionType.NATIVE_ANIMATED_EVENT;\n } else {\n // JS callback or Animated.event with useNativeDriver: false\n return ActionType.JS_FUNCTION_OLD_API;\n }\n })();\n\n RNGestureHandlerModule.attachGestureHandler(\n this.handlerTag,\n newViewTag,\n actionType\n );\n }\n };\n\n private updateGestureHandler = (\n newConfig: Readonly<Record<string, unknown>>\n ) => {\n this.config = newConfig;\n\n RNGestureHandlerModule.updateGestureHandler(this.handlerTag, newConfig);\n };\n\n private update() {\n const newConfig = filterConfig(\n transformProps ? transformProps(this.props) : this.props,\n [...allowedProps, ...customNativeProps],\n config\n );\n if (!deepEqual(this.config, newConfig)) {\n this.updateGestureHandler(newConfig);\n }\n }\n\n setNativeProps(updates: any) {\n const mergedProps = { ...this.props, ...updates };\n const newConfig = filterConfig(\n transformProps ? transformProps(mergedProps) : mergedProps,\n [...allowedProps, ...customNativeProps],\n config\n );\n this.updateGestureHandler(newConfig);\n }\n\n render() {\n let gestureEventHandler = this.onGestureHandlerEvent;\n // Another instance of https://github.com/microsoft/TypeScript/issues/13995\n type OnGestureEventHandlers = {\n onGestureEvent?: BaseGestureHandlerProps<U>['onGestureEvent'];\n onGestureHandlerEvent?: InternalEventHandlers['onGestureHandlerEvent'];\n };\n const {\n onGestureEvent,\n onGestureHandlerEvent,\n }: OnGestureEventHandlers = this.props;\n if (onGestureEvent && typeof onGestureEvent !== 'function') {\n // If it's not a method it should be an native Animated.event\n // object. We set it directly as the handler for the view\n // In this case nested handlers are not going to be supported\n if (onGestureHandlerEvent) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n gestureEventHandler = onGestureEvent;\n } else {\n if (\n onGestureHandlerEvent &&\n typeof onGestureHandlerEvent !== 'function'\n ) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n }\n\n let gestureStateEventHandler = this.onGestureHandlerStateChange;\n // Another instance of https://github.com/microsoft/TypeScript/issues/13995\n type OnGestureStateChangeHandlers = {\n onHandlerStateChange?: BaseGestureHandlerProps<U>['onHandlerStateChange'];\n onGestureHandlerStateChange?: InternalEventHandlers['onGestureHandlerStateChange'];\n };\n const {\n onHandlerStateChange,\n onGestureHandlerStateChange,\n }: OnGestureStateChangeHandlers = this.props;\n if (onHandlerStateChange && typeof onHandlerStateChange !== 'function') {\n // If it's not a method it should be an native Animated.event\n // object. We set it directly as the handler for the view\n // In this case nested handlers are not going to be supported\n if (onGestureHandlerStateChange) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n gestureStateEventHandler = onHandlerStateChange;\n } else {\n if (\n onGestureHandlerStateChange &&\n typeof onGestureHandlerStateChange !== 'function'\n ) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n }\n const events = {\n onGestureHandlerEvent: this.state.allowTouches\n ? gestureEventHandler\n : undefined,\n onGestureHandlerStateChange: this.state.allowTouches\n ? gestureStateEventHandler\n : undefined,\n };\n\n this.propsRef.current = events;\n\n const child: any = React.Children.only(this.props.children);\n let grandChildren = child.props.children;\n if (\n Touchable.TOUCH_TARGET_DEBUG &&\n child.type &&\n (child.type === 'RNGestureHandlerButton' ||\n child.type.name === 'View' ||\n child.type.displayName === 'View')\n ) {\n grandChildren = React.Children.toArray(grandChildren);\n grandChildren.push(\n Touchable.renderDebugView({\n color: 'mediumspringgreen',\n hitSlop: child.props.hitSlop,\n })\n );\n }\n\n return React.cloneElement(\n child,\n {\n ref: this.refHandler,\n collapsable: false,\n ...(isJestEnv()\n ? {\n handlerType: name,\n handlerTag: this.handlerTag,\n }\n : {}),\n testID: this.props.testID,\n ...events,\n },\n grandChildren\n );\n }\n }\n return Handler;\n}\n"]}
|
1
|
+
{"version":3,"sources":["createHandler.ts"],"names":["UIManagerAny","UIManager","customGHEventsConfigFabricAndroid","topOnGestureHandlerEvent","registrationName","topOnGestureHandlerStateChange","customGHEventsConfig","onGestureHandlerEvent","onGestureHandlerStateChange","Platform","OS","genericDirectEventTypes","UIManagerConstants","getViewManagerConfig","getConstants","setJSResponder","oldSetJSResponder","clearJSResponder","oldClearJSResponder","tag","blockNativeResponder","RNGestureHandlerModule","handleSetJSResponder","handleClearJSResponder","allowTouches","DEV_ON_ANDROID","__DEV__","DeviceEventEmitter","addListener","hasUnresolvedRefs","props","extract","refs","Array","isArray","current","some","r","stateToPropMappings","State","UNDETERMINED","undefined","BEGAN","FAILED","CANCELLED","ACTIVE","END","createHandler","name","allowedProps","config","transformProps","customNativeProps","Handler","React","Component","constructor","event","nativeEvent","handlerTag","onGestureEvent","onHandlerStateChange","state","stateEventName","eventHandler","node","viewNode","child","Children","only","children","ref","newConfig","createGestureHandler","newViewTag","viewTag","attachGestureHandler","ActionType","JS_FUNCTION_OLD_API","propsRef","onGestureStateChange","actionType","REANIMATED_WORKLET","NATIVE_ANIMATED_EVENT","updateGestureHandler","createRef","id","handlerIDToTag","Error","componentDidMount","inspectorToggleListener","setState","_","update","updateEnqueued","setImmediate","componentDidUpdate","componentWillUnmount","remove","dropGestureHandler","clearImmediate","handlerID","setNativeProps","updates","mergedProps","render","gestureEventHandler","gestureStateEventHandler","events","grandChildren","Touchable","TOUCH_TARGET_DEBUG","type","displayName","toArray","push","renderDebugView","color","hitSlop","cloneElement","refHandler","collapsable","handlerType","testID"],"mappings":";;;;;;;AAAA;;AACA;;AAQA;;AACA;;AAEA;;AACA;;AAMA;;AASA;;AACA;;;;;;;;;;;;AAEA,MAAMA,YAAY,GAAGC,sBAArB;AAEA,MAAMC,iCAAiC,GAAG;AACxCC,EAAAA,wBAAwB,EAAE;AAAEC,IAAAA,gBAAgB,EAAE;AAApB,GADc;AAExCC,EAAAA,8BAA8B,EAAE;AAC9BD,IAAAA,gBAAgB,EAAE;AADY;AAFQ,CAA1C;AAOA,MAAME,oBAAoB,GAAG;AAC3BC,EAAAA,qBAAqB,EAAE;AAAEH,IAAAA,gBAAgB,EAAE;AAApB,GADI;AAE3BI,EAAAA,2BAA2B,EAAE;AAC3BJ,IAAAA,gBAAgB,EAAE;AADS,GAFF;AAM3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAI,0BACFK,sBAASC,EAAT,KAAgB,SADd,IAEFR,iCAFF;AAd2B,CAA7B,C,CAmBA;AACA;AACA;AACA;;AACAF,YAAY,CAACW,uBAAb,GAAuC,EACrC,GAAGX,YAAY,CAACW,uBADqB;AAErC,KAAGL;AAFkC,CAAvC,C,CAIA;AACA;AACA;;AACA,MAAMM,kBAAkB,sDACtBZ,YAAY,CAACa,oBADS,2DACtB,4BAAAb,YAAY,EAAwB,cAAxB,CADU,kGAEtBA,YAAY,CAACc,YAFS,0DAEtB,2BAAAd,YAAY,CAFd;;AAIA,IAAIY,kBAAJ,EAAwB;AACtBA,EAAA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ACM,IAAd,CACEL,uBAAUM,eAAV,CAA0B;AACxBC,UAAAA,KAAK,EAAE,mBADiB;AAExBC,UAAAA,OAAO,EAAEnD,KAAK,CAACrC,KAAN,CAAYwF;AAFG,SAA1B,CADF;AAMD;;AAED,0BAAOhE,KAAK,CAACiE,YAAN,CACLpD,KADK,EAEL;AACEI,QAAAA,GAAG,EAAE,KAAKiD,UADZ;AAEEC,QAAAA,WAAW,EAAE,KAFf;AAGE,YAAI,0BACA;AACEC,UAAAA,WAAW,EAAE1E,IADf;AAEEW,UAAAA,UAAU,EAAE,KAAKA;AAFnB,SADA,GAKA,EALJ,CAHF;AASEgE,QAAAA,MAAM,wBAAE,KAAK7F,KAAL,CAAW6F,MAAb,mEAAuBxD,KAAK,CAACrC,KAAN,CAAY6F,MAT3C;AAUE,WAAGf;AAVL,OAFK,EAcLC,aAdK,CAAP;AAgBD;;AApUD;;AAPwE,kBAIpExD,OAJoE,iBAQnDL,IARmD;;AA6U1E,SAAOK,OAAP;AACD","sourcesContent":["import * as React from 'react';\nimport {\n Platform,\n Touchable,\n UIManager,\n DeviceEventEmitter,\n EmitterSubscription,\n} from 'react-native';\n// @ts-ignore - it isn't typed by TS & don't have definitelyTyped types\nimport deepEqual from 'lodash/isEqual';\nimport RNGestureHandlerModule from '../RNGestureHandlerModule';\nimport type RNGestureHandlerModuleWeb from '../RNGestureHandlerModule.web';\nimport { State } from '../State';\nimport {\n handlerIDToTag,\n getNextHandlerTag,\n registerOldGestureHandler,\n} from './handlersRegistry';\n\nimport {\n BaseGestureHandlerProps,\n filterConfig,\n GestureEvent,\n HandlerStateChangeEvent,\n findNodeHandle,\n scheduleFlushOperations,\n} from './gestureHandlerCommon';\nimport { ValueOf } from '../typeUtils';\nimport { isFabric, isJestEnv } from '../utils';\nimport { ActionType } from '../ActionType';\n\nconst UIManagerAny = UIManager as any;\n\nconst customGHEventsConfigFabricAndroid = {\n topOnGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },\n topOnGestureHandlerStateChange: {\n registrationName: 'onGestureHandlerStateChange',\n },\n};\n\nconst customGHEventsConfig = {\n onGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },\n onGestureHandlerStateChange: {\n registrationName: 'onGestureHandlerStateChange',\n },\n\n // When using React Native Gesture Handler for Animated.event with useNativeDriver: true\n // on Android with Fabric enabled, the native part still sends the native events to JS\n // but prefixed with \"top\". We cannot simply rename the events above so they are prefixed\n // with \"top\" instead of \"on\" because in such case Animated.events would not be registered.\n // That's why we need to register another pair of event names.\n // The incoming events will be queued but never handled.\n // Without this piece of code below, you'll get the following JS error:\n // Unsupported top level event type \"topOnGestureHandlerEvent\" dispatched\n ...(isFabric() &&\n Platform.OS === 'android' &&\n customGHEventsConfigFabricAndroid),\n};\n\n// Add gesture specific events to genericDirectEventTypes object exported from UIManager\n// native module.\n// Once new event types are registered with react it is possible to dispatch these\n// events to all kind of native views.\nUIManagerAny.genericDirectEventTypes = {\n ...UIManagerAny.genericDirectEventTypes,\n ...customGHEventsConfig,\n};\n// In newer versions of RN the `genericDirectEventTypes` is located in the object\n// returned by UIManager.getViewManagerConfig('getConstants') or in older RN UIManager.getConstants(), we need to add it there as well to make\n// it compatible with RN 61+\nconst UIManagerConstants =\n UIManagerAny.getViewManagerConfig?.('getConstants') ??\n UIManagerAny.getConstants?.();\n\nif (UIManagerConstants) {\n UIManagerConstants.genericDirectEventTypes = {\n ...UIManagerConstants.genericDirectEventTypes,\n ...customGHEventsConfig,\n };\n}\n\n// Wrap JS responder calls and notify gesture handler manager\nconst {\n setJSResponder: oldSetJSResponder = () => {\n //no operation\n },\n clearJSResponder: oldClearJSResponder = () => {\n //no operation\n },\n} = UIManagerAny;\nUIManagerAny.setJSResponder = (tag: number, blockNativeResponder: boolean) => {\n RNGestureHandlerModule.handleSetJSResponder(tag, blockNativeResponder);\n oldSetJSResponder(tag, blockNativeResponder);\n};\nUIManagerAny.clearJSResponder = () => {\n RNGestureHandlerModule.handleClearJSResponder();\n oldClearJSResponder();\n};\n\nlet allowTouches = true;\nconst DEV_ON_ANDROID = __DEV__ && Platform.OS === 'android';\n// Toggled inspector blocks touch events in order to allow inspecting on Android\n// This needs to be a global variable in order to set initial state for `allowTouches` property in Handler component\nif (DEV_ON_ANDROID) {\n DeviceEventEmitter.addListener('toggleElementInspector', () => {\n allowTouches = !allowTouches;\n });\n}\n\ntype HandlerProps<T extends Record<string, unknown>> = Readonly<\n React.PropsWithChildren<BaseGestureHandlerProps<T>>\n>;\nfunction hasUnresolvedRefs<T extends Record<string, unknown>>(\n props: HandlerProps<T>\n) {\n // TODO(TS) - add type for extract arg\n const extract = (refs: any | any[]) => {\n if (!Array.isArray(refs)) {\n return refs && refs.current === null;\n }\n return refs.some((r) => r && r.current === null);\n };\n return extract(props['simultaneousHandlers']) || extract(props['waitFor']);\n}\n\nconst stateToPropMappings = {\n [State.UNDETERMINED]: undefined,\n [State.BEGAN]: 'onBegan',\n [State.FAILED]: 'onFailed',\n [State.CANCELLED]: 'onCancelled',\n [State.ACTIVE]: 'onActivated',\n [State.END]: 'onEnded',\n} as const;\n\ntype CreateHandlerArgs<\n HandlerPropsT extends Record<string, unknown>\n> = Readonly<{\n name: string;\n allowedProps: Readonly<Extract<keyof HandlerPropsT, string>[]>;\n config: Readonly<Record<string, unknown>>;\n transformProps?: (props: HandlerPropsT) => HandlerPropsT;\n customNativeProps?: Readonly<string[]>;\n}>;\n\n// TODO(TS) fix event types\ntype InternalEventHandlers = {\n onGestureHandlerEvent?: (event: any) => void;\n onGestureHandlerStateChange?: (event: any) => void;\n};\n\n// TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.\nexport default function createHandler<\n T extends BaseGestureHandlerProps<U>,\n U extends Record<string, unknown>\n>({\n name,\n allowedProps = [],\n config = {},\n transformProps,\n customNativeProps = [],\n}: CreateHandlerArgs<T>): React.ComponentType<T & React.RefAttributes<any>> {\n interface HandlerState {\n allowTouches: boolean;\n }\n class Handler extends React.Component<\n T & InternalEventHandlers,\n HandlerState\n > {\n static displayName = name;\n\n private handlerTag: number;\n private config: Record<string, unknown>;\n private propsRef: React.MutableRefObject<unknown>;\n private viewNode: any;\n private viewTag?: number;\n private updateEnqueued: ReturnType<typeof setImmediate> | null = null;\n private inspectorToggleListener?: EmitterSubscription;\n\n constructor(props: T & InternalEventHandlers) {\n super(props);\n this.handlerTag = getNextHandlerTag();\n this.config = {};\n this.propsRef = React.createRef();\n this.state = { allowTouches };\n if (props.id) {\n if (handlerIDToTag[props.id] !== undefined) {\n throw new Error(`Handler with ID \"${props.id}\" already registered`);\n }\n handlerIDToTag[props.id] = this.handlerTag;\n }\n }\n\n componentDidMount() {\n const props: HandlerProps<U> = this.props;\n\n if (DEV_ON_ANDROID) {\n this.inspectorToggleListener = DeviceEventEmitter.addListener(\n 'toggleElementInspector',\n () => {\n this.setState((_) => ({ allowTouches }));\n this.update();\n }\n );\n }\n if (hasUnresolvedRefs(props)) {\n // If there are unresolved refs (e.g. \".current\" has not yet been set)\n // passed as `simultaneousHandlers` or `waitFor`, we enqueue a call to\n // _update method that will try to update native handler props using\n // setImmediate. This makes it so update() function gets called after all\n // react components are mounted and we expect the missing ref object to\n // be resolved by then.\n this.updateEnqueued = setImmediate(() => {\n this.updateEnqueued = null;\n this.update();\n });\n }\n\n this.createGestureHandler(\n filterConfig(\n transformProps ? transformProps(this.props) : this.props,\n [...allowedProps, ...customNativeProps],\n config\n )\n );\n\n this.attachGestureHandler(findNodeHandle(this.viewNode) as number); // TODO(TS) - check if this can be null\n }\n\n componentDidUpdate() {\n const viewTag = findNodeHandle(this.viewNode);\n if (this.viewTag !== viewTag) {\n this.attachGestureHandler(viewTag as number); // TODO(TS) - check interaction between _viewTag & findNodeHandle\n }\n this.update();\n }\n\n componentWillUnmount() {\n this.inspectorToggleListener?.remove();\n RNGestureHandlerModule.dropGestureHandler(this.handlerTag);\n scheduleFlushOperations();\n if (this.updateEnqueued) {\n clearImmediate(this.updateEnqueued);\n }\n // We can't use this.props.id directly due to TS generic type narrowing bug, see https://github.com/microsoft/TypeScript/issues/13995 for more context\n const handlerID: string | undefined = this.props.id;\n if (handlerID) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete handlerIDToTag[handlerID];\n }\n }\n\n private onGestureHandlerEvent = (event: GestureEvent<U>) => {\n if (event.nativeEvent.handlerTag === this.handlerTag) {\n if (typeof this.props.onGestureEvent === 'function') {\n this.props.onGestureEvent?.(event);\n }\n } else {\n this.props.onGestureHandlerEvent?.(event);\n }\n };\n\n // TODO(TS) - make sure this is right type for event\n private onGestureHandlerStateChange = (\n event: HandlerStateChangeEvent<U>\n ) => {\n if (event.nativeEvent.handlerTag === this.handlerTag) {\n if (typeof this.props.onHandlerStateChange === 'function') {\n this.props.onHandlerStateChange?.(event);\n }\n\n const state: ValueOf<typeof State> = event.nativeEvent.state;\n const stateEventName = stateToPropMappings[state];\n const eventHandler = stateEventName && this.props[stateEventName];\n if (eventHandler && typeof eventHandler === 'function') {\n eventHandler(event);\n }\n } else {\n this.props.onGestureHandlerStateChange?.(event);\n }\n };\n\n private refHandler = (node: any) => {\n this.viewNode = node;\n\n const child = React.Children.only(this.props.children);\n // TODO(TS) fix ref type\n const { ref }: any = child;\n if (ref !== null) {\n if (typeof ref === 'function') {\n ref(node);\n } else {\n ref.current = node;\n }\n }\n };\n\n private createGestureHandler = (\n newConfig: Readonly<Record<string, unknown>>\n ) => {\n this.config = newConfig;\n\n RNGestureHandlerModule.createGestureHandler(\n name,\n this.handlerTag,\n newConfig\n );\n };\n\n private attachGestureHandler = (newViewTag: number) => {\n this.viewTag = newViewTag;\n\n if (Platform.OS === 'web') {\n // typecast due to dynamic resolution, attachGestureHandler should have web version signature in this branch\n (RNGestureHandlerModule.attachGestureHandler as typeof RNGestureHandlerModuleWeb.attachGestureHandler)(\n this.handlerTag,\n newViewTag,\n ActionType.JS_FUNCTION_OLD_API, // ignored on web\n this.propsRef\n );\n } else {\n registerOldGestureHandler(this.handlerTag, {\n onGestureEvent: this.onGestureHandlerEvent,\n onGestureStateChange: this.onGestureHandlerStateChange,\n });\n\n const actionType = (() => {\n if (\n this.props?.onGestureEvent &&\n 'current' in this.props.onGestureEvent\n ) {\n // Reanimated worklet\n return ActionType.REANIMATED_WORKLET;\n } else if (\n this.props?.onGestureEvent &&\n '__isNative' in this.props.onGestureEvent\n ) {\n // Animated.event with useNativeDriver: true\n return ActionType.NATIVE_ANIMATED_EVENT;\n } else {\n // JS callback or Animated.event with useNativeDriver: false\n return ActionType.JS_FUNCTION_OLD_API;\n }\n })();\n\n RNGestureHandlerModule.attachGestureHandler(\n this.handlerTag,\n newViewTag,\n actionType\n );\n }\n\n scheduleFlushOperations();\n };\n\n private updateGestureHandler = (\n newConfig: Readonly<Record<string, unknown>>\n ) => {\n this.config = newConfig;\n\n RNGestureHandlerModule.updateGestureHandler(this.handlerTag, newConfig);\n scheduleFlushOperations();\n };\n\n private update() {\n const newConfig = filterConfig(\n transformProps ? transformProps(this.props) : this.props,\n [...allowedProps, ...customNativeProps],\n config\n );\n if (!deepEqual(this.config, newConfig)) {\n this.updateGestureHandler(newConfig);\n }\n }\n\n setNativeProps(updates: any) {\n const mergedProps = { ...this.props, ...updates };\n const newConfig = filterConfig(\n transformProps ? transformProps(mergedProps) : mergedProps,\n [...allowedProps, ...customNativeProps],\n config\n );\n this.updateGestureHandler(newConfig);\n }\n\n render() {\n let gestureEventHandler = this.onGestureHandlerEvent;\n // Another instance of https://github.com/microsoft/TypeScript/issues/13995\n type OnGestureEventHandlers = {\n onGestureEvent?: BaseGestureHandlerProps<U>['onGestureEvent'];\n onGestureHandlerEvent?: InternalEventHandlers['onGestureHandlerEvent'];\n };\n const {\n onGestureEvent,\n onGestureHandlerEvent,\n }: OnGestureEventHandlers = this.props;\n if (onGestureEvent && typeof onGestureEvent !== 'function') {\n // If it's not a method it should be an native Animated.event\n // object. We set it directly as the handler for the view\n // In this case nested handlers are not going to be supported\n if (onGestureHandlerEvent) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n gestureEventHandler = onGestureEvent;\n } else {\n if (\n onGestureHandlerEvent &&\n typeof onGestureHandlerEvent !== 'function'\n ) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n }\n\n let gestureStateEventHandler = this.onGestureHandlerStateChange;\n // Another instance of https://github.com/microsoft/TypeScript/issues/13995\n type OnGestureStateChangeHandlers = {\n onHandlerStateChange?: BaseGestureHandlerProps<U>['onHandlerStateChange'];\n onGestureHandlerStateChange?: InternalEventHandlers['onGestureHandlerStateChange'];\n };\n const {\n onHandlerStateChange,\n onGestureHandlerStateChange,\n }: OnGestureStateChangeHandlers = this.props;\n if (onHandlerStateChange && typeof onHandlerStateChange !== 'function') {\n // If it's not a method it should be an native Animated.event\n // object. We set it directly as the handler for the view\n // In this case nested handlers are not going to be supported\n if (onGestureHandlerStateChange) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n gestureStateEventHandler = onHandlerStateChange;\n } else {\n if (\n onGestureHandlerStateChange &&\n typeof onGestureHandlerStateChange !== 'function'\n ) {\n throw new Error(\n 'Nesting touch handlers with native animated driver is not supported yet'\n );\n }\n }\n const events = {\n onGestureHandlerEvent: this.state.allowTouches\n ? gestureEventHandler\n : undefined,\n onGestureHandlerStateChange: this.state.allowTouches\n ? gestureStateEventHandler\n : undefined,\n };\n\n this.propsRef.current = events;\n\n const child: any = React.Children.only(this.props.children);\n let grandChildren = child.props.children;\n if (\n Touchable.TOUCH_TARGET_DEBUG &&\n child.type &&\n (child.type === 'RNGestureHandlerButton' ||\n child.type.name === 'View' ||\n child.type.displayName === 'View')\n ) {\n grandChildren = React.Children.toArray(grandChildren);\n grandChildren.push(\n Touchable.renderDebugView({\n color: 'mediumspringgreen',\n hitSlop: child.props.hitSlop,\n })\n );\n }\n\n return React.cloneElement(\n child,\n {\n ref: this.refHandler,\n collapsable: false,\n ...(isJestEnv()\n ? {\n handlerType: name,\n handlerTag: this.handlerTag,\n }\n : {}),\n testID: this.props.testID ?? child.props.testID,\n ...events,\n },\n grandChildren\n );\n }\n }\n return Handler;\n}\n"]}
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.filterConfig = filterConfig;
|
7
7
|
exports.findNodeHandle = findNodeHandle;
|
8
|
+
exports.scheduleFlushOperations = scheduleFlushOperations;
|
8
9
|
exports.baseGestureHandlerWithMonitorProps = exports.baseGestureHandlerProps = void 0;
|
9
10
|
|
10
11
|
var _reactNative = require("react-native");
|
@@ -13,11 +14,15 @@ var _handlersRegistry = require("./handlersRegistry");
|
|
13
14
|
|
14
15
|
var _utils = require("../utils");
|
15
16
|
|
17
|
+
var _RNGestureHandlerModule = _interopRequireDefault(require("../RNGestureHandlerModule"));
|
18
|
+
|
19
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
20
|
+
|
16
21
|
// Previous types exported gesture handlers as classes which creates an interface and variable, both named the same as class.
|
17
22
|
// Without those types, we'd introduce breaking change, forcing users to prefix every handler type specification with typeof
|
18
23
|
// e.g. React.createRef<TapGestureHandler> -> React.createRef<typeof TapGestureHandler>.
|
19
24
|
// See https://www.typescriptlang.org/docs/handbook/classes.html#constructor-functions for reference.
|
20
|
-
const commonProps = ['id', 'enabled', 'shouldCancelWhenOutside', 'hitSlop'];
|
25
|
+
const commonProps = ['id', 'enabled', 'shouldCancelWhenOutside', 'hitSlop', 'cancelsTouchesInView'];
|
21
26
|
const componentInteractionProps = ['waitFor', 'simultaneousHandlers'];
|
22
27
|
const baseGestureHandlerProps = [...commonProps, ...componentInteractionProps, 'onBegan', 'onFailed', 'onCancelled', 'onActivated', 'onEnded', 'onGestureEvent', 'onHandlerStateChange'];
|
23
28
|
exports.baseGestureHandlerProps = baseGestureHandlerProps;
|
@@ -77,4 +82,16 @@ function findNodeHandle(node) {
|
|
77
82
|
if (_reactNative.Platform.OS === 'web') return node;
|
78
83
|
return (0, _reactNative.findNodeHandle)(node);
|
79
84
|
}
|
85
|
+
|
86
|
+
let scheduledFlushOperationsId = null;
|
87
|
+
|
88
|
+
function scheduleFlushOperations() {
|
89
|
+
if (scheduledFlushOperationsId === null) {
|
90
|
+
scheduledFlushOperationsId = requestAnimationFrame(() => {
|
91
|
+
_RNGestureHandlerModule.default.flushOperations();
|
92
|
+
|
93
|
+
scheduledFlushOperationsId = null;
|
94
|
+
});
|
95
|
+
}
|
96
|
+
}
|
80
97
|
//# sourceMappingURL=gestureHandlerCommon.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["gestureHandlerCommon.ts"],"names":["commonProps","componentInteractionProps","baseGestureHandlerProps","baseGestureHandlerWithMonitorProps","isConfigParam","param","name","undefined","Object","filterConfig","props","validProps","defaults","filteredConfig","key","value","transformIntoHandlerTags","top","left","bottom","right","handlerIDs","Platform","OS","map","current","filter","handle","handlerID","handlerIDToTag","handlerTag","findNodeHandle","node"],"mappings":"
|
1
|
+
{"version":3,"sources":["gestureHandlerCommon.ts"],"names":["commonProps","componentInteractionProps","baseGestureHandlerProps","baseGestureHandlerWithMonitorProps","isConfigParam","param","name","undefined","Object","filterConfig","props","validProps","defaults","filteredConfig","key","value","transformIntoHandlerTags","top","left","bottom","right","handlerIDs","Platform","OS","map","current","filter","handle","handlerID","handlerIDToTag","handlerTag","findNodeHandle","node","scheduledFlushOperationsId","scheduleFlushOperations","requestAnimationFrame","RNGestureHandlerModule","flushOperations"],"mappings":";;;;;;;;;;AAKA;;AAKA;;AACA;;AACA;;;;AAZA;AACA;AACA;AACA;AAWA,MAAMA,WAAW,GAAG,CAClB,IADkB,EAElB,SAFkB,EAGlB,yBAHkB,EAIlB,SAJkB,EAKlB,sBALkB,CAApB;AAQA,MAAMC,yBAAyB,GAAG,CAAC,SAAD,EAAY,sBAAZ,CAAlC;AAEO,MAAMC,uBAAuB,GAAG,CACrC,GAAGF,WADkC,EAErC,GAAGC,yBAFkC,EAGrC,SAHqC,EAI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A,EAAAA,UAAU,GAAG,oBAAQA,UAAR,CAAb;;AAEA,MAAIC,sBAASC,EAAT,KAAgB,KAApB,EAA2B;AACzB,WAAOF,UAAU,CACdG,GADI,CACA,CAAC;AAAEC,MAAAA;AAAF,KAAD,KAAmCA,OADnC,EAEJC,MAFI,CAEIC,MAAD,IAAiBA,MAFpB,CAAP;AAGD,GAPgD,CAQjD;;;AACA,SAAON,UAAU,CACdG,GADI,CAEFI,SAAD;AAAA;;AAAA,WACEC,iCAAeD,SAAf,4BAA6BA,SAAS,CAACH,OAAvC,uDAA6B,mBAAmBK,UAAhD,KAA8D,CAAC,CADjE;AAAA,GAFG,EAKJJ,MALI,CAKII,UAAD,IAAwBA,UAAU,GAAG,CALxC,CAAP;AAMD;;AAEM,SAASC,cAAT,CACLC,IADK,EAEkE;AACvE,MAAIV,sBAASC,EAAT,KAAgB,KAApB,EAA2B,OAAOS,IAAP;AAC3B,SAAO,iCAAiBA,IAAjB,CAAP;AACD;;AAED,IAAIC,0BAEI,GAAG,IAFX;;AAIO,SAASC,uBAAT,GAAmC;AACxC,MAAID,0BAA0B,KAAK,IAAnC,EAAyC;AACvCA,IAAAA,0BAA0B,GAAGE,qBAAqB,CAAC,MAAM;AACvDC,sCAAuBC,eAAvB;;AAEAJ,MAAAA,0BAA0B,GAAG,IAA7B;AACD,KAJiD,CAAlD;AAKD;AACF","sourcesContent":["// Previous types exported gesture handlers as classes which creates an interface and variable, both named the same as class.\n// Without those types, we'd introduce breaking change, forcing users to prefix every handler type specification with typeof\n// e.g. React.createRef<TapGestureHandler> -> React.createRef<typeof TapGestureHandler>.\n// See https://www.typescriptlang.org/docs/handbook/classes.html#constructor-functions for reference.\nimport * as React from 'react';\nimport { Platform, findNodeHandle as findNodeHandleRN } from 'react-native';\n\nimport { State } from '../State';\nimport { TouchEventType } from '../TouchEventType';\nimport { ValueOf } from '../typeUtils';\nimport { handlerIDToTag } from './handlersRegistry';\nimport { toArray } from '../utils';\nimport RNGestureHandlerModule from '../RNGestureHandlerModule';\n\nconst commonProps = [\n 'id',\n 'enabled',\n 'shouldCancelWhenOutside',\n 'hitSlop',\n 'cancelsTouchesInView',\n] as const;\n\nconst componentInteractionProps = ['waitFor', 'simultaneousHandlers'] as const;\n\nexport const baseGestureHandlerProps = [\n ...commonProps,\n ...componentInteractionProps,\n 'onBegan',\n 'onFailed',\n 'onCancelled',\n 'onActivated',\n 'onEnded',\n 'onGestureEvent',\n 'onHandlerStateChange',\n] as const;\n\nexport const baseGestureHandlerWithMonitorProps = [\n ...commonProps,\n 'needsPointerData',\n 'manualActivation',\n];\n\nexport interface GestureEventPayload {\n handlerTag: number;\n numberOfPointers: number;\n state: ValueOf<typeof State>;\n}\nexport interface HandlerStateChangeEventPayload extends GestureEventPayload {\n oldState: ValueOf<typeof State>;\n}\n\nexport type HitSlop =\n | number\n | Partial<\n Record<\n 'left' | 'right' | 'top' | 'bottom' | 'vertical' | 'horizontal',\n number\n >\n >\n | Record<'width' | 'left', number>\n | Record<'width' | 'right', number>\n | Record<'height' | 'top', number>\n | Record<'height' | 'bottom', number>;\n\n//TODO(TS) events in handlers\n\nexport interface GestureEvent<ExtraEventPayloadT = Record<string, unknown>> {\n nativeEvent: Readonly<GestureEventPayload & ExtraEventPayloadT>;\n}\nexport interface HandlerStateChangeEvent<\n ExtraEventPayloadT = Record<string, unknown>\n> {\n nativeEvent: Readonly<HandlerStateChangeEventPayload & ExtraEventPayloadT>;\n}\n\nexport type TouchData = {\n id: number;\n x: number;\n y: number;\n absoluteX: number;\n absoluteY: number;\n};\n\nexport type GestureTouchEvent = {\n handlerTag: number;\n numberOfTouches: number;\n state: ValueOf<typeof State>;\n eventType: TouchEventType;\n allTouches: TouchData[];\n changedTouches: TouchData[];\n};\n\nexport type GestureUpdateEvent<\n GestureEventPayloadT = Record<string, unknown>\n> = GestureEventPayload & GestureEventPayloadT;\n\nexport type GestureStateChangeEvent<\n GestureStateChangeEventPayloadT = Record<string, unknown>\n> = HandlerStateChangeEventPayload & GestureStateChangeEventPayloadT;\n\nexport type CommonGestureConfig = {\n enabled?: boolean;\n shouldCancelWhenOutside?: boolean;\n hitSlop?: HitSlop;\n};\n\n// Events payloads are types instead of interfaces due to TS limitation.\n// See https://github.com/microsoft/TypeScript/issues/15300 for more info.\nexport type BaseGestureHandlerProps<\n ExtraEventPayloadT extends Record<string, unknown> = Record<string, unknown>\n> = CommonGestureConfig & {\n id?: string;\n waitFor?: React.Ref<unknown> | React.Ref<unknown>[];\n simultaneousHandlers?: React.Ref<unknown> | React.Ref<unknown>[];\n testID?: string;\n cancelsTouchesInView?: boolean;\n // TODO(TS) - fix event types\n onBegan?: (event: HandlerStateChangeEvent) => void;\n onFailed?: (event: HandlerStateChangeEvent) => void;\n onCancelled?: (event: HandlerStateChangeEvent) => void;\n onActivated?: (event: HandlerStateChangeEvent) => void;\n onEnded?: (event: HandlerStateChangeEvent) => void;\n\n //TODO(TS) consider using NativeSyntheticEvent\n onGestureEvent?: (event: GestureEvent<ExtraEventPayloadT>) => void;\n onHandlerStateChange?: (\n event: HandlerStateChangeEvent<ExtraEventPayloadT>\n ) => void;\n};\n\nfunction isConfigParam(param: unknown, name: string) {\n // param !== Object(param) returns false if `param` is a function\n // or an object and returns true if `param` is null\n return (\n param !== undefined &&\n (param !== Object(param) ||\n !('__isNative' in (param as Record<string, unknown>))) &&\n name !== 'onHandlerStateChange' &&\n name !== 'onGestureEvent'\n );\n}\n\nexport function filterConfig(\n props: Record<string, unknown>,\n validProps: string[],\n defaults: Record<string, unknown> = {}\n) {\n const filteredConfig = { ...defaults };\n for (const key of validProps) {\n let value = props[key];\n if (isConfigParam(value, key)) {\n if (key === 'simultaneousHandlers' || key === 'waitFor') {\n value = transformIntoHandlerTags(props[key]);\n } else if (key === 'hitSlop' && typeof value !== 'object') {\n value = { top: value, left: value, bottom: value, right: value };\n }\n filteredConfig[key] = value;\n }\n }\n return filteredConfig;\n}\n\nfunction transformIntoHandlerTags(handlerIDs: any) {\n handlerIDs = toArray(handlerIDs);\n\n if (Platform.OS === 'web') {\n return handlerIDs\n .map(({ current }: { current: any }) => current)\n .filter((handle: any) => handle);\n }\n // converts handler string IDs into their numeric tags\n return handlerIDs\n .map(\n (handlerID: any) =>\n handlerIDToTag[handlerID] || handlerID.current?.handlerTag || -1\n )\n .filter((handlerTag: number) => handlerTag > 0);\n}\n\nexport function findNodeHandle(\n node: null | number | React.Component<any, any> | React.ComponentClass<any>\n): null | number | React.Component<any, any> | React.ComponentClass<any> {\n if (Platform.OS === 'web') return node;\n return findNodeHandleRN(node);\n}\n\nlet scheduledFlushOperationsId: ReturnType<\n typeof requestAnimationFrame\n> | null = null;\n\nexport function scheduleFlushOperations() {\n if (scheduledFlushOperationsId === null) {\n scheduledFlushOperationsId = requestAnimationFrame(() => {\n RNGestureHandlerModule.flushOperations();\n\n scheduledFlushOperationsId = null;\n });\n }\n}\n"]}
|
@@ -31,7 +31,7 @@ var _TapGestureHandler = require("../TapGestureHandler");
|
|
31
31
|
|
32
32
|
var _State = require("../../State");
|
33
33
|
|
34
|
-
var
|
34
|
+
var _TouchEventType = require("../../TouchEventType");
|
35
35
|
|
36
36
|
var _ActionType = require("../../ActionType");
|
37
37
|
|
@@ -39,6 +39,10 @@ var _utils = require("../../utils");
|
|
39
39
|
|
40
40
|
var _getShadowNodeFromRef = require("../../getShadowNodeFromRef");
|
41
41
|
|
42
|
+
var _reactNative = require("react-native");
|
43
|
+
|
44
|
+
var _eventReceiver = require("./eventReceiver");
|
45
|
+
|
42
46
|
var _Reanimated$default$c, _Reanimated$default;
|
43
47
|
|
44
48
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
@@ -75,6 +79,8 @@ function dropHandlers(preparedGesture) {
|
|
75
79
|
|
76
80
|
(0, _handlersRegistry.unregisterHandler)(handler.handlerTag, handler.config.testId);
|
77
81
|
}
|
82
|
+
|
83
|
+
(0, _gestureHandlerCommon.scheduleFlushOperations)();
|
78
84
|
}
|
79
85
|
|
80
86
|
function checkGestureCallbacksForWorklets(gesture) {
|
@@ -97,7 +103,8 @@ function attachHandlers({
|
|
97
103
|
preparedGesture,
|
98
104
|
gestureConfig,
|
99
105
|
gesture,
|
100
|
-
viewTag
|
106
|
+
viewTag,
|
107
|
+
webEventHandlersRef
|
101
108
|
}) {
|
102
109
|
if (!preparedGesture.firstExecution) {
|
103
110
|
gestureConfig === null || gestureConfig === void 0 ? void 0 : gestureConfig.initialize();
|
@@ -116,10 +123,13 @@ function attachHandlers({
|
|
116
123
|
|
117
124
|
_RNGestureHandlerModule.default.createGestureHandler(handler.handlerName, handler.handlerTag, (0, _gestureHandlerCommon.filterConfig)(handler.config, ALLOWED_PROPS));
|
118
125
|
|
119
|
-
(0, _handlersRegistry.registerHandler)(handler.handlerTag, handler, handler.config.testId);
|
120
|
-
|
126
|
+
(0, _handlersRegistry.registerHandler)(handler.handlerTag, handler, handler.config.testId);
|
127
|
+
} // use setImmediate to extract handlerTags, because all refs should be initialized
|
128
|
+
// when it's ran
|
129
|
+
|
121
130
|
|
122
|
-
|
131
|
+
setImmediate(() => {
|
132
|
+
for (const handler of gesture) {
|
123
133
|
let requireToFail = [];
|
124
134
|
|
125
135
|
if (handler.config.requireToFail) {
|
@@ -136,15 +146,21 @@ function attachHandlers({
|
|
136
146
|
simultaneousHandlers: simultaneousWith,
|
137
147
|
waitFor: requireToFail
|
138
148
|
}));
|
139
|
-
}
|
140
|
-
}
|
149
|
+
}
|
141
150
|
|
151
|
+
(0, _gestureHandlerCommon.scheduleFlushOperations)();
|
152
|
+
});
|
142
153
|
preparedGesture.config = gesture;
|
143
154
|
|
144
155
|
for (const gesture of preparedGesture.config) {
|
145
156
|
const actionType = gesture.shouldUseReanimated ? _ActionType.ActionType.REANIMATED_WORKLET : _ActionType.ActionType.JS_FUNCTION_NEW_API;
|
146
157
|
|
147
|
-
|
158
|
+
if (_reactNative.Platform.OS === 'web') {
|
159
|
+
_RNGestureHandlerModule.default.attachGestureHandler(gesture.handlerTag, viewTag, _ActionType.ActionType.JS_FUNCTION_OLD_API, // ignored on web
|
160
|
+
webEventHandlersRef);
|
161
|
+
} else {
|
162
|
+
_RNGestureHandlerModule.default.attachGestureHandler(gesture.handlerTag, viewTag, actionType);
|
163
|
+
}
|
148
164
|
}
|
149
165
|
|
150
166
|
if (preparedGesture.animatedHandlers) {
|
@@ -191,6 +207,8 @@ function updateHandlers(preparedGesture, gestureConfig, gesture) {
|
|
191
207
|
preparedGesture.animatedHandlers.value = preparedGesture.config.filter(g => g.shouldUseReanimated) // ignore gestures that shouldn't run on UI
|
192
208
|
.map(g => g.handlers);
|
193
209
|
}
|
210
|
+
|
211
|
+
(0, _gestureHandlerCommon.scheduleFlushOperations)();
|
194
212
|
});
|
195
213
|
}
|
196
214
|
|
@@ -265,16 +283,16 @@ function useAnimatedGesture(preparedGesture, needsRebuild) {
|
|
265
283
|
'worklet';
|
266
284
|
|
267
285
|
switch (eventType) {
|
268
|
-
case
|
286
|
+
case _TouchEventType.TouchEventType.TOUCHES_DOWN:
|
269
287
|
return _gesture.CALLBACK_TYPE.TOUCHES_DOWN;
|
270
288
|
|
271
|
-
case
|
289
|
+
case _TouchEventType.TouchEventType.TOUCHES_MOVE:
|
272
290
|
return _gesture.CALLBACK_TYPE.TOUCHES_MOVE;
|
273
291
|
|
274
|
-
case
|
292
|
+
case _TouchEventType.TouchEventType.TOUCHES_UP:
|
275
293
|
return _gesture.CALLBACK_TYPE.TOUCHES_UP;
|
276
294
|
|
277
|
-
case
|
295
|
+
case _TouchEventType.TouchEventType.TOUCHES_CANCELLED:
|
278
296
|
return _gesture.CALLBACK_TYPE.TOUCHES_CANCELLED;
|
279
297
|
}
|
280
298
|
|
@@ -343,7 +361,7 @@ function useAnimatedGesture(preparedGesture, needsRebuild) {
|
|
343
361
|
stateControllers[i] = _gestureStateManager.GestureStateManager.create(event.handlerTag);
|
344
362
|
}
|
345
363
|
|
346
|
-
if (event.eventType !==
|
364
|
+
if (event.eventType !== _TouchEventType.TouchEventType.UNDETERMINED) {
|
347
365
|
runWorklet(touchEventTypeToCallbackType(event.eventType), gesture, event, stateControllers[i]);
|
348
366
|
}
|
349
367
|
} else {
|
@@ -375,6 +393,11 @@ const GestureDetector = props => {
|
|
375
393
|
const useReanimatedHook = gesture.some(g => g.shouldUseReanimated);
|
376
394
|
const viewRef = (0, _react.useRef)(null);
|
377
395
|
const firstRenderRef = (0, _react.useRef)(true);
|
396
|
+
const webEventHandlersRef = (0, _react.useRef)({
|
397
|
+
onGestureHandlerEvent: e => {
|
398
|
+
(0, _eventReceiver.onGestureHandlerEvent)(e.nativeEvent);
|
399
|
+
}
|
400
|
+
});
|
378
401
|
|
379
402
|
const preparedGesture = _react.default.useRef({
|
380
403
|
config: gesture,
|
@@ -411,7 +434,8 @@ const GestureDetector = props => {
|
|
411
434
|
preparedGesture,
|
412
435
|
gestureConfig,
|
413
436
|
gesture,
|
414
|
-
viewTag
|
437
|
+
viewTag,
|
438
|
+
webEventHandlersRef
|
415
439
|
});
|
416
440
|
return () => {
|
417
441
|
dropHandlers(preparedGesture);
|
@@ -427,7 +451,8 @@ const GestureDetector = props => {
|
|
427
451
|
preparedGesture,
|
428
452
|
gestureConfig,
|
429
453
|
gesture,
|
430
|
-
viewTag
|
454
|
+
viewTag,
|
455
|
+
webEventHandlersRef
|
431
456
|
});
|
432
457
|
} else {
|
433
458
|
updateHandlers(preparedGesture, gestureConfig, gesture);
|
@@ -446,12 +471,7 @@ const GestureDetector = props => {
|
|
446
471
|
const node = (0, _getShadowNodeFromRef.getShadowNodeFromRef)(ref);
|
447
472
|
|
448
473
|
if (global.isFormsStackingContext(node) === false) {
|
449
|
-
|
450
|
-
// For some weird reason, console.error on iOS delays
|
451
|
-
// the execution of RNGestureHandlerModule.attachGestureHandler,
|
452
|
-
// so that's why we use setImmediate here.
|
453
|
-
console.error((0, _utils.tagMessage)('GestureDetector has received a child that may get view-flattened. ' + '\nTo prevent it from misbehaving you need to wrap the child with a `<View collapsable={false}>`.'));
|
454
|
-
});
|
474
|
+
console.error((0, _utils.tagMessage)('GestureDetector has received a child that may get view-flattened. ' + '\nTo prevent it from misbehaving you need to wrap the child with a `<View collapsable={false}>`.'));
|
455
475
|
}
|
456
476
|
}
|
457
477
|
}
|