astro-mail/public/assets/js/main.js

1 line
2.8 KiB
JavaScript
Executable File

!function () { "use strict"; let e = (e, t = !1) => (e = e.trim(), t) ? [...document.querySelectorAll(e)] : document.querySelector(e), t = (t, s, l, o = !1) => { let i = e(s, o); i && (o ? i.forEach(e => e.addEventListener(t, l)) : i.addEventListener(t, l)) }, s = (e, t) => { e.addEventListener("scroll", t) }, l = e("#navbar .scrollto", !0), o = () => { let t = window.scrollY + 200; l.forEach(s => { if (!s.hash) return; let l = e(s.hash); l && (t >= l.offsetTop && t <= l.offsetTop + l.offsetHeight ? s.classList.add("active") : s.classList.remove("active")) }) }; window.addEventListener("load", o), s(document, o); let i = t => { let s = e("#header"), l = s.offsetHeight; s.classList.contains("header-scrolled") || (l -= 16); let o = e(t).offsetTop; window.scrollTo({ top: o - l, behavior: "smooth" }) }, a = e("#header"); if (a) { let r = a.offsetTop, n = a.nextElementSibling, c = () => { r - window.scrollY <= 0 ? (a.classList.add("fixed-top"), n.classList.add("scrolled-offset")) : (a.classList.remove("fixed-top"), n.classList.remove("scrolled-offset")) }; window.addEventListener("load", c), s(document, c) } let f = e(".back-to-top"); if (f) { let d = () => { window.scrollY > 100 ? f.classList.add("active") : f.classList.remove("active") }; window.addEventListener("load", d), s(document, d) } t("click", ".mobile-nav-toggle", function (t) { e("#navbar").classList.toggle("navbar-mobile"), this.classList.toggle("bi-list"), this.classList.toggle("bi-x") }), t("click", ".navbar .dropdown > a", function (t) { e("#navbar").classList.contains("navbar-mobile") && (t.preventDefault(), this.nextElementSibling.classList.toggle("dropdown-active")) }, !0), t("click", ".scrollto", function (t) { if (e(this.hash)) { t.preventDefault(); let s = e("#navbar"); if (s.classList.contains("navbar-mobile")) { s.classList.remove("navbar-mobile"); let l = e(".mobile-nav-toggle"); l.classList.toggle("bi-list"), l.classList.toggle("bi-x") } i(this.hash) } }, !0), window.addEventListener("load", () => { window.location.hash && e(window.location.hash) && i(window.location.hash) }); let v = e("#preloader"); v && window.addEventListener("load", () => { v.remove() }); let h = e(".skills-content"); h && new Waypoint({ element: h, offset: "80%", handler: function (t) { e(".progress .progress-bar", !0).forEach(e => { e.style.width = e.getAttribute("aria-valuenow") + "%" }) } }), window.addEventListener("load", () => { let s = e(".portfolio-container"); if (s) { let l = new Isotope(s, { itemSelector: ".portfolio-item" }), o = e("#portfolio-flters li", !0); t("click", "#portfolio-flters li", function (e) { e.preventDefault(), o.forEach(function (e) { e.classList.remove("filter-active") }), this.classList.add("filter-active"), l.arrange({ filter: this.getAttribute("data-filter") }), l.on("arrangeComplete", function () { AOS.refresh() }) }, !0) } }) }();