-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
173 lines (148 loc) · 5.4 KB
/
script.js
File metadata and controls
173 lines (148 loc) · 5.4 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
// Minimalist JavaScript for cyreslab.ai
document.addEventListener('DOMContentLoaded', function() {
// Initialize smooth animations
initScrollAnimations();
// Initialize navigation behavior
initNavigation();
// Initialize subtle interactions
initInteractions();
});
// Scroll-triggered animations
function initScrollAnimations() {
// Only run if user prefers motion
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
return;
}
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
}
});
}, observerOptions);
// Observe elements for animation
const animatedElements = document.querySelectorAll('.pillar, .about-text, .contact-content');
animatedElements.forEach(el => observer.observe(el));
}
// Navigation behavior
function initNavigation() {
const nav = document.querySelector('.nav');
let lastScrollY = window.scrollY;
// Add scroll effect to navigation
window.addEventListener('scroll', () => {
const currentScrollY = window.scrollY;
// Add/remove nav background based on scroll position
if (currentScrollY > 50) {
nav.style.backgroundColor = 'rgba(250, 250, 250, 0.98)';
nav.style.boxShadow = '0 2px 20px rgba(0, 0, 0, 0.1)';
} else {
nav.style.backgroundColor = 'rgba(250, 250, 250, 0.95)';
nav.style.boxShadow = 'none';
}
lastScrollY = currentScrollY;
});
// Smooth scroll for navigation links
const navLinks = document.querySelectorAll('.nav-links a[href^="#"]');
navLinks.forEach(link => {
link.addEventListener('click', (e) => {
e.preventDefault();
const targetId = link.getAttribute('href').substring(1);
const targetElement = document.getElementById(targetId);
if (targetElement) {
const navHeight = nav.offsetHeight;
const targetPosition = targetElement.offsetTop - navHeight - 20;
window.scrollTo({
top: targetPosition,
behavior: 'smooth'
});
}
});
});
}
// Subtle interactions
function initInteractions() {
// Logo hover effect
const logoMain = document.querySelector('.logo-main');
if (logoMain) {
logoMain.addEventListener('mouseenter', () => {
logoMain.style.transform = 'scale(1.05) rotate(2deg)';
});
logoMain.addEventListener('mouseleave', () => {
logoMain.style.transform = 'scale(1) rotate(0deg)';
});
}
// Contact link subtle animation
const contactLink = document.querySelector('.contact-link');
if (contactLink) {
contactLink.addEventListener('mouseenter', () => {
const icon = contactLink.querySelector('.contact-icon svg');
if (icon) {
icon.style.transform = 'translateX(5px)';
icon.style.transition = 'transform 0.3s ease';
}
});
contactLink.addEventListener('mouseleave', () => {
const icon = contactLink.querySelector('.contact-icon svg');
if (icon) {
icon.style.transform = 'translateX(0)';
}
});
}
// Pillar hover enhancements
const pillars = document.querySelectorAll('.pillar');
pillars.forEach(pillar => {
pillar.addEventListener('mouseenter', () => {
const icon = pillar.querySelector('.pillar-icon svg');
if (icon) {
icon.style.transform = 'scale(1.1)';
icon.style.transition = 'transform 0.3s ease';
}
});
pillar.addEventListener('mouseleave', () => {
const icon = pillar.querySelector('.pillar-icon svg');
if (icon) {
icon.style.transform = 'scale(1)';
}
});
});
}
// Scroll indicator interaction
document.addEventListener('DOMContentLoaded', function() {
const scrollIndicator = document.querySelector('.scroll-indicator');
if (scrollIndicator) {
scrollIndicator.addEventListener('click', () => {
const pillarsSection = document.querySelector('.pillars');
if (pillarsSection) {
const navHeight = document.querySelector('.nav').offsetHeight;
const targetPosition = pillarsSection.offsetTop - navHeight;
window.scrollTo({
top: targetPosition,
behavior: 'smooth'
});
}
});
// Add cursor pointer to indicate it's clickable
scrollIndicator.style.cursor = 'pointer';
}
});
// Performance optimization: throttle scroll events
function throttle(func, limit) {
let inThrottle;
return function() {
const args = arguments;
const context = this;
if (!inThrottle) {
func.apply(context, args);
inThrottle = true;
setTimeout(() => inThrottle = false, limit);
}
}
}
// Apply throttling to scroll events for better performance
window.addEventListener('scroll', throttle(() => {
// Any scroll-based animations can be added here if needed
}, 16)); // ~60fps