Skip to content

Commit

Permalink
+scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
Irina-anat committed May 3, 2023
1 parent 7e95ef8 commit e5eac29
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -106,7 +108,6 @@ function resetSlider() {




/*function scroll() {
const { height: cardHeight } = document
.querySelector('.gallery')
Expand Down
10 changes: 10 additions & 0 deletions src/js/scroll.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function scroll() {
const { height: cardHeight } = document.querySelector(".gallery").firstElementChild.getBoundingClientRect();
window.scrollBy({
top: cardHeight * 2,
behavior: "smooth",
})
};

export {scroll}

0 comments on commit e5eac29

Please sign in to comment.