fix(Transition): fix transition event sequence (#5707)

This commit is contained in:
xiami 2024-01-22 19:29:18 +08:00 committed by GitHub
parent c0b7537da9
commit b9f88ec64a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -53,7 +53,8 @@ export function transition(showDefaultValue: boolean) {
}, },
enter() { enter() {
this.waitEnterEndPromise = new Promise((resolve) => { if (this.enterFinishedPromise) return;
this.enterFinishedPromise = new Promise((resolve) => {
const { duration, name } = this.data; const { duration, name } = this.data;
const classNames = getClassNames(name); const classNames = getClassNames(name);
const currentDuration = isObj(duration) ? duration.enter : duration; const currentDuration = isObj(duration) ? duration.enter : duration;
@ -93,8 +94,8 @@ export function transition(showDefaultValue: boolean) {
}, },
leave() { leave() {
if (!this.waitEnterEndPromise) return; if (!this.enterFinishedPromise) return;
this.waitEnterEndPromise.then(() => { this.enterFinishedPromise.then(() => {
if (!this.data.display) { if (!this.data.display) {
return; return;
} }
@ -124,7 +125,10 @@ export function transition(showDefaultValue: boolean) {
} }
this.transitionEnded = false; this.transitionEnded = false;
setTimeout(() => this.onTransitionEnd(), currentDuration); setTimeout(() => {
this.onTransitionEnd();
this.enterFinishedPromise = null;
}, currentDuration);
this.setData({ classes: classNames['leave-to'] }); this.setData({ classes: classNames['leave-to'] });
}); });