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

61 lines
1.2 KiB
Markdown
Raw Normal View History

2016-03-31 09:40:55 +08:00
---
order: 3
title: 自定义动画进出场
---
2015-10-23 22:37:42 +08:00
通过 `animConfig` 来自定义动画进出场。
````jsx
import { QueueAnim, Button } from 'antd';
const Test = React.createClass({
2015-10-23 22:37:42 +08:00
getInitialState() {
return {
show: true,
};
2015-10-23 22:37:42 +08:00
},
onClick() {
this.setState({
show: !this.state.show,
});
2015-10-23 22:37:42 +08:00
},
render() {
2016-04-13 15:00:47 +08:00
const list = this.state.show ? [
<div className="demo-kp" key="a">
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</div>,
<div className="demo-listBox" key="b">
<div className="demo-list">
<div className="title"></div>
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</div>
2016-05-11 09:32:33 +08:00
</div>,
2016-04-13 15:00:47 +08:00
] : null;
2015-10-23 22:37:42 +08:00
return (
<div>
<p className="buttons">
<Button type="primary" onClick={this.onClick}>切换</Button>
</p>
<QueueAnim className="demo-content"
animConfig={[
{ opacity: [1, 0], translateY: [0, 50] },
2016-05-11 09:32:33 +08:00
{ opacity: [1, 0], translateY: [0, -50] },
2015-10-23 22:37:42 +08:00
]}>
2016-04-13 15:00:47 +08:00
{list}
2015-10-23 22:37:42 +08:00
</QueueAnim>
</div>
);
2016-05-11 09:32:33 +08:00
},
2015-10-23 22:37:42 +08:00
});
ReactDOM.render(<Test />, mountNode);
2015-10-23 22:37:42 +08:00
````