mirror of
https://github.com/youzan/vant.git
synced 2025-10-21 11:17:41 +00:00
[bugfix] Toast: overlay blocked by other element (#740)
This commit is contained in:
@@ -6,10 +6,11 @@ const defaultOptions = {
|
||||
type: 'text',
|
||||
mask: false,
|
||||
message: '',
|
||||
visible: true,
|
||||
value: true,
|
||||
duration: 3000,
|
||||
position: 'middle',
|
||||
forbidClick: false
|
||||
forbidClick: false,
|
||||
overlayStyle: {}
|
||||
};
|
||||
const parseOptions = message => isObj(message) ? message : { message };
|
||||
|
||||
@@ -28,6 +29,16 @@ function createInstance() {
|
||||
return queue[queue.length - 1];
|
||||
};
|
||||
|
||||
// transform toast options to popup props
|
||||
function transformer(options) {
|
||||
options.overlay = options.mask;
|
||||
if (options.forbidClick && !options.overlay) {
|
||||
options.overlay = true;
|
||||
options.overlayStyle = { background: 'transparent' };
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
function Toast(options = {}) {
|
||||
const toast = createInstance();
|
||||
|
||||
@@ -35,11 +46,11 @@ function Toast(options = {}) {
|
||||
...currentOptions,
|
||||
...parseOptions(options),
|
||||
clear() {
|
||||
toast.visible = false;
|
||||
toast.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
Object.assign(toast, options);
|
||||
Object.assign(toast, transformer(options));
|
||||
clearTimeout(toast.timer);
|
||||
|
||||
if (options.duration > 0) {
|
||||
|
Reference in New Issue
Block a user