In this lesson we will use Animated.timing to animate the opacity and height of a View in our React Native application. This function has attributes that you can set such as easing and duration.

import React, {Component} from 'react';
import {Text, View, StyleSheet, Image, Animated, Easing} from 'react-native'; var styles = StyleSheet.create({
container: {
backgroundColor: '#48BBEC',
paddingBottom:
},
name: {
alignSelf: 'center',
fontSize: ,
marginTop: ,
marginBottom: ,
color: 'white'
},
handle: {
alignSelf: 'center',
fontSize: ,
color: 'white'
},
image: {
height: ,
width: ,
borderRadius: ,
marginTop: ,
alignSelf: 'center'
}
}); class Badge extends React.Component {
constructor(props){
super(props);
this.state = {
fadeAnim: new Animated.Value(),
bounceAnim: new Animated.Value()
}
}
componentDidMount() {
Animated.timing(
this.state.fadeAnim,
{toValue: , duration: }
).start();
Animated.timing(
this.state.bounceAnim,
{toValue: , duration: , easing: Easing.bounce}
).start();
}
render(){
const animatedTextStyle = {
opacity: this.state.fadeAnim,
};
const animateImageStyle = {
opacity: this.state.bounceAnim
};
return (
<View style={styles.container}>
<Animated.Image style={[styles.image, animateImageStyle]} source={{uri: this.props.userInfo.avatar_url}}></Animated.Image>
<Animated.Text style={[styles.name,animatedTextStyle]}> {this.props.userInfo.name} </Animated.Text>
<Animated.Text style={[styles.handle, animatedTextStyle]}> {this.props.userInfo.login} </Animated.Text>
</View>
)
}
} /**
* Make sure when when user the Badge component, the userInfo object is there
* @type {{userInfo: *}}
*/
Badge.propTypes = {
userInfo: React.PropTypes.object.isRequired
}; module.exports=Badge;

最新文章

  1. Elasticsearch聚合 之 Range区间聚合
  2. Cxgrid获取选中行列,排序规则,当前正在编辑的单元格内的值
  3. linux 用户之间的切换
  4. IOS 蓝牙相关-app作为外设被连接的实现(3)
  5. Unity3D 调用模态对话框/Unity3D MessageBox
  6. Dynamic CRM 2013学习笔记(三十八)流程1 - 操作(action)开发与配置详解
  7. 不要过早退出循环 while(1){no break}
  8. UIView与CALayer的区别
  9. sqlserver 常用sql语句
  10. ssh 密钥详解
  11. http://msh.baidu.com/UTWpR6wY4722
  12. android fragment传递参数_fragment之间传值的两种方法
  13. java——String的那边破事
  14. bzoj2683简单题 cdq分治
  15. 【转载】阿里云服务器为网站选配Https证书
  16. pandas数据清洗策略1
  17. 【Git】 GitLab简单使用
  18. C++虚表详解
  19. 从urllib2的内存泄露看python的GC python引用计数 对象的引用数 循环引用
  20. 【PyQt5-Qt Designer】对话框系列

热门文章

  1. Office Open XML导出大数据
  2. Fedora 13 Alpha测试手记横空出世
  3. Chrome 好用的扩展程序
  4. angular 子组件与父组件通讯
  5. 非常有用的sql脚本
  6. 又一次认识java(一) ---- 万物皆对象
  7. Android中使用HttpClient实现HTTP通信效果
  8. @转EXT2-&gt;EXT3-&gt;EXT4
  9. 如何查看kafka消费者信息?
  10. Android 网络图片Url 转 Bitmap