diff --git a/src/index.js b/src/index.js index ce22c5f..b63f690 100755 --- a/src/index.js +++ b/src/index.js @@ -3,7 +3,8 @@ import { Notify } from 'notiflix/build/notiflix-notify-aio'; import SimpleLightbox from "simplelightbox"; import "simplelightbox/dist/simple-lightbox.min.css"; import { getImages } from "./js/getImages"; -import {createMarcup} from "./js/createMarcup" +import { createMarcup } from "./js/createMarcup"; +import { scroll } from "./js/scroll"; const form = document.querySelector('.search-form'); const gallery = document.querySelector(`.gallery`); @@ -70,6 +71,7 @@ async function onSearch(evn) { if (entry.isIntersecting) { currentPage += 1; + scroll() const data = await getImages(searchQuery, currentPage); // console.log(data) let totalPages = Math.ceil(data.totalHits / perPage); @@ -106,7 +108,6 @@ function resetSlider() { - /*function scroll() { const { height: cardHeight } = document .querySelector('.gallery') diff --git a/src/js/scroll.js b/src/js/scroll.js new file mode 100644 index 0000000..b94f07f --- /dev/null +++ b/src/js/scroll.js @@ -0,0 +1,10 @@ +function scroll() { +const { height: cardHeight } = document.querySelector(".gallery").firstElementChild.getBoundingClientRect(); +window.scrollBy({ +top: cardHeight * 2, +behavior: "smooth", +}) +}; + +export {scroll} + \ No newline at end of file