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

81 lines
2.2 KiB
Markdown
Raw Normal View History

2015-09-11 12:02:08 +08:00
# style 自定义样式动画进出场
2015-09-11 12:02:08 +08:00
- order: 3
2015-09-11 12:02:08 +08:00
通过加上属性里的 `style` 来自定义 CSS 动画进出场。
---
````jsx
var EnterAnimation = antd.EnterAnimation;
var Test = React.createClass({
2015-09-11 12:02:08 +08:00
getInitialState() {
return {
2015-09-11 12:02:08 +08:00
enter: {
style: {
transform: "translateX(50px)",
opacity: 0
},
2015-09-11 12:02:08 +08:00
interval: .1,
},
2015-09-11 12:02:08 +08:00
leave: {
interval: 0.03
},
2015-09-11 12:02:08 +08:00
show: true
}
},
2015-09-11 12:02:08 +08:00
onClick() {
this.setState({
2015-09-11 12:02:08 +08:00
show: !this.state.show
})
},
render() {
return (
2015-09-11 12:02:08 +08:00
<div>
<div style={{marginBottom: 20}}>
<button className="ant-btn ant-btn-primary" onClick={this.onClick}>切换</button>
</div>
<EnterAnimation enter={this.state.enter} leave={this.state.leave}>
{this.state.show ? <div key='enter-data'>
<div className="demo-content">
<div className="demo-title" enter-data={{style: {opacity: 0}}}>我是标题</div>
<div className="demo-kp">
<ul>
2015-09-11 12:02:08 +08:00
<li enter-data></li>
<li enter-data></li>
<li enter-data></li>
</ul>
</div>
2015-09-11 12:02:08 +08:00
<div className="demo-title" enter-data={{style: {opacity: 0}, queueId: 1, delay: 0.8}} leave-data={{delay: 0.1}}>我是标题</div>
<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>
</div>
</div> : null}
2015-09-11 12:02:08 +08:00
</EnterAnimation>
</div>
)
}
});
React.render(<Test />
, document.getElementById('components-enter-animation-demo-style'));
````
<style>
#components-enter-animation-demo-style {
text-align: center;
overflow: hidden;
margin: 18px auto;
}
</style>