ant-design/components/queue-anim/demo/router.md

146 lines
3.8 KiB
Markdown
Raw Normal View History

2015-10-21 17:53:38 +08:00
# Router 默认进出场
- order: 7
router 组合的进场与出场动画。
---
````jsx
const ReactRouter = require('react-router');
let { Router, Route, Link } = ReactRouter;
import { QueueAnim, Menu } from 'antd';
2015-10-21 17:53:38 +08:00
const App = React.createClass({
2015-10-21 17:53:38 +08:00
render() {
const key = this.props.location.pathname;
const keys = key.replace('/', '') ? [ key.replace('/', '') ] : [ 'home' ];
2015-10-21 17:53:38 +08:00
return (
<div>
<Menu style={{marginBottom: 10}} mode="horizontal" selectedKeys={keys}>
2015-10-23 22:37:42 +08:00
<Menu.Item key="home">
2015-10-21 17:53:38 +08:00
<Link to="/">首页</Link>
</Menu.Item>
2015-10-23 22:37:42 +08:00
<Menu.Item key="page1">
2015-10-21 17:53:38 +08:00
<Link to="/page1">Page 1</Link>
</Menu.Item>
2015-10-23 22:37:42 +08:00
<Menu.Item key="page2">
2015-10-21 17:53:38 +08:00
<Link to="/page2">Page 2</Link>
</Menu.Item>
</Menu>
2015-10-23 22:37:42 +08:00
<QueueAnim type={['right', 'left']} className="demo-router-wrap">
{React.cloneElement(this.props.children || <Home/>, {key: key})}
2015-10-21 17:53:38 +08:00
</QueueAnim>
</div>
);
}
});
2015-10-23 22:37:42 +08:00
const Home = React.createClass({
2015-10-21 17:53:38 +08:00
render() {
return (
2015-10-23 22:37:42 +08:00
<div className="demo-router-child">
2015-10-21 17:53:38 +08:00
<QueueAnim className="demo-content">
2015-10-23 22:37:42 +08:00
<div className="demo-kp" key="a">
<QueueAnim component="ul">
<li key="0"></li>
<li key="1"></li>
<li key="2"></li>
2015-10-21 17:53:38 +08:00
</QueueAnim>
</div>
2015-10-23 22:37:42 +08:00
<div className="demo-kp" key="b">
<QueueAnim component="ul">
<li key="0"></li>
<li key="1"></li>
<li key="2"></li>
2015-10-21 17:53:38 +08:00
</QueueAnim>
</div>
2015-10-23 22:37:42 +08:00
<div className="demo-kp" key="c">
<QueueAnim component="ul">
<li key="0"></li>
<li key="1"></li>
<li key="2"></li>
2015-10-21 17:53:38 +08:00
</QueueAnim>
</div>
</QueueAnim>
</div>
);
}
2015-10-23 22:37:42 +08:00
});
const Page1 = React.createClass({
2015-10-21 17:53:38 +08:00
render() {
return (
2015-10-23 22:37:42 +08:00
<div className="demo-router-child">
2015-10-21 17:53:38 +08:00
<QueueAnim className="demo-content">
2015-10-23 22:37:42 +08:00
<div className="demo-kp" key="b">
<QueueAnim component="ul">
<li key="0"></li>
<li key="1"></li>
<li key="2"></li>
2015-10-21 17:53:38 +08:00
</QueueAnim>
</div>
<div className="demo-listBox">
<QueueAnim className="demo-list" delay={200}>
2015-10-23 22:37:42 +08:00
<div className="title" key="title3"></div>
<QueueAnim component="ul" animConfig={{opacity: [1, 0], translateY: [0, 30], scale: [1, 0.9]}} key="ul">
2015-10-23 22:37:42 +08:00
<li key="0"></li>
<li key="1"></li>
<li key="2"></li>
2015-10-21 17:53:38 +08:00
</QueueAnim>
</QueueAnim>
</div>
</QueueAnim>
</div>
);
}
});
2015-10-23 22:37:42 +08:00
const Page2 = React.createClass({
2015-10-21 17:53:38 +08:00
render() {
return (
2015-10-23 22:37:42 +08:00
<div className="demo-router-child">
<div className="demo-content">
2015-10-21 17:53:38 +08:00
<div className="demo-listBox">
<QueueAnim className="demo-list">
2015-10-23 22:37:42 +08:00
<div className="title" key="title3"></div>
<QueueAnim component="ul" animConfig={{opacity: [1, 0], translateY: [0, 30], scale: [1, 0.9]}} key="li">
2015-10-23 22:37:42 +08:00
<li key="0"></li>
<li key="1"></li>
<li key="2"></li>
<li key="3"></li>
<li key="4"></li>
2015-10-23 23:15:03 +08:00
<li key="5"></li>
2015-10-21 17:53:38 +08:00
</QueueAnim>
</QueueAnim>
</div>
</div>
</div>
);
}
});
2015-10-23 22:37:42 +08:00
2015-10-23 14:53:57 +08:00
ReactDOM.render((
2015-10-21 17:53:38 +08:00
<Router>
<Route path="/" component={App} ignoreScrollBehavior>
<Route path="page1" component={Page1} />
<Route path="page2" component={Page2} />
</Route>
</Router>
), mountNode);
2015-10-21 17:53:38 +08:00
````
2015-10-23 22:37:42 +08:00
````css
#components-queue-anim-demo-router .demo-router-wrap {
2015-10-21 17:53:38 +08:00
position: relative;
width: 100%;
margin: auto;
height:200px;
overflow: hidden;
}
2015-10-23 22:37:42 +08:00
#components-queue-anim-demo-router .queue-anim-leaving {
2015-10-21 17:53:38 +08:00
position: absolute;
width:100%;
}
2015-10-23 22:37:42 +08:00
````