Skip to content

Commit

Permalink
add hide-modal function
Browse files Browse the repository at this point in the history
  • Loading branch information
PavelUd committed Nov 18, 2023
1 parent df83351 commit 76cc8df
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions js/full-size-images.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const commentsCount = bigPicture.querySelector('.comments-count');
const likesCount = bigPicture.querySelector('.likes-count');
const bigImage = bigPicture.querySelector('.big-picture__img img');
const description = bigPicture.querySelector('.social__caption');
const cancelButton = bigPicture.querySelector('.big-picture__cancel');

const createComment = (avatar, name, text) => `<li class="social__comment">
<img
Expand All @@ -20,6 +21,18 @@ const createCommentsBlock = (comments) =>{
commentsBlock.insertAdjacentHTML('afterbegin', comments.map((comment) => createComment(comment.avatar, comment.name, comment.message)).join('')); // Array(comments).map
};

const hideModal = () => {
document.body.classList.remove('modal-open');
bigPicture.classList.add('hidden');
};

document.onkeydown = (evt) => {
if (evt.key === 'Escape') {
hideModal();
}
};

cancelButton.onclick = hideModal;

const constructBigPicture = (picture, photos) =>{
const likes = picture.querySelector('.picture__likes');
Expand Down

0 comments on commit 76cc8df

Please sign in to comment.