Skip to content

Commit

Permalink
update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Irina-anat committed May 3, 2023
1 parent f9c4ee8 commit 5ef1a8f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,28 +63,28 @@ async function onSearch(evn) {
};


function onLoadMore(entries, observer) {
function onLoadMore(entries, observer) {

try {
entries.forEach(async (entry) => {
entries.forEach(async function (entry) {

if (entry.isIntersecting) {
currentPage += 1;
const data = await getImages(searchQuery, currentPage);
// console.log(data)
let totalPages = Math.ceil(data.totalHits/perPage)
// console.log(data)
let totalPages = Math.ceil(data.totalHits / perPage);
gallery.insertAdjacentHTML('beforeend', createMarcup(data.hits));
if (totalPages === currentPage) {
Notify.failure("We're sorry, but you've reached the end of search results.");
observer.unobserve(guard)
observer.unobserve(guard);
}
lightbox.refresh()
lightbox.refresh();
}
})
}
catch {
console.log('ERROR: ' + `error`)
clear()
clear();
}
};

Expand Down

0 comments on commit 5ef1a8f

Please sign in to comment.