diff --git a/js/ui.js b/js/ui.js index 173f80c..a07608b 100644 --- a/js/ui.js +++ b/js/ui.js @@ -4,7 +4,7 @@ let homeRE = new RegExp(/(https?:\S+\/$|index.html$)/); if (homeRE.test(window.location.href)) { - window.addEventListener('load', () => { + document.addEventListener('readystatechange', () => { let nextimage = 0; let header = document.querySelector('header'); slider(); @@ -27,7 +27,7 @@ if (homeRE.test(window.location.href)) { 'img/fara_bg_11.jpg', ]; - if (nextimage >= images.length) { + if (nextimage >= images.length) { nextimage = 0; } header.setAttribute('style', 'background-image : url("' + images[nextimage++] + '");'); @@ -76,11 +76,10 @@ window.addEventListener('scroll', event => { nav.classList.remove('bg-white', 'border'); } }); - -window.addEventListener('load', () => { - /** - * Show horizontal nav on mobile - */ +/** +* Show horizontal nav on mobile +*/ +document.addEventListener('readystatechange', () => { let menu = document.querySelector('i'); menu.addEventListener('click', () => { @@ -123,7 +122,6 @@ window.addEventListener('load', () => { a.addEventListener('click', () => { aNodes.forEach(n => { - if (n.src) { let vStr = n.src .substr(n.src.lastIndexOf('/')+1, n.src.length) @@ -153,7 +151,5 @@ window.addEventListener('load', () => { overlay.addEventListener('click', () => { modal.classList.remove('active'); }) - } - }); \ No newline at end of file