Skip to content

Commit 7bc9c78

Browse files
committed
fix: trigger animate #5008
close #5008
1 parent 7d7f0f3 commit 7bc9c78

File tree

4 files changed

+28
-11
lines changed

4 files changed

+28
-11
lines changed

components/_util/transition.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const getTransitionProps = (transitionName: string, opt: TransitionProps
2626
// appearActiveClass: `antdv-base-transtion`,
2727
// appearToClass: `${transitionName}-appear ${transitionName}-appear-active`,
2828
enterFromClass: `${transitionName}-enter ${transitionName}-enter-prepare`,
29-
// enterActiveClass: `${transitionName}-enter ${transitionName}-enter-active`,
29+
enterActiveClass: `${transitionName}-enter ${transitionName}-enter-prepare`,
3030
enterToClass: `${transitionName}-enter ${transitionName}-enter-active`,
3131
leaveFromClass: ` ${transitionName}-leave`,
3232
leaveActiveClass: `${transitionName}-leave ${transitionName}-leave-active`,

components/vc-trigger/Popup/PopupInner.tsx

+23-6
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,25 @@ export default defineComponent({
3939
measureStretchStyle(props.getRootDomNode());
4040
}
4141
};
42+
const visible = ref(false);
43+
let timeoutId: any;
44+
watch(
45+
() => props.visible,
46+
val => {
47+
clearTimeout(timeoutId);
48+
if (val) {
49+
timeoutId = setTimeout(() => {
50+
visible.value = props.visible;
51+
});
52+
} else {
53+
visible.value = false;
54+
}
55+
},
56+
{ immediate: true },
57+
);
4258

4359
// ======================== Status ========================
44-
const [status, goNextStatus] = useVisibleStatus(toRef(props, 'visible'), doMeasure);
60+
const [status, goNextStatus] = useVisibleStatus(visible, doMeasure);
4561

4662
// ======================== Aligns ========================
4763
const prepareResolveRef = ref<(value?: unknown) => void>();
@@ -117,7 +133,6 @@ export default defineComponent({
117133
return () => {
118134
const {
119135
zIndex,
120-
visible,
121136
align,
122137
prefixCls,
123138
destroyPopupOnHide,
@@ -131,7 +146,8 @@ export default defineComponent({
131146
const mergedStyle: CSSProperties = {
132147
...stretchStyle.value,
133148
zIndex,
134-
opacity: statusValue === 'motion' || statusValue === 'stable' || !visible ? undefined : 0,
149+
opacity:
150+
statusValue === 'motion' || statusValue === 'stable' || !visible.value ? undefined : 0,
135151
pointerEvents: statusValue === 'stable' ? undefined : 'none',
136152
...(attrs.style as object),
137153
};
@@ -149,17 +165,18 @@ export default defineComponent({
149165
childNode = <div class={`${prefixCls}-content`}>{childNode}</div>;
150166
}
151167
const mergedClassName = classNames(prefixCls, attrs.class, alignedClassName.value);
152-
const transitionProps = getTransitionProps(motion.value.name, motion.value);
168+
const hasAnimate = visible.value || !props.visible;
169+
const transitionProps = hasAnimate ? getTransitionProps(motion.value.name, motion.value) : {};
153170
return (
154171
<Transition
155172
ref={elementRef}
156173
{...transitionProps}
157174
onBeforeEnter={onShowPrepare}
158175
v-slots={{
159176
default: () => {
160-
return !destroyPopupOnHide || visible ? (
177+
return !destroyPopupOnHide || props.visible ? (
161178
<Align
162-
v-show={visible}
179+
v-show={visible.value}
163180
target={getAlignTarget()}
164181
key="popup"
165182
ref={alignRef}

components/vc-trigger/Popup/useVisibleStatus.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Ref } from 'vue';
2-
import { nextTick, onBeforeUnmount, ref, watch, onMounted } from 'vue';
2+
import { onBeforeUnmount, ref, watch, onMounted } from 'vue';
33
import type { RafFrame } from '../../_util/raf';
44
import raf from '../../_util/raf';
55

@@ -76,7 +76,7 @@ export default (
7676
}
7777

7878
if (status.value) {
79-
nextTick(() => {
79+
rafRef.value = raf(async () => {
8080
const index = StatusQueue.indexOf(status.value);
8181
const nextStatus = StatusQueue[index + 1];
8282
if (nextStatus && index !== -1) {

components/vc-virtual-list/ScrollBar.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ export default defineComponent({
6262
},
6363

6464
mounted() {
65-
this.scrollbarRef.current.addEventListener(
65+
this.scrollbarRef.current?.addEventListener(
6666
'touchstart',
6767
this.onScrollbarTouchStart,
6868
supportsPassive ? ({ passive: false } as EventListenerOptions) : false,
6969
);
70-
this.thumbRef.current.addEventListener(
70+
this.thumbRef.current?.addEventListener(
7171
'touchstart',
7272
this.onMouseDown,
7373
supportsPassive ? ({ passive: false } as EventListenerOptions) : false,

0 commit comments

Comments
 (0)