-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAButton.js
More file actions
78 lines (70 loc) · 1.84 KB
/
AButton.js
File metadata and controls
78 lines (70 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import React, {Component} from 'react';
import {View,Text,Animated,
TouchableHighlight,
TouchableWithoutFeedback,
Easing,
StyleSheet
} from 'react-native';
export default class AButton extends Component{
constructor(props) {
super(props)
this.triggerAnimation=this.triggerAnimation.bind(this);
}
componentWillMount() {
this.animation= new Animated.Value(0);
}
triggerAnimation(){
this.animation.setValue(0);
Animated.timing(this.animation,{
duration:100,
toValue:1,
ease:Easing.bounce
}).start();
}
showShadow(){
return(
<Animated.View style={[this.props.style,this.props.showdowstyle,{position:'absolute'}]}>
<Text style={styles.text}> </Text>
</Animated.View>
)
}
render(){
const interpolate = this.animation.interpolate({
inputRange: [0,.5,1],
outputRange: [0,this.props.showdowstyle.top*2,0],
extrapolate: 'clamp',
});
const style={
transform:[
{
translateX:interpolate
}
]
}
return(
<View
style={[this.props.style,{backgroundColor:'transparent',padding:0,marginBottom:this.props.showdowstyle.top}]}
>
<View style={[this.props.style,{position:'relative',backgroundColor:'transparent',padding:0}]}>
{this.showShadow()}
<TouchableWithoutFeedback onPress={()=>{
//alert("clicked")
this.triggerAnimation()
}}>
<Animated.View style={[this.props.style,{marginTop:interpolate}]}>
<Text style={[styles.text,this.props.textstyle]}>
{this.props.text}
</Text>
</Animated.View>
</TouchableWithoutFeedback>
</View>
</View>
)
}
}
const styles = StyleSheet.create({
text:{
color:'#fff',
textAlign:'center'
}
});