mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
refactor(transition): no longer throw error in wrong status (#4003)
fix #3993
This commit is contained in:
parent
f7c90a1761
commit
3b015fe1a3
@ -42,6 +42,7 @@ export function transition(showDefaultValue: boolean) {
|
||||
if (value === old) {
|
||||
return;
|
||||
}
|
||||
|
||||
value ? this.enter() : this.leave();
|
||||
},
|
||||
|
||||
@ -54,7 +55,10 @@ export function transition(showDefaultValue: boolean) {
|
||||
this.$emit('before-enter');
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
this.checkStatus('enter');
|
||||
if (this.status !== 'enter') {
|
||||
return;
|
||||
}
|
||||
|
||||
this.$emit('enter');
|
||||
|
||||
this.setData({
|
||||
@ -65,9 +69,11 @@ export function transition(showDefaultValue: boolean) {
|
||||
});
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
this.checkStatus('enter');
|
||||
this.transitionEnded = false;
|
||||
if (this.status !== 'enter') {
|
||||
return;
|
||||
}
|
||||
|
||||
this.transitionEnded = false;
|
||||
this.setData({ classes: classNames['enter-to'] });
|
||||
});
|
||||
});
|
||||
@ -86,7 +92,10 @@ export function transition(showDefaultValue: boolean) {
|
||||
this.$emit('before-leave');
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
this.checkStatus('leave');
|
||||
if (this.status !== 'leave') {
|
||||
return;
|
||||
}
|
||||
|
||||
this.$emit('leave');
|
||||
|
||||
this.setData({
|
||||
@ -95,7 +104,10 @@ export function transition(showDefaultValue: boolean) {
|
||||
});
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
this.checkStatus('leave');
|
||||
if (this.status !== 'leave') {
|
||||
return;
|
||||
}
|
||||
|
||||
this.transitionEnded = false;
|
||||
setTimeout(() => this.onTransitionEnd(), currentDuration);
|
||||
|
||||
@ -104,12 +116,6 @@ export function transition(showDefaultValue: boolean) {
|
||||
});
|
||||
},
|
||||
|
||||
checkStatus(status: 'enter' | 'leave') {
|
||||
if (status !== this.status) {
|
||||
throw new Error(`incongruent status: ${status}`);
|
||||
}
|
||||
},
|
||||
|
||||
onTransitionEnd() {
|
||||
if (this.transitionEnded) {
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user