-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
187 lines (155 loc) · 6.64 KB
/
Copy pathscript.js
File metadata and controls
187 lines (155 loc) · 6.64 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
// Mobile Navigation Toggle
document.addEventListener('DOMContentLoaded', function() {
const navToggle = document.querySelector('.nav-toggle');
const navMenu = document.querySelector('.nav-menu');
const navLinks = document.querySelectorAll('.nav-link');
// Toggle mobile menu
navToggle.addEventListener('click', function() {
const isOpen = navMenu.classList.toggle('active');
navToggle.setAttribute('aria-expanded', isOpen ? 'true' : 'false');
// Animate hamburger menu
const bars = navToggle.querySelectorAll('.bar');
bars.forEach((bar, index) => {
if (isOpen) {
if (index === 0) bar.style.transform = 'rotate(-45deg) translate(-5px, 6px)';
if (index === 1) bar.style.opacity = '0';
if (index === 2) bar.style.transform = 'rotate(45deg) translate(-5px, -6px)';
} else {
bar.style.transform = '';
bar.style.opacity = '';
}
});
});
// Close mobile menu when clicking on links
navLinks.forEach(link => {
link.addEventListener('click', function() {
const wasOpen = navMenu.classList.contains('active');
navMenu.classList.remove('active');
if (wasOpen) {
navToggle.setAttribute('aria-expanded', 'false');
}
const bars = navToggle.querySelectorAll('.bar');
bars.forEach(bar => {
bar.style.transform = '';
bar.style.opacity = '';
});
});
});
// Smooth scrolling is handled by CSS scroll-behavior: smooth
// and scroll-margin-top on section targets; no JS override needed.
// Navbar background on scroll
window.addEventListener('scroll', function() {
const navbar = document.querySelector('.navbar');
if (window.scrollY > 50) {
navbar.style.background = 'rgba(255, 255, 255, 0.98)';
navbar.style.boxShadow = '0 2px 20px rgba(0, 0, 0, 0.1)';
} else {
navbar.style.background = 'rgba(255, 255, 255, 0.95)';
navbar.style.boxShadow = 'none';
}
});
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
// Animate elements on scroll
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver(function(entries) {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, observerOptions);
// Observe elements for animation (skip when reduced motion is preferred)
const animateElements = document.querySelectorAll('.feature-card, .team-member, .community-card, .arch-component, .try-stage-card, .try-stage-links');
if (!prefersReducedMotion) {
animateElements.forEach(el => {
el.style.opacity = '0';
el.style.transform = 'translateY(30px)';
el.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
observer.observe(el);
});
}
// Counter animation for stats
function animateCounter(element, target, duration = 2000) {
let start = 0;
const increment = target / (duration / 16);
function updateCounter() {
start += increment;
if (start < target) {
element.textContent = Math.floor(start);
requestAnimationFrame(updateCounter);
} else {
element.textContent = target;
}
}
updateCounter();
}
// Animate stats when they come into view
const statsObserver = new IntersectionObserver(function(entries) {
entries.forEach(entry => {
if (entry.isIntersecting) {
const statNumber = entry.target.querySelector('.stat-number');
const text = statNumber.textContent;
// Extract number from text like "60%" or "$100B+"
const number = parseInt(text.replace(/[^\d]/g, ''));
if (!isNaN(number) && number > 0) {
statNumber.textContent = '0' + text.replace(/\d+/, '');
animateCounter(statNumber, number);
// Add back the suffix after animation
setTimeout(() => {
statNumber.textContent = text;
}, 2000);
}
statsObserver.unobserve(entry.target);
}
});
}, { threshold: 0.5 });
document.querySelectorAll('.stat').forEach(stat => {
statsObserver.observe(stat);
});
// Blockchain animation enhancement
const blocks = document.querySelectorAll('.block');
blocks.forEach((block, index) => {
block.addEventListener('mouseenter', function() {
this.style.transform = 'scale(1.1) translateY(-5px)';
this.style.boxShadow = '0 15px 40px rgba(102, 126, 234, 0.4)';
});
block.addEventListener('mouseleave', function() {
this.style.transform = '';
this.style.boxShadow = '0 10px 30px rgba(102, 126, 234, 0.3)';
});
});
// Easter egg: Konami code
let konamiCode = [];
const konamiSequence = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65]; // Up Up Down Down Left Right Left Right B A
document.addEventListener('keydown', function(e) {
konamiCode.push(e.keyCode);
if (konamiCode.length > konamiSequence.length) {
konamiCode.shift();
}
if (JSON.stringify(konamiCode) === JSON.stringify(konamiSequence)) {
// Easter egg activated
document.body.style.filter = 'hue-rotate(180deg)';
setTimeout(() => {
document.body.style.filter = '';
}, 3000);
konamiCode = [];
}
});
// External links open in a new tab via target="_blank"; no destructive
// innerHTML spinner (it broke icon markup and flashed "Opening…").
// Add subtle parallax effect to hero section (skip when reduced motion is preferred)
if (!prefersReducedMotion) {
window.addEventListener('scroll', function() {
const scrolled = window.pageYOffset;
const heroVisual = document.querySelector('.hero-visual');
if (heroVisual && scrolled < window.innerHeight) {
heroVisual.style.transform = `translateY(${scrolled * 0.3}px)`;
}
});
}
console.log('Clutch Protocol website loaded.');
});