templates/website/parts/loading.html.twig line 1

  1. <div class="loader-container" id="loading" >
  2.     <img id="randomImage" width="100%" src="" alt="hero">
  3. </div>
  4. <script>
  5.     const images = [
  6.         { url: '/static_images/loader/ana.gif', img: '/static_images/loader/ana.png', class: 'color-lilac'},
  7.         { url: '/static_images/loader/luys.gif', img: '/static_images/loader/luys.png', class: 'color-orange'},
  8.         { url: '/static_images/loader/nunj.gif', img: '/static_images/loader/nunj.png', class: 'color-blue'},
  9.         { url: '/static_images/loader/pinchu.gif', img: '/static_images/loader/pinchu.png', class: 'color-green'},
  10.         { url: '/static_images/loader/zor.gif', img: '/static_images/loader/zor.png', class: 'color-red'},
  11.         { url: '/static_images/loader/yan.gif', img: '/static_images/loader/yan.png', class: 'color-purple' }
  12.     ];
  13.     function showRandomImage() {
  14.         const randomIndex = Math.floor(Math.random() * images.length);
  15.         const randomImage = images[randomIndex];
  16.         const randomClass = images[randomIndex];
  17.         document.body.classList.add(randomClass.class);
  18.         document.getElementById('randomImage').src = randomImage.url;
  19.         document.querySelectorAll('#hero-random-img').forEach((item)=>{
  20.             item.src = randomImage.img;
  21.         });
  22.         // document.getElementById('loading').style.display = 'flex';
  23.     }
  24.     // function hideLoader() {
  25.     //     document.getElementById('loading').style.display = 'none';
  26.     // }
  27.     if (document.readyState === 'complete') {
  28.         // hideLoader();
  29.     } else {
  30.         showRandomImage();
  31.         // window.onload = function () {
  32.         //     hideLoader();
  33.         // };
  34.     }
  35. </script>