Igor150195

lazyload

Dec 8th, 2025
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2.  
  3. (function(){
  4.         const pagination = document.querySelector('.collection__pagination');
  5.  
  6.     if (!pagination) return;
  7.  
  8.     // Создаем наблюдателя
  9.     const observer = new IntersectionObserver((entries) => {
  10.         entries.forEach(entry => {
  11.             if (entry.isIntersecting) {
  12.                 // Находим кнопку внутри блока
  13.                 const loadButton = pagination.querySelector('.collection__pagination-button-load');
  14.                 if (loadButton) {
  15.                     loadButton.click();
  16.                 }
  17.             }
  18.         });
  19.     }, {
  20.         root: null, // viewport
  21.         threshold: 0.1 // срабатывает, когда хотя бы 10% блока видны
  22.     });
  23.  
  24.     observer.observe(pagination);
  25. })();
  26.  
  27. </script>
Advertisement
Add Comment
Please, Sign In to add comment