1 line
3.9 KiB
Plaintext
1 line
3.9 KiB
Plaintext
|
{"version":3,"sources":["TouchableOpacity.tsx"],"names":["Animated","Easing","StyleSheet","View","GenericTouchable","TOUCHABLE_STATE","React","Component","TouchableOpacity","childStyle","flatten","props","style","opacity","Value","getChildStyleOpacityWithDefault","value","duration","timing","toValue","easing","inOut","quad","useNativeDriver","start","_from","to","BEGAN","setOpacityTo","activeOpacity","UNDETERMINED","MOVED_OUTSIDE","render","rest","onStateChange","children","defaultProps"],"mappings":";;;;AAAA,SACEA,QADF,EAEEC,MAFF,EAGEC,UAHF,EAIEC,IAJF,QAMO,cANP;AAOA,OAAOC,gBAAP,IACEC,eADF,QAGO,oBAHP;AAIA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,SAASC,SAAT,QAA0B,OAA1B;AAEA;AACA;AACA;;AACA,eAAe,MAAMC,gBAAN,SAA+BD,SAA/B,CAEb;AAAA;AAAA;;AAAA,6DAOkC,MAAM;AACtC,YAAME,UAAU,GAAGP,UAAU,CAACQ,OAAX,CAAmB,KAAKC,KAAL,CAAWC,KAA9B,KAAwC,EAA3D;AACA,aAAOH,UAAU,CAACI,OAAX,IAAsB,IAAtB,GAA6B,CAA7B,GAAiCJ,UAAU,CAACI,OAAnD;AACD,KAVD;;AAAA,qCAYU,IAAIb,QAAQ,CAACc,KAAb,CAAmB,KAAKC,+BAAL,EAAnB,CAZV;;AAAA,0CAce,CAACC,KAAD,EAAgBC,QAAhB,KAAqC;AAClDjB,MAAAA,QAAQ,CAACkB,MAAT,CAAgB,KAAKL,OAArB,EAA8B;AAC5BM,QAAAA,OAAO,EAAEH,KADmB;AAE5BC,QAAAA,QAAQ,EAAEA,QAFkB;AAG5BG,QAAAA,MAAM,EAAEnB,MAAM,CAACoB,KAAP,CAAapB,MAAM,CAACqB,IAApB,CAHoB;AAI5BC,QAAAA,eAAe,EAAE;AAJW,OAA9B,EAKGC,KALH;AAMD,KArBD;;AAAA,2CAuBgB,CAACC,KAAD,EAAgBC,EAAhB,KAA+B;AAC7C,UAAIA,EAAE,KAAKrB,eAAe,CAACsB,KAA3B,EAAkC;AAChC,aAAKC,YAAL,CAAkB,KAAKjB,KAAL,CAAWkB,aAA7B,EAA6C,CAA7C;AACD,OAFD,MAEO,IACLH,EAAE,KAAKrB,eAAe,CAACyB,YAAvB,IACAJ,EAAE,KAAKrB,eAAe,CAAC0B,aAFlB,EAGL;AACA,aAAKH,YAAL,CAAkB,KAAKb,+BAAL,EAAlB,EAA0D,GAA1D;AACD;AACF,KAhCD;AAAA;;AAkCAiB,EAAAA,MAAM,GAAG;AACP,UAAM;AAAEpB,MAAAA,KAAK,GAAG,EAAV;AAAc,SAAGqB;AAAjB,QAA0B,KAAKtB,KAArC;AACA,wBACE,oBAAC,gBAAD,eACMsB,IADN;AAEE,MAAA,KAAK,EAAE,CACLrB,KADK,EAEL;AACEC,QAAAA,OAAO,EAAG,KAAKA,OADjB,CACgD;;AADhD,OAFK,CAFT;AAQE,MAAA,aAAa,EAAE,KAAKqB;AARtB,QASG,KAAKvB,KAAL,CAAWwB,QAAX,GAAsB,KAAKxB,KAAL,CAAWwB,QAAjC,gBAA4C,oBAAC,IAAD,OAT/C,CADF;AAaD;;AAjDD;;gBAFmB3B,gB,kBAGG,EACpB,GAAGJ,gBAAgB,CAACgC,YADA;AAEpBP,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"]}
|