mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-15 17:31:25 +08:00
37 lines
724 B
TypeScript
37 lines
724 B
TypeScript
import cssAnimation from 'css-animation';
|
|
|
|
function animate(node, show, done) {
|
|
let height;
|
|
return cssAnimation(node, 'ant-motion-collapse', {
|
|
start() {
|
|
if (!show) {
|
|
node.style.height = `${node.offsetHeight}px`;
|
|
} else {
|
|
height = node.offsetHeight;
|
|
node.style.height = 0;
|
|
}
|
|
},
|
|
active() {
|
|
node.style.height = `${show ? height : 0}px`;
|
|
},
|
|
end() {
|
|
node.style.height = '';
|
|
done();
|
|
},
|
|
});
|
|
}
|
|
|
|
const animation = {
|
|
enter(node, done) {
|
|
return animate(node, true, done);
|
|
},
|
|
leave(node, done) {
|
|
return animate(node, false, done);
|
|
},
|
|
appear(node, done) {
|
|
return animate(node, true, done);
|
|
},
|
|
};
|
|
|
|
export default animation;
|