2015-09-11 12:02:08 +08:00
|
|
|
# style 自定义样式动画进出场
|
2015-09-10 16:20:24 +08:00
|
|
|
|
2015-09-15 17:41:34 +08:00
|
|
|
- order: 4
|
2015-09-10 16:20:24 +08:00
|
|
|
|
2015-09-11 12:02:08 +08:00
|
|
|
通过加上属性里的 `style` 来自定义 CSS 动画进出场。
|
2015-09-10 16:20:24 +08:00
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
````jsx
|
|
|
|
var EnterAnimation = antd.EnterAnimation;
|
2015-10-08 15:13:04 +08:00
|
|
|
var Button = antd.Button;
|
2015-09-10 16:20:24 +08:00
|
|
|
|
|
|
|
var Test = React.createClass({
|
2015-09-11 12:02:08 +08:00
|
|
|
getInitialState() {
|
2015-09-10 16:20:24 +08:00
|
|
|
return {
|
2015-09-11 12:02:08 +08:00
|
|
|
enter: {
|
|
|
|
style: {
|
|
|
|
transform: "translateX(50px)",
|
|
|
|
opacity: 0
|
2015-09-10 16:20:24 +08:00
|
|
|
},
|
2015-09-11 12:02:08 +08:00
|
|
|
interval: .1,
|
2015-09-10 16:20:24 +08:00
|
|
|
},
|
2015-09-11 12:02:08 +08:00
|
|
|
leave: {
|
|
|
|
interval: 0.03
|
2015-09-10 16:20:24 +08:00
|
|
|
},
|
2015-09-11 12:02:08 +08:00
|
|
|
show: true
|
2015-09-10 16:20:24 +08:00
|
|
|
}
|
|
|
|
},
|
2015-09-11 12:02:08 +08:00
|
|
|
onClick() {
|
2015-09-10 16:20:24 +08:00
|
|
|
this.setState({
|
2015-09-11 12:02:08 +08:00
|
|
|
show: !this.state.show
|
2015-09-10 16:20:24 +08:00
|
|
|
})
|
|
|
|
},
|
|
|
|
render() {
|
|
|
|
return (
|
2015-09-11 12:02:08 +08:00
|
|
|
<div>
|
|
|
|
<div style={{marginBottom: 20}}>
|
2015-10-08 15:13:04 +08:00
|
|
|
<Button type="primary" onClick={this.onClick}>切换</Button>
|
2015-09-11 12:02:08 +08:00
|
|
|
</div>
|
|
|
|
<EnterAnimation enter={this.state.enter} leave={this.state.leave}>
|
|
|
|
{this.state.show ? <div key='enter-data'>
|
|
|
|
<div className="demo-content">
|
|
|
|
<div className="demo-kp">
|
2015-09-10 16:20:24 +08:00
|
|
|
<ul>
|
2015-09-11 12:02:08 +08:00
|
|
|
<li enter-data></li>
|
|
|
|
<li enter-data></li>
|
|
|
|
<li enter-data></li>
|
2015-09-10 16:20:24 +08:00
|
|
|
</ul>
|
|
|
|
</div>
|
2015-09-11 12:02:08 +08:00
|
|
|
<div className="demo-listBox">
|
|
|
|
<div className="demo-list">
|
|
|
|
<div className="title" enter-data={{style: {transform: 'translateY(30px)', opacity: 0}, queueId: 1}}></div>
|
|
|
|
<ul>
|
|
|
|
<li enter-data={{style: {transform: 'translateY(30px)', opacity: 0}, queueId: 1}}></li>
|
|
|
|
<li enter-data={{style: {transform: 'translateY(30px)', opacity: 0}, queueId: 1}}></li>
|
|
|
|
<li enter-data={{style: {transform: 'translateY(30px)', opacity: 0}, queueId: 1}}></li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
2015-09-10 16:20:24 +08:00
|
|
|
</div>
|
|
|
|
</div> : null}
|
2015-09-11 12:02:08 +08:00
|
|
|
</EnterAnimation>
|
|
|
|
</div>
|
2015-09-10 16:20:24 +08:00
|
|
|
)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-10-20 16:47:55 +08:00
|
|
|
ReactDOM.render(<Test />
|
2015-09-10 16:20:24 +08:00
|
|
|
, document.getElementById('components-enter-animation-demo-style'));
|
|
|
|
````
|
|
|
|
|
|
|
|
<style>
|
|
|
|
#components-enter-animation-demo-style {
|
|
|
|
text-align: center;
|
|
|
|
overflow: hidden;
|
|
|
|
margin: 18px auto;
|
|
|
|
}
|
|
|
|
</style>
|