window.addEventListener('DOMContentLoaded', function () { const loading = document.querySelector('.loading'); const body = document.body; const video = document.querySelector('.loading-bg-video'); if (!loading || !video) return; const hasVisited = sessionStorage.getItem('hasVisited'); if (hasVisited) { loading.style.display = 'none'; body.style.overflow = 'auto'; return; } const startLoadingAnim = () => { if (!loading.classList.contains('show')) { loading.classList.add('show'); sessionStorage.setItem('hasVisited', 'true'); setTimeout(function () { loading.classList.add('fade-out'); }, 6000); } }; if (video.readyState >= 3) { startLoadingAnim(); } else { video.addEventListener('canplaythrough', startLoadingAnim, { once: true }); } loading.addEventListener('transitionend', function (event) { if (event.propertyName === 'opacity' && loading.classList.contains('fade-out')) { loading.style.display = 'none'; body.style.overflow = 'auto'; } }); setTimeout(startLoadingAnim, 3000); });