-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
78 lines (71 loc) · 3.18 KB
/
Copy pathscript.js
File metadata and controls
78 lines (71 loc) · 3.18 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
(function () {
"use strict";
var body = document.body;
var toggle = document.querySelector("[data-nav-toggle]");
var nav = document.querySelector("[data-nav]");
function closeNavigation() {
body.classList.remove("nav-open");
if (toggle) toggle.setAttribute("aria-expanded", "false");
if (toggle) {
var closeLabel = toggle.querySelector(".sr-only");
if (closeLabel) closeLabel.textContent = "Open navigation";
}
}
if (toggle && nav) {
toggle.addEventListener("click", function () {
var open = body.classList.toggle("nav-open");
toggle.setAttribute("aria-expanded", String(open));
var label = toggle.querySelector(".sr-only");
if (label) label.textContent = open ? "Close navigation" : "Open navigation";
});
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();
});
document.addEventListener("click", function (event) {
if (body.classList.contains("nav-open") && !event.target.closest(".nav-pill")) closeNavigation();
});
var desktopNav = window.matchMedia("(min-width: 861px)");
if (desktopNav.addEventListener) desktopNav.addEventListener("change", function (event) { if (event.matches) closeNavigation(); });
}
var reduceMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
var revealItems = document.querySelectorAll(".reveal");
function formatNumber(value) {
return String(Math.round(value)).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
function runCounter(el) {
var target = parseFloat(el.getAttribute("data-count"));
var prefix = el.getAttribute("data-prefix") || "";
var suffix = el.getAttribute("data-suffix") || "";
var duration = 1400;
var start = null;
function step(timestamp) {
if (start === null) start = timestamp;
var progress = Math.min(1, (timestamp - start) / duration);
var eased = 1 - Math.pow(1 - progress, 3);
el.textContent = prefix + formatNumber(target * eased) + suffix;
if (progress < 1) window.requestAnimationFrame(step);
}
window.requestAnimationFrame(step);
}
if (!reduceMotion && "IntersectionObserver" in window) {
document.documentElement.classList.add("motion-ok");
var seenCounters = new WeakSet();
var observer = new IntersectionObserver(function (entries) {
for (var j = 0; j < entries.length; j += 1) {
if (!entries[j].isIntersecting) continue;
var el = entries[j].target;
el.classList.add("is-visible");
var nums = el.querySelectorAll("[data-count]");
for (var n = 0; n < nums.length; n += 1) {
if (!seenCounters.has(nums[n])) { seenCounters.add(nums[n]); runCounter(nums[n]); }
}
observer.unobserve(el);
}
}, { rootMargin: "0px 0px -8% 0px", threshold: 0.15 });
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(); });
})();