Skip to content

Commit

Permalink
Merge pull request #83 from TetiZ/Close-card-foo's
Browse files Browse the repository at this point in the history
Close card foo's
  • Loading branch information
TetiZ authored Jan 31, 2024
2 parents 43912b9 + f597f79 commit 1a0ac35
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/js/exersises.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,19 +605,24 @@ function dataToStorage(data) {
}

// Close card foo's

const modalBackDrop = document.querySelector('.pop-backdrop.is-open');

async function closeWithBackDrop() {
await popUp(data);
modal.innerHTML = '';
modalBackDrop.classList.remove('is-open');
async function closeWithBackDrop(event) {
if (
event.target.classList.contains('pop-ex-close-btn') ||
event.key === 'Escape'
) {
await popUp(data);
modal.innerHTML = '';
modalBackDrop.classList.remove('is-open');
}
}

if (modalBackDrop) {
modalBackDrop.addEventListener('click', closeWithBackDrop);
}

document.addEventListener('keydown', closeWithBackDrop);
}
window.addEventListener('keydown', function (e) {
if (e.key === 'Escape') {
modal.innerHTML = '';
Expand Down

0 comments on commit 1a0ac35

Please sign in to comment.