ant-design/components/enter-animation/demo/basic.md

103 lines
2.4 KiB
Markdown
Raw Normal View History

2015-07-28 18:33:40 +08:00
# 默认
2015-07-28 12:32:27 +08:00
- order: 0
2015-07-29 14:50:00 +08:00
默认子节点进场动画。为避免与本站页面的进场冲突,所以 `EnterAnimation` 里延时 1 秒,递增 `interval` 为 0.3。
2015-07-28 12:32:27 +08:00
2015-08-04 17:07:31 +08:00
2015-07-28 12:32:27 +08:00
---
2015-07-28 18:33:40 +08:00
2015-07-28 12:32:27 +08:00
````jsx
2015-07-28 15:16:51 +08:00
var EnterAnimation = antd.EnterAnimation;
2015-07-28 18:33:40 +08:00
2015-07-28 12:32:27 +08:00
var Test = React.createClass({
2015-09-07 18:37:07 +08:00
getInitialState() {
2015-08-12 14:57:45 +08:00
return {
2015-09-07 18:37:07 +08:00
enter:{
type: 'right',
interval: 0.3,
callback:()=>{
console.log('enter');
}
},
leave:{
type: 'left',
interval: .1,
callback:()=>{
console.log('leave');
}
},
bool:true,
2015-08-12 14:57:45 +08:00
}
},
2015-09-07 18:37:07 +08:00
onClick() {
2015-08-12 14:57:45 +08:00
this.setState({
2015-09-07 18:37:07 +08:00
bool:!this.state.bool,
2015-08-12 14:57:45 +08:00
})
},
2015-07-28 12:32:27 +08:00
render() {
2015-07-28 15:16:51 +08:00
return (
2015-08-12 14:57:45 +08:00
<div>
2015-09-07 18:37:07 +08:00
<div style={{marginBottom: 20}}>
<button className="ant-btn ant-btn-primary" onClick={this.onClick}>切换</button>
2015-07-28 15:16:51 +08:00
</div>
2015-09-07 18:37:07 +08:00
<EnterAnimation enter={this.state.enter} leave={this.state.leave}>
{this.state.bool ? <div key='a'>
<div className="demo-header">
<div className="logo">
<img width="30" src="https://t.alipayobjects.com/images/rmsweb/T1B9hfXcdvXXXXXXXX.svg" />
<span>logo</span>
</div>
2015-07-29 12:17:18 +08:00
<ul>
<li></li>
<li></li>
<li></li>
2015-09-07 18:37:07 +08:00
<li></li>
<li></li>
2015-07-29 12:17:18 +08:00
</ul>
</div>
2015-09-07 18:37:07 +08:00
<div className="demo-content" >
<div className="demo-title">我是标题</div>
<div className="demo-kp">
2015-08-12 14:57:45 +08:00
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</div>
2015-09-07 18:37:07 +08:00
<div className="demo-title">我是标题</div>
<div className="demo-listBox">
<div className="demo-list">
<div className="title"></div>
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
</div>
2015-08-12 14:57:45 +08:00
</div>
2015-09-07 18:37:07 +08:00
<div className="demo-footer"></div>
</div> : null}
2015-08-12 14:57:45 +08:00
</EnterAnimation>
</div>
2015-07-28 18:33:40 +08:00
);
2015-07-28 12:32:27 +08:00
}
});
2015-07-28 18:33:40 +08:00
React.render(<Test />
, document.getElementById('components-enter-animation-demo-basic'));
2015-07-28 12:32:27 +08:00
````
2015-07-28 18:33:40 +08:00
2015-07-28 15:16:51 +08:00
<style>
2015-07-28 18:33:40 +08:00
#components-enter-animation-demo-basic {
width: 600px;
2015-07-28 15:16:51 +08:00
text-align: center;
overflow: hidden;
margin: 20px auto;
}
</style>