(Created page with "function scrollCheckIfFadeIn(el, num){ return ()=>{ if (el.getBoundingClientRect().top > window.innerHeight) return; if (el.classList.contains("animation__...") |
m |
||
Line 4: | Line 4: | ||
if (el.classList.contains("animation__fadein_visible")) return; | if (el.classList.contains("animation__fadein_visible")) return; | ||
el.classList.add("animation__fadein_visible"); | el.classList.add("animation__fadein_visible"); | ||
− | el.classList.add(("animation__fadein_visible" + num)); | + | el.classList.add("animation__fadein_visible" + num); |
+ | |||
+ | setTimeout(()=>{ | ||
+ | el.classList.remove("animation__fadein_hidden"); | ||
+ | el.classList.remove("animation__fadein_visible" + num); | ||
+ | }, 1460); | ||
}; | }; | ||
} | } | ||
Line 17: | Line 22: | ||
el.classList.add("animation__fadein_hidden"); | el.classList.add("animation__fadein_hidden"); | ||
window.addEventListener("scroll", scrollCheckIfFadeIn(el, num)); | window.addEventListener("scroll", scrollCheckIfFadeIn(el, num)); | ||
+ | setTimeout(scrollCheckIfFadeIn(el, num), 100); | ||
if (count) num++; | if (count) num++; | ||
if (num > 9) num = 1; | if (num > 9) num = 1; |
Latest revision as of 10:43, 26 September 2020
function scrollCheckIfFadeIn(el, num){
return ()=>{ if (el.getBoundingClientRect().top > window.innerHeight) return; if (el.classList.contains("animation__fadein_visible")) return; el.classList.add("animation__fadein_visible"); el.classList.add("animation__fadein_visible" + num);
setTimeout(()=>{ el.classList.remove("animation__fadein_hidden"); el.classList.remove("animation__fadein_visible" + num); }, 1460); };
}
function scrollFadeIn(arrayOfElementIds, count = false){
let num = 1; arrayOfElementIds.forEach(el => { if (Array.isArray(el)){ scrollFadeIn(el, true); return; } el.classList.add("animation__fadein_hidden"); window.addEventListener("scroll", scrollCheckIfFadeIn(el, num)); setTimeout(scrollCheckIfFadeIn(el, num), 100); if (count) num++; if (num > 9) num = 1; });
}