From b9f88ec64acf097610108939928fe8e1d645c2cb Mon Sep 17 00:00:00 2001 From: xiami <64689255+johnsonwong666@users.noreply.github.com> Date: Mon, 22 Jan 2024 19:29:18 +0800 Subject: [PATCH] fix(Transition): fix transition event sequence (#5707) --- packages/mixins/transition.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/mixins/transition.ts b/packages/mixins/transition.ts index 7aa9d751..044f6daa 100644 --- a/packages/mixins/transition.ts +++ b/packages/mixins/transition.ts @@ -53,7 +53,8 @@ export function transition(showDefaultValue: boolean) { }, enter() { - this.waitEnterEndPromise = new Promise((resolve) => { + if (this.enterFinishedPromise) return; + this.enterFinishedPromise = new Promise((resolve) => { const { duration, name } = this.data; const classNames = getClassNames(name); const currentDuration = isObj(duration) ? duration.enter : duration; @@ -93,8 +94,8 @@ export function transition(showDefaultValue: boolean) { }, leave() { - if (!this.waitEnterEndPromise) return; - this.waitEnterEndPromise.then(() => { + if (!this.enterFinishedPromise) return; + this.enterFinishedPromise.then(() => { if (!this.data.display) { return; } @@ -124,7 +125,10 @@ export function transition(showDefaultValue: boolean) { } this.transitionEnded = false; - setTimeout(() => this.onTransitionEnd(), currentDuration); + setTimeout(() => { + this.onTransitionEnd(); + this.enterFinishedPromise = null; + }, currentDuration); this.setData({ classes: classNames['leave-to'] }); });