Skip to content

Commit

Permalink
Merge pull request #61 from GeorgiySergeev/test
Browse files Browse the repository at this point in the history
fixed scroll when modal window is open
  • Loading branch information
GeorgiySergeev committed May 24, 2023
2 parents 4e3ceb5 + 8b25c3f commit 3547770
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/js/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var modalButtons = document.querySelectorAll('.js-open-modal'),

modalElem.classList.add('active');
overlay.classList.add('active');
document.body.style.overflow = 'hidden';
});

});
Expand All @@ -27,6 +28,7 @@ var modalButtons = document.querySelectorAll('.js-open-modal'),

parentModal.classList.remove('active');
overlay.classList.remove('active');
document.body.style.overflow = 'auto';
});

}); // end foreach
Expand All @@ -39,13 +41,15 @@ var modalButtons = document.querySelectorAll('.js-open-modal'),

document.querySelector('.modal.active').classList.remove('active');
document.querySelector('.overlay').classList.remove('active');
document.body.style.overflow = 'auto';
};
}, false);


overlay.addEventListener('click', function() {
document.querySelector('.modal.active').classList.remove('active');
this.classList.remove('active');
document.body.style.overflow = 'auto';
});

// (() => {
Expand Down
2 changes: 2 additions & 0 deletions src/js/thanks-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ const closeBtns = document.querySelectorAll('.close-btn');
const openSuccessModal = () => {
backdrop.classList.add(MODAL_ACTIVE_CLASS_NAME);
thankModal.classList.add(MODAL_ACTIVE_CLASS_NAME);
document.body.style.overflow = 'hidden';
};
const closeSuccessModal = () => {
thankModal.classList.remove(MODAL_ACTIVE_CLASS_NAME);
backdrop.classList.remove(MODAL_ACTIVE_CLASS_NAME);
document.body.style.overflow = 'auto';
};
closeBtns.forEach(btn => {
btn.addEventListener('click', e => {
Expand Down
15 changes: 9 additions & 6 deletions src/partials/order-mod.html
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ <h3 class="order-item-name">Fruits Basket</h3>
placeholder="Enter full name..."
/>

<label class="contact-label visually-hidden" for="user-email">Email</label>
<label class="contact-label visually-hidden" for="user-email"
>Email</label
>
<input
class="input-modal-field"
type="email"
Expand All @@ -256,13 +258,14 @@ <h3 class="order-item-name">Fruits Basket</h3>
placeholder="Enter email..."
/>

<label class="contact-label visually-hidden" for="card-nomber">Card nomber</label>
<label class="contact-label visually-hidden" for="card-nomber"
>Card number</label
>
<input
class="input-modal-field"
type="number"
step="1"
min="5"
max="9999999999999999"
type="text"
pattern="^[0-9]{5,45}$"
title="Your card number must be between 5 to 45 digitals."
required
name="card-nomber"
id="card-nomber"
Expand Down

0 comments on commit 3547770

Please sign in to comment.