Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
sidlicki committed Sep 16, 2023
1 parent 5166b21 commit f691de7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Homework 11</title>
<link rel="stylesheet" href="./sass/_common.scss">
<link rel="stylesheet" href="./sass/index.scss" />
<script type="module" src="./index.js"></script>
</head>

<body>
Expand All @@ -24,7 +25,6 @@ <h2 class="start-text">Напишіть свій перший запит для
<!-- <button type="button" class="load-more">Load more</button> -->
<div class="js-guard"></div>
</main>
<script src="index.js" type="module"></script>
</body>

</html>
9 changes: 9 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const target = document.querySelector('.js-guard'); // Цільовий елем
const observer = new IntersectionObserver(onLoad, options); // Створення обсервера

Notiflix.Notify.init({
timeout: 5000,
fontSize: '20px',
width: '350px',
position: 'right-top',
Expand Down Expand Up @@ -51,6 +52,14 @@ async function getAndCreateMarkup(val, page = 1) {
const {
data: { hits, totalHits },
} = await getImages(val, page);
if (totalHits === 0) {
Notiflix.Notify.failure(
`Нажаль за вашим запитом "${val}" не знайшлося жодного зоображення, спробуйте ще раз`
);
gallery.innerHTML =
'<h2 class="start-text">Напишіть свій запит ще раз для пошуку зоображень</h2>';
return;
}
gallery.innerHTML = createMarkup(hits); // Додати зображення до галереї
lightbox.refresh(); // оновлення галереї
observer.observe(target); // Почати спостереження
Expand Down
2 changes: 1 addition & 1 deletion src/sass/index.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@import './common';
@import './example';
@import './example';

0 comments on commit f691de7

Please sign in to comment.