[new feature] Notify: add new prop zIndex

fix #1498
This commit is contained in:
rex 2019-04-17 11:49:25 +08:00 committed by GitHub
parent 9752c832d2
commit f635a9c490
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 6 deletions

View File

@ -3,7 +3,6 @@
.van-notify { .van-notify {
position: fixed; position: fixed;
top: 0; top: 0;
z-index: 110;
width: 100%; width: 100%;
padding: @notify-padding; padding: @notify-padding;
font-size: @notify-font-size; font-size: @notify-font-size;

View File

@ -18,6 +18,10 @@ VantComponent({
duration: { duration: {
type: Number, type: Number,
value: 3000 value: 3000
},
zIndex: {
type: Number,
value: 110
} }
}, },

View File

@ -2,7 +2,7 @@
name="slide-down" name="slide-down"
show="{{ show }}" show="{{ show }}"
custom-class="van-notify" custom-class="van-notify"
custom-style="background-color:{{ backgroundColor }}; color: {{ color }};" custom-style="background-color:{{ backgroundColor }}; color: {{ color }}; z-index: {{ zIndex }};"
> >
<view wx:if="{{ safeAreaInsetTop }}" class="van-notify__safe-top" style="padding-top: {{ statusBarHeight }}px"></view> <view wx:if="{{ safeAreaInsetTop }}" class="van-notify__safe-top" style="padding-top: {{ statusBarHeight }}px"></view>
{{ text }} {{ text }}

View File

@ -1,6 +1,6 @@
import { isObj } from '../common/utils'; import { isObj } from '../common/utils';
type NotifyOptions = { interface NotifyOptions {
text: string; text: string;
color?: string; color?: string;
backgroundColor?: string; backgroundColor?: string;
@ -8,7 +8,8 @@ type NotifyOptions = {
selector?: string; selector?: string;
context?: any; context?: any;
safeAreaInsetTop?: boolean; safeAreaInsetTop?: boolean;
}; zIndex?: number;
}
const defaultOptions = { const defaultOptions = {
selector: '#van-notify', selector: '#van-notify',
@ -16,10 +17,10 @@ const defaultOptions = {
}; };
function parseOptions(text: NotifyOptions | string): NotifyOptions { function parseOptions(text: NotifyOptions | string): NotifyOptions {
return isObj(text) ? text as NotifyOptions : { text } as NotifyOptions; return isObj(text) ? (text as NotifyOptions) : ({ text } as NotifyOptions);
} }
function getContext() { function getContext(): Page.PageInstance {
const pages = getCurrentPages(); const pages = getCurrentPages();
return pages[pages.length - 1]; return pages[pages.length - 1];
} }