-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
58 lines (51 loc) · 2.24 KB
/
Copy pathscript.js
File metadata and controls
58 lines (51 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
(function () {
"use strict";
var body = document.body;
var toggle = document.querySelector("[data-nav-toggle]");
var nav = document.querySelector("[data-nav]");
var progress = document.querySelector(".scroll-progress span");
var years = document.querySelectorAll("[data-year]");
var reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
for (var y = 0; y < years.length; y += 1) {
years[y].textContent = String(new Date().getFullYear());
}
function closeNavigation() {
body.classList.remove("nav-open");
if (toggle) toggle.setAttribute("aria-expanded", "false");
}
if (toggle && nav) {
toggle.addEventListener("click", function () {
var open = body.classList.toggle("nav-open");
toggle.setAttribute("aria-expanded", String(open));
});
var links = nav.querySelectorAll("a");
for (var i = 0; i < links.length; i += 1) links[i].addEventListener("click", closeNavigation);
document.addEventListener("keydown", function (event) {
if (event.key === "Escape") closeNavigation();
});
}
function updateProgress() {
if (!progress) return;
var max = document.documentElement.scrollHeight - window.innerHeight;
var value = max > 0 ? Math.min(100, Math.max(0, (window.scrollY / max) * 100)) : 0;
progress.style.width = value + "%";
}
updateProgress();
window.addEventListener("scroll", updateProgress, { passive: true });
window.addEventListener("resize", updateProgress);
var revealItems = document.querySelectorAll(".reveal");
if (!reduceMotion && "IntersectionObserver" in window && revealItems.length) {
document.documentElement.classList.add("reveal-ready");
var observer = new IntersectionObserver(function (entries) {
for (var j = 0; j < entries.length; j += 1) {
if (entries[j].isIntersecting) {
entries[j].target.classList.add("is-visible");
observer.unobserve(entries[j].target);
}
}
}, { rootMargin: "0px 0px -6% 0px", threshold: 0.08 });
for (var k = 0; k < revealItems.length; k += 1) observer.observe(revealItems[k]);
}
var printButton = document.querySelector("[data-print-resume]");
if (printButton) printButton.addEventListener("click", function () { window.print(); });
})();