Skip to content

Commit

Permalink
fix #536
Browse files Browse the repository at this point in the history
  • Loading branch information
dimdenGD committed Sep 15, 2023
1 parent 6995058 commit 16a596f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion scripts/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,15 @@ function createModal(html, className, onclose, canclose) {
}
}
close.addEventListener('click', removeModal);
let isHoldingMouseFromContent = false;
modal_content.addEventListener('mousedown', () => {
isHoldingMouseFromContent = true;
});
document.addEventListener('mouseup', () => {
setTimeout(() => isHoldingMouseFromContent = false, 10);
});
modal.addEventListener('click', e => {
if(e.target === modal) {
if(e.target === modal && !isHoldingMouseFromContent) {
if(!canclose || canclose()) removeModal();
}
});
Expand Down

0 comments on commit 16a596f

Please sign in to comment.