Skip to content

Commit

Permalink
fix: upload height error, close #5298
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjinzhou committed Mar 2, 2022
1 parent 55e0ad7 commit 991fa77
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions components/upload/UploadList/listAnimation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { addClass, removeClass } from '../../vc-util/Dom/class';
import { nextTick } from 'vue';
import type { CSSMotionProps } from '../../_util/transition';

const listAnimation = (name): CSSMotionProps => {
const listAnimation = (name = 'ant-motion-collapse'): CSSMotionProps => {
return {
name,
appear: true,
css: true,
onBeforeEnter: (node: HTMLDivElement) => {
addClass(node, name);
node.style.height = '0px';
node.style.opacity = '0';
addClass(node, name);
},
onEnter: (node: HTMLDivElement) => {
nextTick(() => {
Expand All @@ -19,14 +19,16 @@ const listAnimation = (name): CSSMotionProps => {
});
},
onAfterEnter: (node: HTMLDivElement) => {
if (node) removeClass(node, name);
node.style.height = undefined;
node.style.opacity = undefined;
if (node) {
removeClass(node, name);
node.style.height = null;
node.style.opacity = null;
}
},
onBeforeLeave: (node: HTMLDivElement) => {
addClass(node, name);
node.style.height = `${node.offsetHeight}px`;
node.style.opacity = undefined;
node.style.opacity = null;
},
onLeave: (node: HTMLDivElement) => {
setTimeout(() => {
Expand All @@ -35,9 +37,13 @@ const listAnimation = (name): CSSMotionProps => {
});
},
onAfterLeave: (node: HTMLDivElement) => {
if (node) removeClass(node, name);
node.style.height = undefined;
node.style.opacity = undefined;
if (node) {
removeClass(node, name);
if (node.style) {
node.style.height = null;
node.style.opacity = null;
}
}
},
};
};
Expand Down

0 comments on commit 991fa77

Please sign in to comment.