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() {
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'] });
});