GT2/Ejectable/node_modules/react-native-gesture-handler/lib/commonjs/components/touchables/TouchableOpacity.js.map

1 line
3.7 KiB
Plaintext

{"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;;;;;;;;;;AAGA;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;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,EAAE;AAJW,OAA9B,EAKGC,KALH;AAMD,KArBD;;AAAA,2CAuBgB,CAACC,KAAD,EAAgBC,EAAhB,KAA+B;AAC7C,UAAIA,EAAE,KAAKC,kCAAgBC,KAA3B,EAAkC;AAChC,aAAKC,YAAL,CAAkB,KAAKpB,KAAL,CAAWqB,aAA7B,EAA6C,CAA7C;AACD,OAFD,MAEO,IACLJ,EAAE,KAAKC,kCAAgBI,YAAvB,IACAL,EAAE,KAAKC,kCAAgBK,aAFlB,EAGL;AACA,aAAKH,YAAL,CAAkB,KAAKf,+BAAL,EAAlB,EAA0D,GAA1D;AACD;AACF,KAhCD;AAAA;;AAkCAmB,EAAAA,MAAM,GAAG;AACP,UAAM;AAAEvB,MAAAA,KAAK,GAAG,EAAV;AAAc,SAAGwB;AAAjB,QAA0B,KAAKzB,KAArC;AACA,wBACE,oBAAC,yBAAD,eACMyB,IADN;AAEE,MAAA,KAAK,EAAE,CACLxB,KADK,EAEL;AACEC,QAAAA,OAAO,EAAG,KAAKA,OADjB,CACgD;;AADhD,OAFK,CAFT;AAQE,MAAA,aAAa,EAAE,KAAKwB;AARtB,QASG,KAAK1B,KAAL,CAAW2B,QAAX,GAAsB,KAAK3B,KAAL,CAAW2B,QAAjC,gBAA4C,oBAAC,iBAAD,OAT/C,CADF;AAaD;;AAjDD;;;;gBAFmBhC,gB,kBAGG,EACpB,GAAGiC,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\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\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: 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"]}