Advertisement
Igor150195

Untitled

Apr 18th, 2024
794
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. window.addEventListener('DOMContentLoaded', function () {
  2.     let timeout;
  3.  
  4.     function setEqualHeight() {
  5.         let items = document.querySelectorAll('.review-item');
  6.         let maxHeight = Math.max(...Array.from(items, item => {
  7.             item.style.height = '';
  8.             return item.offsetHeight;
  9.         }));
  10.         items.forEach(item => item.style.height = `${maxHeight}px`);
  11.     };
  12.  
  13.     document.fonts.ready
  14.         .then(() => {
  15.             setTimeout(function () {
  16.                 setEqualHeight();
  17.             }, 100)
  18.         })
  19.         .catch(() => {
  20.             console.log("Fonts loading error");
  21.         });
  22.  
  23.     window.addEventListener('resize', ()=> {
  24.         if (timeout) {
  25.             clearInterval(timeout);
  26.         };
  27.  
  28.         timeout = setTimeout(() => {
  29.             setEqualHeight();
  30.         }, 50);
  31.     });
  32. });
  33.  
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement