mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-06-22 22:23:49 +08:00
fix(modal): 修复模态框滚动和点击事件处理
为多个模态框组件添加滚动和点击事件处理,防止背景滚动时内容滚动 当点击模态框背景时关闭模态框,同时阻止事件冒泡到内容区域
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
v-bind="attrs"
|
||||
class="fixed inset-0 z-50 flex items-center justify-center overflow-hidden bg-slate-900/70 p-4"
|
||||
@click.self="closeModal"
|
||||
@wheel="onOverlayWheel"
|
||||
>
|
||||
<div
|
||||
class="modal-panel relative w-full max-w-5xl max-h-[85vh] overflow-y-auto overscroll-contain scrollbar-nowidth rounded-3xl border border-white/10 bg-white/95 px-6 pb-6 shadow-2xl dark:border-slate-800 dark:bg-slate-900"
|
||||
@@ -629,4 +630,10 @@ const openPreview = (index: number) => {
|
||||
const hideImage = (e: Event) => {
|
||||
(e.target as HTMLElement).style.display = "none";
|
||||
};
|
||||
|
||||
const onOverlayWheel = (e: WheelEvent) => {
|
||||
const target = e.target as HTMLElement;
|
||||
if (target.closest(".overflow-y-auto, .overflow-auto")) return;
|
||||
e.preventDefault();
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user