Skip to content

Commit

Permalink
remove eventListener
Browse files Browse the repository at this point in the history
  • Loading branch information
OlenaIa committed Jun 20, 2023
1 parent e94e192 commit 45921d2
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ function onClickLoadMore() {
if (page === numberOfPage) {
btnLoadMore.classList.add('is-hidden');
Notify.info("We're sorry, but you've reached the end of search results.", paramsForNotify);
btnLoadMore.removeEventListener('click', onClickLoadMore);
window.removeEventListener('scroll', showLoadMorePage);
};
lightbox.refresh();
// scrollPage();
Expand All @@ -96,14 +98,13 @@ function onFetchError() {
// };

function showLoadMorePage() {
if (checkIfEndOfPage()) {
onClickLoadMore();
}
if (checkIfEndOfPage()) {
onClickLoadMore();
};
};

function checkIfEndOfPage() {
return (
window.innerHeight + window.scrollY >=
document.documentElement.scrollHeight
window.innerHeight + window.scrollY >= document.documentElement.scrollHeight
);
}

0 comments on commit 45921d2

Please sign in to comment.