-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
169 lines (146 loc) · 7.58 KB
/
script.js
File metadata and controls
169 lines (146 loc) · 7.58 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
/**
* ═══════════════════════════════════════════════════════════════════════════════
* ZENCLORA OS
* Gentle particles, smooth animations, and cozy interactions
* ═══════════════════════════════════════════════════════════════════════════════
*/
document.addEventListener('DOMContentLoaded', () => {
initSmoothScroll();
initScrollAnimations();
initTerminalTyping();
initNavScrollEffect();
});
// ═══════════════════════════════════════════════════════════════════════════════
// SMOOTH SCROLLING
// ═══════════════════════════════════════════════════════════════════════════════
function initSmoothScroll() {
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
const headerOffset = 100;
const elementPosition = target.getBoundingClientRect().top;
const offsetPosition = elementPosition + window.pageYOffset - headerOffset;
window.scrollTo({
top: offsetPosition,
behavior: 'smooth'
});
}
});
});
}
// ═══════════════════════════════════════════════════════════════════════════════
// SCROLL ANIMATIONS
// ═══════════════════════════════════════════════════════════════════════════════
function initScrollAnimations() {
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('animate-in');
const children = entry.target.querySelectorAll('.feature-card, .news-card, .zenax-feature, .news-article');
children.forEach((child, index) => {
child.style.transitionDelay = (index * 0.1) + 's';
child.classList.add('animate-in');
});
}
});
}, observerOptions);
const sections = document.querySelectorAll('section, .zenax-info, .zpm-info');
sections.forEach(section => {
section.classList.add('animate-ready');
observer.observe(section);
});
const style = document.createElement('style');
style.textContent = `
.animate-ready {
opacity: 0;
transform: translateY(20px);
transition: opacity 0.6s ease, transform 0.6s ease;
}
.animate-ready.animate-in {
opacity: 1;
transform: translateY(0);
}
.feature-card.animate-ready,
.news-card.animate-ready,
.news-article.animate-ready,
.zenax-feature.animate-ready {
opacity: 0;
transform: translateY(15px);
}
.feature-card.animate-in,
.news-card.animate-in,
.news-article.animate-in,
.zenax-feature.animate-in {
opacity: 1;
transform: translateY(0);
}
`;
document.head.appendChild(style);
}
// ═══════════════════════════════════════════════════════════════════════════════
// TERMINAL TYPING EFFECT
// ═══════════════════════════════════════════════════════════════════════════════
function initTerminalTyping() {
return;
}
// ═══════════════════════════════════════════════════════════════════════════════
// NAV SCROLL EFFECT
// ═══════════════════════════════════════════════════════════════════════════════
function initNavScrollEffect() {
const nav = document.querySelector('nav');
if (!nav) return;
window.addEventListener('scroll', () => {
const currentScroll = window.pageYOffset;
if (currentScroll > 80) {
nav.style.background = 'rgba(255, 255, 255, 0.95)';
nav.style.boxShadow = '0 10px 35px rgba(92, 74, 74, 0.1)';
} else {
nav.style.background = 'rgba(255, 255, 255, 0.7)';
nav.style.boxShadow = '0 8px 32px rgba(92, 74, 74, 0.08)';
}
});
}
// ═══════════════════════════════════════════════════════════════════════════════
// LIGHTBOX
// ═══════════════════════════════════════════════════════════════════════════════
function openLightbox(imgSrc) {
const lightbox = document.getElementById('lightbox');
const lightboxImg = document.getElementById('lightbox-img');
if (lightbox && lightboxImg) {
lightboxImg.src = imgSrc;
lightbox.classList.add('active');
document.body.style.overflow = 'hidden';
}
}
function closeLightbox() {
const lightbox = document.getElementById('lightbox');
if (lightbox) {
lightbox.classList.remove('active');
document.body.style.overflow = 'auto';
}
}
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') {
closeLightbox();
}
});
// ═══════════════════════════════════════════════════════════════════════════════
// ZENNY INTERACTIVE
// ═══════════════════════════════════════════════════════════════════════════════
document.addEventListener('DOMContentLoaded', () => {
const zenny = document.getElementById('zennyHero');
if (zenny) {
zenny.addEventListener('mouseenter', () => {
zenny.style.animationDuration = '2s';
});
zenny.addEventListener('mouseleave', () => {
zenny.style.animationDuration = '4s';
});
}
});