You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ant-design/components/_util/openAnimation.tsx

44 lines
982 B
TypeScript

import cssAnimation from 'css-animation';
import getRequestAnimationFrame from './getRequestAnimationFrame';
10 years ago
function animate(node, show, done) {
let height;
return cssAnimation(node, 'ant-motion-collapse', {
start() {
if (!show) {
node.style.height = `${node.offsetHeight}px`;
node.style.opacity = 1;
} else {
height = node.offsetHeight;
node.style.height = 0;
node.style.opacity = 0;
}
},
active() {
getRequestAnimationFrame()(() => {
node.style.height = `${show ? height : 0}px`;
node.style.opacity = show ? 1 : 0;
});
},
end() {
node.style.height = '';
node.style.opacity = '';
10 years ago
done();
},
10 years ago
});
}
const animation = {
enter(node, done) {
return animate(node, true, done);
10 years ago
},
leave(node, done) {
return animate(node, false, done);
10 years ago
},
appear(node, done) {
return animate(node, true, done);
10 years ago
},
};
export default animation;