-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.min.js
1 lines (1 loc) · 1.64 KB
/
script.min.js
1
function menu() { const e = document.querySelector(".js-menu-mobile"), n = document.querySelector(".js-nav-mobile"); e.addEventListener("click", function () { n.classList.toggle("ativo"), e.classList.toggle("ativo") }) } function slider() { const e = document.querySelector(".js-btn-anterior"), n = document.querySelector(".js-btn-proximo"), t = document.querySelector(".js-scroll-animais"); e.addEventListener("click", function () { const e = document.querySelectorAll(".js-card"); e[e.length - 1].classList.add("anima-previous"), t.insertBefore(e[e.length - 1], t.firstChild), setTimeout(() => { e.forEach(e => { e.classList.remove("anima-previous") }) }, 1e3) }), n.addEventListener("click", function () { const e = document.querySelectorAll(".js-card"); e[0].classList.add("anima-next"), setTimeout(() => { t.appendChild(e[0]), e.forEach(e => { e.classList.remove("anima-next") }) }, 1e3) }) } function scrollAnimation() { const e = document.querySelectorAll(".js-scroll"); var n = .7 * window.innerHeight; function t() { e.forEach(e => { e.getBoundingClientRect().top - n < 0 && e.classList.add("anima-scroll") }) } t(), window.addEventListener("scroll", t) } function numeroScroll() { const e = document.querySelectorAll(".js-numero"), n = document.querySelector(".numeros"); var t = .7 * window.innerHeight; n.getBoundingClientRect().top - t < 0 && (e.forEach(e => { var n = +e.innerText, t = Math.floor(n / 20); let o = 0; const r = setInterval(() => { o += t, e.innerText = o, o > n && (e.innerText = n, clearInterval(r)) }, 50) }), window.removeEventListener("scroll", numeroScroll)) } menu(), slider(), scrollAnimation(), window.addEventListener("scroll", numeroScroll);