From 7bc9c78d518bd10811dd22a23be682e761219396 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Sat, 11 Dec 2021 14:59:52 +0800 Subject: [PATCH] fix: trigger animate #5008 close #5008 --- components/_util/transition.tsx | 2 +- components/vc-trigger/Popup/PopupInner.tsx | 29 +++++++++++++++---- .../vc-trigger/Popup/useVisibleStatus.ts | 4 +-- components/vc-virtual-list/ScrollBar.tsx | 4 +-- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/components/_util/transition.tsx b/components/_util/transition.tsx index 7ff1590a9..d56a033f6 100644 --- a/components/_util/transition.tsx +++ b/components/_util/transition.tsx @@ -26,7 +26,7 @@ export const getTransitionProps = (transitionName: string, opt: TransitionProps // appearActiveClass: `antdv-base-transtion`, // appearToClass: `${transitionName}-appear ${transitionName}-appear-active`, enterFromClass: `${transitionName}-enter ${transitionName}-enter-prepare`, - // enterActiveClass: `${transitionName}-enter ${transitionName}-enter-active`, + enterActiveClass: `${transitionName}-enter ${transitionName}-enter-prepare`, enterToClass: `${transitionName}-enter ${transitionName}-enter-active`, leaveFromClass: ` ${transitionName}-leave`, leaveActiveClass: `${transitionName}-leave ${transitionName}-leave-active`, diff --git a/components/vc-trigger/Popup/PopupInner.tsx b/components/vc-trigger/Popup/PopupInner.tsx index cd623a62c..a9b4697ba 100644 --- a/components/vc-trigger/Popup/PopupInner.tsx +++ b/components/vc-trigger/Popup/PopupInner.tsx @@ -39,9 +39,25 @@ export default defineComponent({ measureStretchStyle(props.getRootDomNode()); } }; + const visible = ref(false); + let timeoutId: any; + watch( + () => props.visible, + val => { + clearTimeout(timeoutId); + if (val) { + timeoutId = setTimeout(() => { + visible.value = props.visible; + }); + } else { + visible.value = false; + } + }, + { immediate: true }, + ); // ======================== Status ======================== - const [status, goNextStatus] = useVisibleStatus(toRef(props, 'visible'), doMeasure); + const [status, goNextStatus] = useVisibleStatus(visible, doMeasure); // ======================== Aligns ======================== const prepareResolveRef = ref<(value?: unknown) => void>(); @@ -117,7 +133,6 @@ export default defineComponent({ return () => { const { zIndex, - visible, align, prefixCls, destroyPopupOnHide, @@ -131,7 +146,8 @@ export default defineComponent({ const mergedStyle: CSSProperties = { ...stretchStyle.value, zIndex, - opacity: statusValue === 'motion' || statusValue === 'stable' || !visible ? undefined : 0, + opacity: + statusValue === 'motion' || statusValue === 'stable' || !visible.value ? undefined : 0, pointerEvents: statusValue === 'stable' ? undefined : 'none', ...(attrs.style as object), }; @@ -149,7 +165,8 @@ export default defineComponent({ childNode =