-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Открывается и закрывается (часть 2) #9
Conversation
js/comments-viewer.js
Outdated
currentCommentsLoaded++; | ||
updateCommentCounters(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Удали функцию и применяй вместо нее одну строку с classList.toggle
Подробнее можешь почитать в статье https://gomakethings.com/the-mysterious-second-argument-on-the-vanilla-js-classlist.toggle-method/
js/comments-viewer.js
Outdated
socialCommentsElement.appendChild(newCommentElement); | ||
} | ||
|
||
function updateCommentCounters() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Удали функцию и вынеси две строчки внутрь addCommentAndUpdateCounter
js/comments-viewer.js
Outdated
updateLoadCommentsButtonVisibility(); | ||
} | ||
|
||
function addComment(comment) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function addComment({avatar, name, commentsList}) {
js/comments-viewer.js
Outdated
const currentCommentsCountElement = bigPictureElement.querySelector('.social__comment-shown-count'); | ||
const totalCommentsCountElement = bigPictureElement.querySelector('.social__comment-total-count'); | ||
const loadCommentsButtonElement = bigPictureElement.querySelector('.social__comments-loader'); | ||
const loadingStep = 5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Оформи как константу плиз
const totalCommentsCountElement = bigPictureElement.querySelector('.social__comment-total-count'); | ||
const loadCommentsButtonElement = bigPictureElement.querySelector('.social__comments-loader'); | ||
const loadingStep = 5; | ||
let commentsArray = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
У массива не let, а const
js/comments-viewer.js
Outdated
loadCommentsButtonElement.classList.toggle('hidden', currentCommentsLoaded >= totalComments); | ||
} | ||
|
||
function addComment({avatar, name, commentsList}) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addComment можно вообще вынести в отдельный файл и обозвать например renderComment
🎓 Открывается и закрывается (часть 2)