mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-28 17:29:16 +08:00
[bugfix] Dialog: overlay incorrect locate when use getContainer (#3041)
This commit is contained in:
parent
c1adaebaa6
commit
784b279738
@ -2,7 +2,6 @@ import { OverlayConfig } from './overlay';
|
||||
|
||||
export type StackItem = {
|
||||
vm: any;
|
||||
target: HTMLElement;
|
||||
config: OverlayConfig;
|
||||
};
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { context } from './context';
|
||||
import { TouchMixin } from '../touch';
|
||||
import { on, off } from '../../utils/event';
|
||||
import { openOverlay, closeOverlay } from './overlay';
|
||||
import { openOverlay, closeOverlay, updateOverlay } from './overlay';
|
||||
import { getScrollEventTarget } from '../../utils/scroll';
|
||||
|
||||
export const PopupMixin = {
|
||||
@ -154,6 +154,10 @@ export const PopupMixin = {
|
||||
if (container && container !== this.$el.parentNode) {
|
||||
container.appendChild(this.$el);
|
||||
}
|
||||
|
||||
if (this.overlay) {
|
||||
updateOverlay();
|
||||
}
|
||||
},
|
||||
|
||||
onTouchMove(e) {
|
||||
|
@ -31,7 +31,7 @@ function onClickOverlay(): void {
|
||||
}
|
||||
}
|
||||
|
||||
function updateOverlay(): void {
|
||||
export function updateOverlay(): void {
|
||||
if (!overlay) {
|
||||
overlay = mount(Overlay, {
|
||||
on: {
|
||||
@ -40,26 +40,26 @@ function updateOverlay(): void {
|
||||
});
|
||||
}
|
||||
|
||||
if (overlay.$el.parentNode) {
|
||||
overlay.visible = false;
|
||||
}
|
||||
|
||||
if (context.top) {
|
||||
const { target, config } = context.top;
|
||||
const { vm, config } = context.top;
|
||||
|
||||
const el = vm.$el;
|
||||
const target = el && el.parentNode ? el.parentNode : document.body;
|
||||
if (target) {
|
||||
target.appendChild(overlay.$el);
|
||||
}
|
||||
|
||||
target.appendChild(overlay.$el);
|
||||
Object.assign(overlay, defaultConfig, config, {
|
||||
visible: true
|
||||
});
|
||||
} else {
|
||||
overlay.visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
export function openOverlay(vm: any, config: OverlayConfig): void {
|
||||
/* istanbul ignore next */
|
||||
if (!context.stack.some(item => item.vm === vm)) {
|
||||
const el = vm.$el;
|
||||
const target = el && el.parentNode ? el.parentNode : document.body;
|
||||
context.stack.push({ vm, config, target });
|
||||
context.stack.push({ vm, config });
|
||||
updateOverlay();
|
||||
}
|
||||
}
|
||||
|
@ -60,9 +60,11 @@ function Toast(options = {}) {
|
||||
clearTimeout(toast.timer);
|
||||
queue = queue.filter(item => item !== toast);
|
||||
|
||||
if (document.body.contains(toast.$el)) {
|
||||
document.body.removeChild(toast.$el);
|
||||
const parent = toast.$el.parentNode;
|
||||
if (parent) {
|
||||
parent.removeChild(toast.$el);
|
||||
}
|
||||
|
||||
toast.$destroy();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user