Skip to content

Commit

Permalink
Close card foo's
Browse files Browse the repository at this point in the history
  • Loading branch information
Petro-Gunko committed Jan 31, 2024
1 parent 450a5e1 commit f597f79
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 f597f79

Please sign in to comment.