Skip to content

Commit

Permalink
fix: fix tree node folding animation (#3234)
Browse files Browse the repository at this point in the history
Co-authored-by: liwenbo <[email protected]>
  • Loading branch information
li1615882553 and liwenbo authored Jul 26, 2024
1 parent 6e7269c commit 2e54ebd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/web-vue/components/tree/expand-transition.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<template>
<transition
@before-enter="onBeforeEnter"
@enter="onEnter"
@after-enter="onAfterEnter"
@before-leave="onBeforeLeave"
Expand All @@ -20,11 +19,12 @@ export default defineComponent({
emits: ['end'],
setup(props, { emit }) {
return {
onBeforeEnter(el: HTMLDivElement) {
el.style.height = props.expanded ? '0' : `${el.scrollHeight}px`;
},
onEnter(el: HTMLDivElement) {
el.style.height = props.expanded ? `${el.scrollHeight}px` : '0';
const endHeight = `${el.scrollHeight}px`;
el.style.height = props.expanded ? '0' : endHeight;
// eslint-disable-next-line no-unused-expressions
el.offsetHeight;
el.style.height = props.expanded ? endHeight : '0';
},
onAfterEnter(el: HTMLDivElement) {
el.style.height = props.expanded ? '' : '0';
Expand Down

0 comments on commit 2e54ebd

Please sign in to comment.