mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-26 11:36:33 +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) {
|
if (value === old) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
value ? this.enter() : this.leave();
|
value ? this.enter() : this.leave();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -54,7 +55,10 @@ export function transition(showDefaultValue: boolean) {
|
|||||||
this.$emit('before-enter');
|
this.$emit('before-enter');
|
||||||
|
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
this.checkStatus('enter');
|
if (this.status !== 'enter') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.$emit('enter');
|
this.$emit('enter');
|
||||||
|
|
||||||
this.setData({
|
this.setData({
|
||||||
@ -65,9 +69,11 @@ export function transition(showDefaultValue: boolean) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
this.checkStatus('enter');
|
if (this.status !== 'enter') {
|
||||||
this.transitionEnded = false;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.transitionEnded = false;
|
||||||
this.setData({ classes: classNames['enter-to'] });
|
this.setData({ classes: classNames['enter-to'] });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -86,7 +92,10 @@ export function transition(showDefaultValue: boolean) {
|
|||||||
this.$emit('before-leave');
|
this.$emit('before-leave');
|
||||||
|
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
this.checkStatus('leave');
|
if (this.status !== 'leave') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.$emit('leave');
|
this.$emit('leave');
|
||||||
|
|
||||||
this.setData({
|
this.setData({
|
||||||
@ -95,7 +104,10 @@ export function transition(showDefaultValue: boolean) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
this.checkStatus('leave');
|
if (this.status !== 'leave') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.transitionEnded = false;
|
this.transitionEnded = false;
|
||||||
setTimeout(() => this.onTransitionEnd(), currentDuration);
|
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() {
|
onTransitionEnd() {
|
||||||
if (this.transitionEnded) {
|
if (this.transitionEnded) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user