[bugfix] Transition: behavior error when set duration zero

This commit is contained in:
rex 2019-03-20 20:46:15 +08:00 committed by GitHub
parent 5cd20000d1
commit b5238ed753
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 14 deletions

View File

@ -3,6 +3,7 @@
<van-popup
show="{{ show.middle }}"
custom-class="center"
transition="none"
bind:close="togglePopup"
bind:transitionEnd="onTransitionEnd"
>

View File

@ -60,6 +60,7 @@ export const transition = function(showDefaultValue: boolean) {
show() {
const { classNames, duration } = this.data;
const currentDuration = isObj(duration) ? duration.leave : duration;
Promise.resolve()
.then(nextTick)
@ -68,7 +69,7 @@ export const transition = function(showDefaultValue: boolean) {
inited: true,
display: true,
classes: classNames.enter,
currentDuration: isObj(duration) ? duration.enter : duration
currentDuration
})
)
.then(nextTick)
@ -81,13 +82,19 @@ export const transition = function(showDefaultValue: boolean) {
leave() {
const { classNames, duration } = this.data;
const currentDuration = isObj(duration) ? duration.leave : duration;
if (+currentDuration === 0) {
this.onTransitionEnd();
return;
}
Promise.resolve()
.then(nextTick)
.then(() =>
this.set({
classes: classNames.leave,
currentDuration: isObj(duration) ? duration.leave : duration
currentDuration
})
)
.then(nextTick)

View File

@ -116,14 +116,3 @@
.van-right-leave-to {
transform: translate3d(100%, -50%, 0);
}
.van-none-enter-active,
.van-none-leave-active {
transition-duration: 1ms !important;
transition-property: opacity;
}
.van-none-enter,
.van-none-leave-to {
opacity: 0.999;
}

View File

@ -56,6 +56,10 @@ VantComponent({
observeClass() {
const { transition, position } = this.data;
this.updateClasses(transition || position);
if (transition === 'none') {
this.set({ duration: 0 });
}
}
}
});

View File

@ -6,7 +6,7 @@
show="{{ show }}"
z-index="{{ zIndex }}"
custom-style="{{ overlayStyle }}"
duration="{{ transition === 'none' ? 1 : duration }}"
duration="{{ duration }}"
bind:click="onClickOverlay"
/>
<view