mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[Improvement] uniform fade animation (#410)
This commit is contained in:
parent
49ef814d1e
commit
7dbb5db256
@ -1,11 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<transition name="van-fade">
|
||||||
<div
|
<div
|
||||||
|
v-show="visible"
|
||||||
class="van-modal"
|
class="van-modal"
|
||||||
:class="className"
|
:class="className"
|
||||||
:style="style"
|
:style="style"
|
||||||
@touchmove.prevent.stop
|
@touchmove.prevent.stop
|
||||||
@click="$emit('click', $event)"
|
@click="$emit('click', $event)"
|
||||||
/>
|
/>
|
||||||
|
</transition>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -13,6 +16,7 @@ export default {
|
|||||||
name: 'van-modal',
|
name: 'van-modal',
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
|
visible: Boolean,
|
||||||
zIndex: Number,
|
zIndex: Number,
|
||||||
className: String,
|
className: String,
|
||||||
customStyle: Object
|
customStyle: Object
|
||||||
|
@ -66,7 +66,7 @@ const PopupManager = {
|
|||||||
const el = modal.$el;
|
const el = modal.$el;
|
||||||
|
|
||||||
if (el.parentNode) {
|
if (el.parentNode) {
|
||||||
el.parentNode.removeChild(el);
|
modal.visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context.top) {
|
if (context.top) {
|
||||||
@ -75,7 +75,8 @@ const PopupManager = {
|
|||||||
targetNode.appendChild(el);
|
targetNode.appendChild(el);
|
||||||
Object.assign(modal, {
|
Object.assign(modal, {
|
||||||
...modalDefaultConfig,
|
...modalDefaultConfig,
|
||||||
...config
|
...config,
|
||||||
|
visible: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
const transition = this.transition || (this.position === '' ? 'popup-fade' : `popup-slide-${this.position}`);
|
const transition = this.transition || (this.position === '' ? 'van-fade' : `popup-slide-${this.position}`);
|
||||||
return {
|
return {
|
||||||
currentValue: false,
|
currentValue: false,
|
||||||
currentTransition: transition
|
currentTransition: transition
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<transition name="van-toast-fade">
|
<transition name="van-fade">
|
||||||
<div class="van-toast-wrapper" v-show="visible">
|
<div class="van-toast-wrapper" v-show="visible">
|
||||||
<div class="van-toast" :class="[`van-toast--${displayStyle}`, `van-toast--${position}`]">
|
<div class="van-toast" :class="[`van-toast--${displayStyle}`, `van-toast--${position}`]">
|
||||||
<!-- text only -->
|
<!-- text only -->
|
||||||
|
@ -19,6 +19,25 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes van-fade-out {
|
||||||
|
from {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.van-fade {
|
||||||
|
&-enter-active {
|
||||||
|
animation: .3s van-fade-in;
|
||||||
|
}
|
||||||
|
|
||||||
|
&-leave-active {
|
||||||
|
animation: .3s van-fade-out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.van-slide-bottom {
|
.van-slide-bottom {
|
||||||
&-enter-active {
|
&-enter-active {
|
||||||
animation: van-slide-bottom-enter .3s both ease;
|
animation: van-slide-bottom-enter .3s both ease;
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
background-color: rgba(0, 0, 0, 0.7);
|
background-color: rgba(0, 0, 0, 0.7);
|
||||||
animation: van-fade-in .3s both;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&-overflow-hidden {
|
&-overflow-hidden {
|
||||||
@ -77,7 +76,3 @@
|
|||||||
.popup-slide-left-enter, .popup-slide-left-leave-active {
|
.popup-slide-left-enter, .popup-slide-left-leave-active {
|
||||||
transform: translate3d(-100%, -50%, 0);
|
transform: translate3d(-100%, -50%, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
.popup-fade-enter, .popup-fade-leave-active {
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
|
@ -17,10 +17,6 @@
|
|||||||
transform: translate3d(-50%, -50%, 0);
|
transform: translate3d(-50%, -50%, 0);
|
||||||
background-color: rgba(39, 39, 39, .7);
|
background-color: rgba(39, 39, 39, .7);
|
||||||
|
|
||||||
&-wrapper {
|
|
||||||
transition: opacity .2s;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__overlay {
|
&__overlay {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
@ -68,7 +64,3 @@
|
|||||||
bottom: 50px;
|
bottom: 50px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.van-toast-fade-enter, .van-toast-fade-leave-to {
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
|
@ -97,7 +97,7 @@ describe('Toast', () => {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
expect(document.querySelector('.van-toast-wrapper').style.display === 'none').to.be.true;
|
expect(document.querySelector('.van-toast-wrapper').style.display === 'none').to.be.true;
|
||||||
done();
|
done();
|
||||||
}, 300);
|
}, 500);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('toast duration 0', (done) => {
|
it('toast duration 0', (done) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user