-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
213 lines (187 loc) · 8.01 KB
/
Copy pathscript.js
File metadata and controls
213 lines (187 loc) · 8.01 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
document.addEventListener('DOMContentLoaded', function() {
initScrollReveal();
initNavbarScroll();
initSmoothNavigation();
initHeroParallax();
initInteractiveCarousel();
initButtonEffects();
});
// ==========================================================================
// 1. Front Page to Content Scroll Reveal Engine (Intersection Observer)
// ==========================================================================
function initScrollReveal() {
const observerOptions = {
root: null, // Viewport standard binding
threshold: 0.12, // Triggers when 12% of the targeted view frame maps out
rootMargin: '0px 0px -40px 0px'
};
const revealObserver = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('is-visible');
observer.unobserve(entry.target); // Execution ends processing observation loop once visual assets load
}
});
}, observerOptions);
// Track layout containers using the dedicated visibility system
document.querySelectorAll('.reveal-section').forEach(section => {
revealObserver.observe(section);
});
}
// Navbar scroll edge layout behavior
function initNavbarScroll() {
const navbar = document.querySelector('.navbar');
window.addEventListener('scroll', () => {
if (window.scrollY > 50) {
navbar.style.background = 'rgba(10, 10, 10, 0.85)';
navbar.style.borderBottomColor = 'rgba(66, 66, 69, 0.6)';
} else {
navbar.style.background = 'rgba(10, 10, 10, 0.7)';
navbar.style.borderBottomColor = 'rgba(66, 66, 69, 0.3)';
}
});
}
// Handle Anchor Jump Interventions smoothly
function initSmoothNavigation() {
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
const href = this.getAttribute('href');
if (href !== '#') {
e.preventDefault();
const target = document.querySelector(href);
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
}
});
});
}
// Hero Parallax
function initHeroParallax() {
const heroContent = document.querySelector('.hero-content');
window.addEventListener('scroll', () => {
if (!heroContent) return;
const scrollPosition = window.scrollY;
if (scrollPosition < window.innerHeight) {
heroContent.style.transform = `translateY(${scrollPosition * 0.35}px)`;
heroContent.style.opacity = 1 - (scrollPosition / (window.innerHeight * 0.8));
}
});
}
// ==========================================================================
// 2. High-Performance Infinite Loop Carousel (Drag + Button Mechanics)
// ==========================================================================
function initInteractiveCarousel() {
const carousel = document.getElementById('logo-carousel');
if (!carousel) return;
const track = carousel.querySelector('.carousel-track');
const prevBtn = document.getElementById('carousel-prev');
const nextBtn = document.getElementById('carousel-next');
if (!track) return;
let isAutoplayPaused = false;
let scrollPosition = 0;
const speed = 0.75; // Step frequency size for background processing animation tick loop
// Build loop duplication matrix dynamically
const originalItems = Array.from(track.children);
originalItems.forEach(item => {
const clone = item.cloneNode(true);
track.appendChild(clone);
});
// Compute layout dimensional limits
let itemWidth = originalItems[0].offsetWidth + 28; // Element dimensions mixed into standard margin gap values
let totalWidth = itemWidth * originalItems.length;
window.addEventListener('resize', () => {
itemWidth = originalItems[0].offsetWidth + 28;
totalWidth = itemWidth * originalItems.length;
});
// Core continuous render engine processing loop
function updateScroll() {
if (!isAutoplayPaused) {
scrollPosition -= speed;
if (Math.abs(scrollPosition) >= totalWidth) {
scrollPosition = 0; // Seamless reset without skipping standard layout view frames
}
track.style.transform = `translateX(${scrollPosition}px)`;
}
requestAnimationFrame(updateScroll);
}
// Fire automatic engine
requestAnimationFrame(updateScroll);
// Directional control bindings
function handleManualShift(direction) {
isAutoplayPaused = true;
// Shift a complete item increment down the line track mapping sequence
scrollPosition += (direction * itemWidth * 1.5);
// Prevent out-of-bounds anomalies during manual layout shifting execution cycles
if (scrollPosition > 0) {
scrollPosition = -totalWidth;
} else if (Math.abs(scrollPosition) >= totalWidth * 2) {
scrollPosition = -totalWidth;
}
track.style.transform = `translateX(${scrollPosition}px)`;
// Restore automated gliding motion after manual interactive pause window expires
setTimeout(() => { isAutoplayPaused = false; }, 2500);
}
if (prevBtn && nextBtn) {
prevBtn.addEventListener('click', () => handleManualShift(1));
nextBtn.addEventListener('click', () => handleManualShift(-1));
}
// Set up item hyperlinks correctly
track.querySelectorAll('.logo-item').forEach(item => {
item.style.cursor = 'pointer';
item.addEventListener('click', () => {
const url = item.getAttribute('data-url');
if (url) window.open(url, '_blank', 'noopener noreferrer');
});
// Pause automated movement when user hovers over an item
item.addEventListener('mouseenter', () => { isAutoplayPaused = true; });
item.addEventListener('mouseleave', () => { isAutoplayPaused = false; });
});
// Respect user device parameters for motion constraints
if (window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
isAutoplayPaused = true;
}
}
// Button micro-interactions and ripples
function initButtonEffects() {
document.querySelectorAll('.btn').forEach(button => {
button.addEventListener('mouseenter', function() {
this.style.transform = 'translateY(-3px)';
});
button.addEventListener('mouseleave', function() {
this.style.transform = 'translateY(0)';
});
});
document.querySelectorAll('.btn, .contact-link').forEach(element => {
element.addEventListener('click', function(e) {
const ripple = document.createElement('span');
const rect = this.getBoundingClientRect();
const size = Math.max(rect.width, rect.height);
const x = e.clientX - rect.left - size / 2;
const y = e.clientY - rect.top - size / 2;
ripple.style.width = ripple.style.height = size + 'px';
ripple.style.left = x + 'px';
ripple.style.top = y + 'px';
ripple.style.position = 'absolute';
ripple.style.background = 'rgba(255, 255, 255, 0.25)';
ripple.style.borderRadius = '50%';
ripple.style.transform = 'scale(0)';
ripple.style.pointerEvents = 'none';
ripple.style.animation = 'ripple-effect 0.6s linear';
this.style.position = 'relative';
this.style.overflow = 'hidden';
this.appendChild(ripple);
setTimeout(() => ripple.remove(), 600);
});
});
}
// Global ripple injection keyframe styles fallback mapping mechanism
const styleSheet = document.createElement("style");
styleSheet.innerText = `
@keyframes ripple-effect {
to { transform: scale(4); opacity: 0; }
}`;
document.head.appendChild(styleSheet);