2019-01-12 03:33:27 +00:00
|
|
|
import cssAnimation from '../../_util/css-animation';
|
2018-02-01 10:18:05 +00:00
|
|
|
|
2019-01-12 03:33:27 +00:00
|
|
|
function animate(node, show, transitionName, done) {
|
|
|
|
let height;
|
2018-02-01 10:18:05 +00:00
|
|
|
return cssAnimation(node, transitionName, {
|
2019-01-12 03:33:27 +00:00
|
|
|
start() {
|
2018-02-01 10:18:05 +00:00
|
|
|
if (!show) {
|
2019-01-12 03:33:27 +00:00
|
|
|
node.style.height = `${node.offsetHeight}px`;
|
2018-02-01 10:18:05 +00:00
|
|
|
} else {
|
2019-01-12 03:33:27 +00:00
|
|
|
height = node.offsetHeight;
|
|
|
|
node.style.height = 0;
|
2018-02-01 10:18:05 +00:00
|
|
|
}
|
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
active() {
|
|
|
|
node.style.height = `${show ? height : 0}px`;
|
2018-02-01 10:18:05 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
end() {
|
|
|
|
node.style.height = '';
|
|
|
|
done();
|
2018-02-01 10:18:05 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
});
|
2018-02-01 10:18:05 +00:00
|
|
|
}
|
|
|
|
|
2019-01-12 03:33:27 +00:00
|
|
|
function animation(prefixCls) {
|
2018-02-01 10:18:05 +00:00
|
|
|
return {
|
2020-07-16 08:24:44 +00:00
|
|
|
onEnter(node, done) {
|
2019-01-12 03:33:27 +00:00
|
|
|
return animate(node, true, `${prefixCls}-anim`, done);
|
2018-02-01 10:18:05 +00:00
|
|
|
},
|
2020-07-16 08:24:44 +00:00
|
|
|
onLeave(node, done) {
|
2019-01-12 03:33:27 +00:00
|
|
|
return animate(node, false, `${prefixCls}-anim`, done);
|
2018-02-01 10:18:05 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
2018-02-01 10:18:05 +00:00
|
|
|
}
|
|
|
|
|
2019-01-12 03:33:27 +00:00
|
|
|
export default animation;
|