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. Python 解决: from pip import main ImportError: cannot import name 'main'

    此次报错是因为 pip 升级出的问题: from pip import mainif __name__ == '__main__': sys.exit(main()) 改为: from pip imp ...

  2. python中list列表的方法len()

    作用:返回列表中元素的个数. 用法: len(list)

  3. Centos6.8通过yum安装mysql5.7 centos7.5适用

    1.安装mysql的yum源 a.下载配置mysql的yum源的rpm包 根据上面3张图片中的操作下载下来的rpm文件可以通过如下命令获取: wget https://dev.mysql.com/ge ...

  4. 使用JAVA实现的一个简单IOC注入实例

    https://blog.csdn.net/echoshinian100/article/details/77977823 欲登高而望远,勿筑台于流沙 RSS订阅 原 使用JAVA实现的一个简单IOC ...

  5. springmvc log4j配置

    1. web.xml <!-- 加载Log4J 配置文件 --> <context-param> <param-name>log4jConfigLocation&l ...

  6. 【OpenStack】network相关知识学习

    network 类型 local:通信不跨主机,必须同一网段,主要做单机测试使用: flat:统计可以跨主机,但是需要在同一网段: 每个 flat network 都会独占一个物理网卡 计算节点上 b ...

  7. [UE4]Background Blur,背景模糊

    一.Blur Strength:模糊强度 二.背景是模糊的,在Background Blur前面的控件二不会模糊. 三.可以调整顺序,让按钮也模糊.然后按钮被模糊了,但是按钮还可以被点击的,Backg ...

  8. PUSU 拆分后发货和开票的时间节点问题

    项目做到现在业务突然说流程要变,心中顿时无数个草草草掠过.这公司业务也真是够奇葩了,一天一个样.原来流程是由PU把产品生产完后就发给SU,由SU再来决定什么时候对客户和开票.而现在马上要上线了,突然冒 ...

  9. HTML/CSS基础知识(一)

    Q:浏览器页面有哪三层构成,分别是什么,作用是什么? A:由三部分构成: 网页结构层(Structural Layer)——由(X)HTML等标记语言负责创建,实现页面结构. 网页表示层(Presen ...

  10. 当一个HTML元素需要添加mouseon、mouseout与click事件,或者mouserenter、mouseleave和click事件时,click事件无法触发

    当一个HTML元素需要添加mouseon.mouseout与click事件,或者mouserenter.mouseleave和click事件时,click事件无法触发 针对上述问题,我遇到的有两种情况 ...