-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
73 lines (63 loc) · 2.44 KB
/
Copy pathscript.js
File metadata and controls
73 lines (63 loc) · 2.44 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
// Stack Hack 2026 — small interactions
// FAQ accordion
document.querySelectorAll(".faq-trigger").forEach(function (btn) {
btn.addEventListener("click", function () {
var item = btn.closest(".faq-item");
item.classList.toggle("open");
});
});
// Scroll-reveal: fade + rise sections/cards into view as they enter the viewport
(function () {
var reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
// Tag content wrappers + cards for reveal (skip the hero so it shows immediately).
var targets = document.querySelectorAll(
"section:not(#home) > div, #about article, #prizes article, " +
"#sponsors .grid > div, #faq .faq-item, #contact a, footer > div"
);
if (reduce || !("IntersectionObserver" in window)) {
targets.forEach(function (el) { el.classList.add("reveal", "in"); });
return;
}
// Stagger siblings slightly for a cascading feel.
targets.forEach(function (el) {
el.classList.add("reveal");
var parent = el.parentElement;
var i = Array.prototype.indexOf.call(parent.children, el);
el.style.transitionDelay = Math.min(i, 6) * 70 + "ms";
});
var io = new IntersectionObserver(
function (entries) {
entries.forEach(function (entry) {
if (entry.isIntersecting) {
entry.target.classList.add("in");
io.unobserve(entry.target);
}
});
},
{ threshold: 0.12, rootMargin: "0px 0px -8% 0px" }
);
targets.forEach(function (el) { io.observe(el); });
})();
// Hero background shapes lean toward the cursor (parallax). Uses the
// `transform` property so it composes with the blobs' float (`translate`)
// and rotation (`rotate`).
(function () {
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
var hero = document.getElementById("home");
if (!hero) return;
var blobs = hero.querySelectorAll(".blob");
if (!blobs.length) return;
hero.addEventListener("mousemove", function (e) {
var r = hero.getBoundingClientRect();
var dx = (e.clientX - r.left) / r.width - 0.5; // -0.5 .. 0.5
var dy = (e.clientY - r.top) / r.height - 0.5;
blobs.forEach(function (b, i) {
var depth = ((i % 3) + 1) * 16; // nearer/farther shapes move differently
b.style.transform =
"translate(" + (dx * depth).toFixed(1) + "px," + (dy * depth).toFixed(1) + "px)";
});
});
hero.addEventListener("mouseleave", function () {
blobs.forEach(function (b) { b.style.transform = ""; });
});
})();