https://reacttraining.com/react-router/web/example/animated-transitions

动画转换这么高级,其实是又引入了一个组件,没什么特别,

import React from 'react'
import ReactCSSTransitionGroup from 'react-addons-css-transition-group' // 就是他。。效果就是内容变化后,有一点点动画效果,
import {
BrowserRouter as Router,
Route,
Link,
Redirect
} from 'react-router-dom' /* you'll need this CSS somewhere // 就是这些css样式
.fade-enter {
opacity: 0;
z-index: 1;
} .fade-enter.fade-enter-active {
opacity: 1;
transition: opacity 250ms ease-in;
}
*/ const AnimationExample = () => (
<Router>
<Route render={({ location }) => (
<div style={styles.fill}>
<Route exact path="/" render={() => (
<Redirect to="/10/90/50"/>
)}/> <ul style={styles.nav}>
<NavLink to="/10/90/50">Red</NavLink>
<NavLink to="/120/100/40">Green</NavLink>
<NavLink to="/200/100/40">Blue</NavLink>
<NavLink to="/310/100/50">Pink</NavLink>
</ul> <div style={styles.content}>
<ReactCSSTransitionGroup
transitionName="fade"
transitionEnterTimeout={300} // 入场动画时间
transitionLeaveTimeout={300} // 出场动画时间
>
{/* no different than other usage of
ReactCSSTransitionGroup, just make
sure to pass `location` to `Route`
so it can match the old location
as it animates out
*/}
<Route
location={location}
key={location.key}
path="/:h/:s/:l"
component={HSL}
/>
</ReactCSSTransitionGroup>
</div>
</div>
)}/>
</Router>
) const NavLink = (props) => (
<li style={styles.navItem}>
<Link {...props} style={{ color: 'inherit' }}/>
</li>
) const HSL = ({ match: { params } }) => (
<div style={{
...styles.fill,
...styles.hsl,
background: `hsl(${params.h}, ${params.s}%, ${params.l}%)` // ES6的模板字符串
}}>hsl({params.h}, {params.s}%, {params.l}%)</div>
) const styles = {} styles.fill = {
position: 'absolute',
left: 0,
right: 0,
top: 0,
bottom: 0
} styles.content = {
...styles.fill,
top: '40px',
textAlign: 'center'
} styles.nav = {
padding: 0,
margin: 0,
position: 'absolute',
top: 0,
height: '40px',
width: '100%',
display: 'flex'
} styles.navItem = {
textAlign: 'center',
flex: 1,
listStyleType: 'none',
padding: '10px'
} styles.hsl = {
...styles.fill,
color: 'white',
paddingTop: '20px',
fontSize: '30px'
} export default AnimationExample

React-router4 第八篇 ReactCSSTransitionGroup 动画转换的更多相关文章

  1. 第八篇 SQL Server安全数据加密

    本篇文章是SQL Server安全系列的第八篇,详细内容请参考原文. Relational databases are used in an amazing variety of applicatio ...

  2. 【译】第八篇 SQL Server安全数据加密

    本篇文章是SQL Server安全系列的第八篇,详细内容请参考原文. Relational databases are used in an amazing variety of applicatio ...

  3. Bodymovin:Bodymovin和Lottie:把AE动画转换成HTML5/Android/iOS原生动画

    转自:https://www.cnblogs.com/zamhown/p/6688369.html 大杀器Bodymovin和Lottie:把AE动画转换成HTML5/Android/iOS原生动画 ...

  4. NHibernate 数据查询之Linto to NHibernate (第八篇)

    NHibernate 数据查询之Linto to NHibernate (第八篇) 刚学NHibernate的时候觉得,HQL挺好用的,但是终归没有与其他技术 相关联,只有NHibernate用到,一 ...

  5. React入门看这篇就够了

    摘要: 很多值得了解的细节. 原文:React入门看这篇就够了 作者:Random Fundebug经授权转载,版权归原作者所有. React 背景介绍 React 入门实例教程 React 起源于 ...

  6. [转]React入门看这篇就够了

    摘要: 很多值得了解的细节. 原文:React入门看这篇就够了 作者:Random Fundebug经授权转载,版权归原作者所有. React 背景介绍 React 入门实例教程 React 起源于 ...

  7. Spring Cloud实战 | 最八篇:Spring Cloud +Spring Security OAuth2+ Axios前后端分离模式下无感刷新实现JWT续期

    一. 前言 记得上一篇Spring Cloud的文章关于如何使JWT失效进行了理论结合代码实践的说明,想当然的以为那篇会是基于Spring Cloud统一认证架构系列的最终篇.但关于JWT另外还有一个 ...

  8. iOS开发UI篇—核心动画(UIView封装动画)

    iOS开发UI篇—核心动画(UIView封装动画) 一.UIView动画(首尾) 1.简单说明 UIKit直接将动画集成到UIView类中,当内部的一些属性发生改变时,UIView将为这些改变提供动画 ...

  9. iOS开发UI篇—核心动画(转场动画和组动画)

    转自:http://www.cnblogs.com/wendingding/p/3801454.html iOS开发UI篇—核心动画(转场动画和组动画) 一.转场动画简单介绍 CAAnimation的 ...

随机推荐

  1. Fabric实例

    Fabric的官网  http://fabric-chs.readthedocs.io/zh_CN/chs/index.html 参考<Python自动化运维 技术与最佳实践>   1:查 ...

  2. nginx屏蔽某段IP、某个国家的IP

    nginx中可通过写入配置文件的方法来达到一定的过滤IP作用,可使用deny来写. deny的使用方法可用于前端服务器无防护设备的时候过滤一些异常IP,过滤的client ip会被禁止再次访问,起到一 ...

  3. 1.1.21 Word修改文章目录

    1.选中目录后,右键[编辑域],选择[索引和目录].选择[TOC],点击右侧的[目录]. 2.选中[目录]后,按照如下[1][2][3]顺序,按格式要求修改目录即可.

  4. Windows 下最佳的 C++ 开发的 IDE 是什么?

    作者:渡世白玉链接:https://www.zhihu.com/question/19589089/answer/30312199来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注 ...

  5. 对于HTML页面中CSS, JS, HTML的加载与执行过程的简单分析

    来自   https://blog.csdn.net/u011088260/article/details/79563315   最近在研究HTML页面中JavaScript的执行顺序问题.在Java ...

  6. .net mvc 分页

    1.分页实体类 public class PageDto { public int PageIndex { get; set; } public int PageSize { get; set; } ...

  7. UE4 UMG

    转自:https://www.cnblogs.com/kadaj/p/6412937.html 1.创建关卡类 1.创建C++类继承LevelScriptActor 2.打开关卡蓝图 Class Se ...

  8. 常用HDFS操作命令

    前一段时间频繁使用HDFS,又收集到了一些命令,在这儿分享出来,大数据的框架及设计原理方面的理论文章暂时还没有时间总结,后面有时间逐渐整理发出来. 注:在使用命令时,可以使用 hadoop fs,如果 ...

  9. web socket client

    <!DOCTYPE HTML> <html> <head> <title>My WebSocket</title> </head> ...

  10. 字符串String的API

      字符串的理解 1. 字符串的属性 str.length 2. 字符串的方法 charAt() charCodeAt() indexOf() lastIndexOf() slice() substr ...