Skip to content

Commit f97d4ec

Browse files
committed
refactor(full-size): make big picture handlers lint-friendly
1 parent 79f7dff commit f97d4ec

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

js/full-size-picture.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,23 @@ const likesCountNode = bigPictureNode.querySelector('.likes-count');
77
const commentsCaptionNode = bigPictureNode.querySelector('.social__caption');
88
const bigPictureCancelNode = bigPictureNode.querySelector('.big-picture__cancel');
99

10+
const onEscKeydown = (evt) => {
11+
if (evt.key === 'Escape') {
12+
evt.preventDefault();
13+
clearComments();
14+
bigPictureNode.classList.add('hidden');
15+
document.body.classList.remove('modal-open');
16+
document.removeEventListener('keydown', onEscKeydown);
17+
}
18+
};
19+
1020
const closeBigPicture = () => {
1121
clearComments();
1222
bigPictureNode.classList.add('hidden');
1323
document.body.classList.remove('modal-open');
1424
document.removeEventListener('keydown', onEscKeydown);
1525
};
1626

17-
const onEscKeydown = (evt) => {
18-
if (evt.key === 'Escape') {
19-
evt.preventDefault();
20-
closeBigPicture();
21-
}
22-
};
23-
2427
const onBigPictureCancelClick = (evt) => {
2528
evt.preventDefault();
2629
closeBigPicture();

0 commit comments

Comments
 (0)