vuecssuiant-designantdreactantantd-vueenterprisefrontendui-designvue-antdvue-antd-uivue3vuecomponent
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.3 KiB
51 lines
1.3 KiB
3 years ago
|
import { nextTick } from 'vue';
|
||
3 years ago
|
import { addClass, removeClass } from '../vc-util/Dom/class';
|
||
|
import type { CSSMotionProps } from './transition';
|
||
3 years ago
|
|
||
3 years ago
|
const collapseMotion = (name = 'ant-motion-collapse', appear = true): CSSMotionProps => {
|
||
3 years ago
|
return {
|
||
|
name,
|
||
3 years ago
|
appear,
|
||
3 years ago
|
css: true,
|
||
|
onBeforeEnter: (node: HTMLDivElement) => {
|
||
|
node.style.height = '0px';
|
||
|
node.style.opacity = '0';
|
||
3 years ago
|
addClass(node, name);
|
||
3 years ago
|
},
|
||
|
onEnter: (node: HTMLDivElement) => {
|
||
|
nextTick(() => {
|
||
|
node.style.height = `${node.scrollHeight}px`;
|
||
|
node.style.opacity = '1';
|
||
|
});
|
||
|
},
|
||
|
onAfterEnter: (node: HTMLDivElement) => {
|
||
3 years ago
|
if (node) {
|
||
|
removeClass(node, name);
|
||
|
node.style.height = null;
|
||
|
node.style.opacity = null;
|
||
|
}
|
||
3 years ago
|
},
|
||
|
onBeforeLeave: (node: HTMLDivElement) => {
|
||
|
addClass(node, name);
|
||
|
node.style.height = `${node.offsetHeight}px`;
|
||
3 years ago
|
node.style.opacity = null;
|
||
3 years ago
|
},
|
||
|
onLeave: (node: HTMLDivElement) => {
|
||
|
setTimeout(() => {
|
||
|
node.style.height = '0px';
|
||
|
node.style.opacity = '0';
|
||
|
});
|
||
|
},
|
||
|
onAfterLeave: (node: HTMLDivElement) => {
|
||
3 years ago
|
if (node) {
|
||
|
removeClass(node, name);
|
||
|
if (node.style) {
|
||
|
node.style.height = null;
|
||
|
node.style.opacity = null;
|
||
|
}
|
||
|
}
|
||
3 years ago
|
},
|
||
|
};
|
||
|
};
|
||
3 years ago
|
export default collapseMotion;
|