[React Native] Animate Styles of a React Native View with Animated.timing
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;
[React Native] Animate Styles of a React Native View with Animated.timing的更多相关文章
- [React Native] Animate the Scale of a React Native Button using Animated.spring
In this lesson we will use Animated.spring and TouchableWithoutFeedback to animate the scale of a bu ...
- React Native是一套使用 React 构建 Native app 的编程框架
React Native是一套使用 React 构建 Native app 的编程框架 React Native at first sight what is React Native? 跟据官方的描 ...
- React学习笔记-1-什么是react,react环境搭建以及第一个react实例
什么是react?react的官方网站:https://facebook.github.io/react/下图这个就是就是react的标志,非常巧合的是他和我们的github的编辑器Atom非常相似. ...
- weblogic.nodemanager.common.ConfigException: Native version is enabled but nodemanager native library could not be loaded 解决办法
近日在一个原本工作正常的weblogic web server(操作系统为redhat 64位系统)上折腾安装redis/hadoop等东东,yum install了一堆第3方类库后,重启weblog ...
- React系列(一):React入门
React简介 1.由来 React是有Facebook开发出来用于构建前端界面的JS组件库,由于其背后的强大背景,使得这款库在技术开发上完全没有问题. 2.React的优势 解决大规模项目开发中数据 ...
- react.js 从零开始(七)React (虚拟)DOM
React 元素 React 中最主要的类型就是 ReactElement.它有四个属性:type,props,key 和ref.它没有方法,并且原型上什么都没有. 可以通过 React.create ...
- 如何使用TDD和React Testing Library构建健壮的React应用程序
如何使用TDD和React Testing Library构建健壮的React应用程序 当我开始学习React时,我努力的一件事就是以一种既有用又直观的方式来测试我的web应用程序. 每次我想测试它时 ...
- React环境配置(第一个React项目)
使用Webpack构建React项目 1. 使用NPM配置React环境 NPM及React安装自行百度 首先创建一个文件夹,the_first_React 进入到创建好的目录,npm init,然后 ...
- React入门介绍(2)- React Component-React组件
React Component-React组件 允许用户自由封装组件是React非常突出的特性,用户可将自己创建的组件像普通的HTML标签一样插入页面,React.CreateClass方法就是用来创 ...
随机推荐
- 1.3 Quick Start中 Step 6: Setting up a multi-broker cluster官网剖析(博主推荐)
不多说,直接上干货! 一切来源于官网 http://kafka.apache.org/documentation/ Step 6: Setting up a multi-broker cluster ...
- mahout用到的典型测试数据集
http://archive.ics.uci.edu/ml/databases/synthetic_control/ 继续
- mahout-distribution-0.9.tar.gz的安装的与配置、启动与运行自带的mahout算法
不多说,直接上干货! 首先,别在windows下搭建什么,安装什么Cygwin啊!直接在linux,对于企业里推荐用CentOS6.5,在学校里用Ubuntu. Mahout安装所需软件清单: 软件 ...
- Day3上午解题报告
预计分数:100+40+50=190 实际分数:100+40+50=190 T1 https://www.luogu.org/problem/show?pid=T15365 表示从来没做过博弈论的题, ...
- POJ 3220 Jessica's Reading Problem
Jessica's Reading Problem Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 12944 Accep ...
- 【2017"百度之星"程序设计大赛 - 初赛(A)】数据分割
[链接]http://acm.hdu.edu.cn/showproblem.php?pid=6109 [题意] 在这里写题意 [题解] 要处理的关系越多,肯定就越容易错. ->单调性. 根据这个 ...
- 51NOD——T 1079 中国剩余定理
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1079 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难 ...
- 洛谷 P2908 [USACO08OPEN]文字的力量Word Power
P2908 [USACO08OPEN]文字的力量Word Power 题目描述 Farmer John wants to evaluate the quality of the names of hi ...
- C#程序集引入无效的解决方法
在项目类库中已经引用了相关了类库,生成解决方案也没问题,但是到了后置代码,通过using引用其他类库的时候,再生成解决方案或者生成单个类库,就会报“未能找到类型或命名空间“xxx"(是否缺少 ...
- 二叉树的递归插入【Java实现】
C++中由于有指针的存在,可以让二叉树节点指针的指针作为插入函数的实参,在函数体内通过*操作实现对真实节点指针.节点左孩子指针.节点右孩子指针的改变,这样很容易使用递归将大树问题转化到小树问题.但在J ...