[Improvement] add overlay component (#442)

This commit is contained in:
neverland 2018-08-20 21:24:57 +08:00 committed by GitHub
parent 44f7581ae2
commit bf4eb7c3e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 29 additions and 20 deletions

View File

@ -1,11 +1,17 @@
Component({ Component({
properties: { properties: {
show: Boolean show: Boolean,
mask: Boolean,
customStyle: String,
zIndex: {
type: Number,
value: 1
}
}, },
methods: { methods: {
onClickOverlay() { onClick() {
this.triggerEvent('click');
} }
} }
}); });

View File

@ -1,3 +1,6 @@
{ {
"component": true "component": true,
"usingComponents": {
"van-transition": "../transition/index"
}
} }

View File

@ -0,0 +1,7 @@
.van-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
}

View File

@ -1,5 +1,6 @@
<view <van-transition
class="overlay-class van-popup__overlay {{ show ? 'van-popup--show' : '' }}" show="{{ show }}"
style="{{ overlayStyle }}" custom-class="van-overlay"
bind:tap="onClickOverlay" custom-style="z-index: {{ zIndex }}; {{ mask ? 'background-color: rgba(0, 0, 0, .7);' : '' }}; {{ customStyle }}"
bind:tap="onClick"
/> />

View File

@ -3,6 +3,7 @@
"usingComponents": { "usingComponents": {
"van-icon": "../icon/index", "van-icon": "../icon/index",
"van-loading": "../loading/index", "van-loading": "../loading/index",
"van-overlay": "../overlay/index",
"van-transition": "../transition/index" "van-transition": "../transition/index"
} }
} }

View File

@ -21,15 +21,6 @@
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
} }
&__overlay {
z-index: 3000;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
&--text { &--text {
padding: 12px; padding: 12px;
min-width: 220px; min-width: 220px;

View File

@ -1,7 +1,7 @@
<van-transition <van-overlay
show="{{ show && (mask || forbidClick) }}" show="{{ show && (mask || forbidClick) }}"
custom-class="van-toast__overlay" mask="{{ mask }}"
custom-style="{{ mask ? 'background-color: rgba(0, 0, 0, .7);' : '' }}" z-index="3000"
/> />
<van-transition <van-transition
show="{{ show }}" show="{{ show }}"