Pass through mouse clicks while dialog overlay is dismissing.

This commit is contained in:
flash 2024-04-21 19:49:03 +00:00
parent 185a745f26
commit 20fc663bcb

View file

@ -6,6 +6,9 @@ const MamiMessageBoxContainer = function() {
const container = <div class="msgbox-container"/>; const container = <div class="msgbox-container"/>;
return { return {
set pointerEvents(value) {
container.style.pointerEvents = value ? null : 'none';
},
getElement: () => container, getElement: () => container,
show: async dialog => { show: async dialog => {
if(typeof dialog !== 'object' || dialog === null) if(typeof dialog !== 'object' || dialog === null)
@ -37,6 +40,7 @@ const MamiMessageBoxDialog = function(info) {
{ name: 'cancel', text: 'Cancel', reject: true }, { name: 'cancel', text: 'Cancel', reject: true },
]; ];
const dialog = <form class="msgbox-dialog"/>;
let showResolve, showReject; let showResolve, showReject;
const doResolve = (...args) => { const doResolve = (...args) => {
@ -44,6 +48,7 @@ const MamiMessageBoxDialog = function(info) {
return; return;
showReject = undefined; showReject = undefined;
dialog.style.pointerEvents = 'none';
showResolve(...args); showResolve(...args);
}; };
const doReject = (...args) => { const doReject = (...args) => {
@ -51,11 +56,10 @@ const MamiMessageBoxDialog = function(info) {
return; return;
showResolve = undefined; showResolve = undefined;
dialog.style.pointerEvents = 'none';
showReject(...args); showReject(...args);
}; };
const dialog = <form class="msgbox-dialog"/>;
const body = <div class="msgbox-dialog-body"/>; const body = <div class="msgbox-dialog-body"/>;
dialog.appendChild(body); dialog.appendChild(body);
@ -177,6 +181,8 @@ const MamiMessageBoxDialog = function(info) {
}); });
}, },
dismiss: async () => { dismiss: async () => {
dialog.style.pointerEvents = 'none';
await MamiAnimate({ await MamiAnimate({
async: true, async: true,
duration: 600, duration: 600,
@ -231,6 +237,8 @@ const MamiMessageBoxControl = function(options) {
}; };
const raise = async () => { const raise = async () => {
container.pointerEvents = true;
if(!views.isCurrent(container)) if(!views.isCurrent(container))
views.raise(container, ctx => MamiAnimate({ views.raise(container, ctx => MamiAnimate({
async: true, async: true,