-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
130 lines (115 loc) · 4.18 KB
/
Copy pathscript.js
File metadata and controls
130 lines (115 loc) · 4.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// ─── LIGHTNING CANVAS ───
const canvas = document.getElementById('lightning-canvas');
if (canvas) {
const ctx = canvas.getContext('2d');
function resizeCanvas() {
canvas.width = canvas.offsetWidth;
canvas.height = canvas.offsetHeight;
}
resizeCanvas();
window.addEventListener('resize', resizeCanvas);
function lightning(x1, y1, x2, y2, roughness, depth) {
if (depth === 0) {
ctx.lineTo(x2, y2);
return;
}
const mx = (x1 + x2) / 2 + (Math.random() - 0.5) * roughness;
const my = (y1 + y2) / 2 + (Math.random() - 0.5) * roughness;
lightning(x1, y1, mx, my, roughness / 2, depth - 1);
lightning(mx, my, x2, y2, roughness / 2, depth - 1);
}
function drawBolt() {
const W = canvas.width, H = canvas.height;
const x1 = Math.random() * W;
const x2 = x1 + (Math.random() - 0.5) * 300;
ctx.beginPath();
ctx.moveTo(x1, 0);
lightning(x1, 0, x2, H * (0.3 + Math.random() * 0.5), 120, 7);
const alpha = 0.03 + Math.random() * 0.07;
ctx.strokeStyle = `rgba(245, 197, 24, ${alpha})`;
ctx.lineWidth = 0.8 + Math.random() * 0.8;
ctx.stroke();
if (Math.random() > 0.5) {
const bx = x1 + (Math.random() - 0.5) * 200;
ctx.beginPath();
ctx.moveTo(x2, H * 0.3);
lightning(x2, H * 0.3, bx, H * (0.5 + Math.random() * 0.3), 60, 5);
ctx.strokeStyle = `rgba(245, 197, 24, ${alpha * 0.5})`;
ctx.lineWidth = 0.4;
ctx.stroke();
}
}
let boltTimer = 0;
function animateLightning() {
ctx.fillStyle = 'rgba(10, 10, 10, 0.012)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
boltTimer++;
if (boltTimer % 40 === 0) {
drawBolt();
if (Math.random() > 0.6) drawBolt();
}
requestAnimationFrame(animateLightning);
}
animateLightning();
}
// ─── NAV SCROLL ───
const nav = document.getElementById('nav');
if (nav) {
window.addEventListener('scroll', () => {
if (window.scrollY > 80) {
nav.style.background = 'rgba(10,10,10,0.98)';
} else {
nav.style.background = 'rgba(10,10,10,0.92)';
}
});
}
// ─── HAMBURGER ───
const hamburger = document.getElementById('hamburger');
const mobileMenu = document.getElementById('mobile-menu');
if (hamburger && mobileMenu) {
hamburger.addEventListener('click', () => mobileMenu.classList.toggle('open'));
mobileMenu.querySelectorAll('a').forEach(a =>
a.addEventListener('click', () => mobileMenu.classList.remove('open'))
);
}
// ─── SMOOTH SCROLL WITH NAV OFFSET (for any in-page anchors) ───
document.querySelectorAll('a[href^="#"]').forEach(a => {
a.addEventListener('click', e => {
const href = a.getAttribute('href');
if (href === '#' || href.length < 2) return;
const target = document.querySelector(href);
if (!target) return;
e.preventDefault();
window.scrollTo({ top: target.getBoundingClientRect().top + window.scrollY - 64, behavior: 'smooth' });
});
});
// ─── LEADERBOARD TABS (placeholder) ───
document.querySelectorAll('.lb-tab').forEach(tab => {
tab.addEventListener('click', () => {
document.querySelectorAll('.lb-tab').forEach(t => t.classList.remove('active'));
tab.classList.add('active');
});
});
// ─── INTERSECTION FADE-IN ───
const observer = new IntersectionObserver(entries => {
entries.forEach(e => { if (e.isIntersecting) e.target.classList.add('visible'); });
}, { threshold: 0.06 });
document.querySelectorAll('.event-card, .equip-card, .class-card, .pillar, .score-row, .format-item').forEach(el => {
el.style.opacity = '0';
el.style.transform = 'translateY(16px)';
el.style.transition = 'opacity 0.4s ease, transform 0.4s ease';
observer.observe(el);
});
const fadeStyle = document.createElement('style');
fadeStyle.textContent = '.visible{opacity:1!important;transform:translateY(0)!important;}';
document.head.appendChild(fadeStyle);
// ─── ELECTRIC FLICKER on hero title ───
const titleKnife = document.querySelector('.title-knife');
if (titleKnife) {
setInterval(() => {
if (Math.random() > 0.96) {
titleKnife.style.textShadow = '0 0 20px rgba(245,197,24,0.6)';
setTimeout(() => { titleKnife.style.textShadow = 'none'; }, 80);
}
}, 200);
}