Spaces:
Running
Running
File size: 8,447 Bytes
92d9d0d ca5829a 92d9d0d ca5829a 92d9d0d ca5829a 92d9d0d ca5829a 92d9d0d ca5829a 92d9d0d ca5829a 92d9d0d ca5829a 92d9d0d ca5829a 92d9d0d ca5829a 92d9d0d ca5829a 92d9d0d ca5829a 92d9d0d 3206283 ca5829a 3206283 ca5829a 92d9d0d ca5829a 92d9d0d ca5829a | 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 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
// Shockwave animation
const canvas = document.getElementById('shockwaveCanvas');
const ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
const shockwaves = [];
class Shockwave {
constructor(x, y) {
this.x = x;
this.y = y;
this.radius = 0;
this.maxRadius = 300;
this.speed = 2;
this.opacity = 0.5;
this.color = `rgba(16, 185, 129, ${this.opacity})`;
}
update() {
this.radius += this.speed;
this.opacity = 0.5 * (1 - this.radius / this.maxRadius);
this.color = `rgba(16, 185, 129, ${this.opacity})`;
}
draw() {
ctx.strokeStyle = this.color;
ctx.lineWidth = 2;
ctx.beginPath();
ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2);
ctx.stroke();
// Second ring
ctx.strokeStyle = `rgba(59, 130, 246, ${this.opacity * 0.5})`;
ctx.beginPath();
ctx.arc(this.x, this.y, this.radius * 0.8, 0, Math.PI * 2);
ctx.stroke();
}
isDead() {
return this.radius > this.maxRadius;
}
}
function animateShockwaves() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Create new shockwave randomly
if (Math.random() < 0.02) {
shockwaves.push(new Shockwave(
Math.random() * canvas.width,
Math.random() * canvas.height
));
}
// Update and draw shockwaves
for (let i = shockwaves.length - 1; i >= 0; i--) {
const wave = shockwaves[i];
wave.update();
wave.draw();
if (wave.isDead()) {
shockwaves.splice(i, 1);
}
}
requestAnimationFrame(animateShockwaves);
}
animateShockwaves();
// Resize canvas on window resize
window.addEventListener('resize', () => {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
});
// Add interactive shockwave on click
document.addEventListener('click', (e) => {
shockwaves.push(new Shockwave(e.clientX, e.clientY));
});
// Service filtering (only if on services page)
if (document.querySelector('.filter-tag')) {
const filterTags = document.querySelectorAll('.filter-tag');
const serviceCards = document.querySelectorAll('.service-card');
filterTags.forEach(tag => {
tag.addEventListener('click', () => {
const filter = tag.dataset.filter;
// Update active state
filterTags.forEach(t => t.classList.remove('bg-emerald-600', 'text-white'));
tag.classList.add('bg-emerald-600', 'text-white');
// Filter cards
serviceCards.forEach(card => {
if (filter === 'all' || card.dataset.category === filter) {
card.style.display = 'block';
setTimeout(() => card.classList.add('visible'), 100);
} else {
card.style.display = 'none';
card.classList.remove('visible');
}
});
});
});
}
// Timeline animation on scroll
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -100px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
}
});
}, observerOptions);
// Observe elements for animation
document.querySelectorAll('.timeline-item, .service-card, .skill-bar').forEach(el => {
observer.observe(el);
});
// Testimonial slider
let currentSlide = 0;
const testimonialsContainer = document.getElementById('testimonialsContainer');
const totalSlides = 3;
function goToSlide(slideIndex) {
currentSlide = slideIndex;
testimonialsContainer.style.transform = `translateX(-${slideIndex * 100}%)`;
// Update dots
document.querySelectorAll('.testimonials-slider button').forEach((dot, index) => {
if (index === slideIndex) {
dot.classList.remove('bg-gray-600');
dot.classList.add('bg-emerald-500');
} else {
dot.classList.remove('bg-emerald-500');
dot.classList.add('bg-gray-600');
}
});
}
// Auto-advance testimonials
setInterval(() => {
currentSlide = (currentSlide + 1) % totalSlides;
goToSlide(currentSlide);
}, 5000);
// Contact form submission
document.getElementById('contactForm').addEventListener('submit', async (e) => {
e.preventDefault();
const formData = new FormData(e.target);
const data = Object.fromEntries(formData);
// Show loading state
const submitBtn = e.target.querySelector('button[type="submit"]');
const originalText = submitBtn.textContent;
submitBtn.innerHTML = '<span class="loading"></span> Sending...';
submitBtn.disabled = true;
try {
// Simulate API call
await new Promise(resolve => setTimeout(resolve, 2000));
// Show success message
const successMsg = document.getElementById('successMessage');
successMsg.style.transform = 'translateX(0)';
// Reset form
e.target.reset();
// Hide success message after 3 seconds
setTimeout(() => {
successMsg.style.transform = 'translateX(100%)';
}, 3000);
} catch (error) {
console.error('Error:', error);
alert('Error sending message. Please try again.');
} finally {
// Reset button
submitBtn.textContent = originalText;
submitBtn.disabled = false;
}
});
// FAQ toggle function
window.toggleFAQ = function(button) {
const content = button.nextElementSibling;
const icon = button.querySelector('i');
content.classList.toggle('hidden');
icon.style.transform = content.classList.contains('hidden') ? 'rotate(0deg)' : 'rotate(180deg)';
};
// Smooth scroll for navigation links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// Parallax scrolling effect
window.addEventListener('scroll', () => {
const scrolled = window.pageYOffset;
const parallaxElements = document.querySelectorAll('.parallax');
parallaxElements.forEach(el => {
const speed = el.dataset.speed || 0.5;
el.style.transform = `translateY(${scrolled * speed}px)`;
});
});
// Add reveal animation to elements on scroll
const revealElements = document.querySelectorAll('.service-card, .timeline-item');
const revealOnScroll = () => {
revealElements.forEach(element => {
const elementTop = element.getBoundingClientRect().top;
const elementBottom = element.getBoundingClientRect().bottom;
if (elementTop < window.innerHeight && elementBottom > 0) {
element.classList.add('visible');
}
});
};
window.addEventListener('scroll', revealOnScroll);
revealOnScroll(); // Initial check
// Dynamic skill bar animation
const skillBars = document.querySelectorAll('.skill-bar');
const animateSkillBars = () => {
skillBars.forEach(bar => {
const rect = bar.getBoundingClientRect();
if (rect.top < window.innerHeight && rect.bottom > 0) {
const progressBar = bar.querySelector('.bg-gradient-to-r');
const width = progressBar.style.width || '0%';
if (width === '0%') {
progressBar.style.width = progressBar.parentElement.previousElementSibling.querySelector('span:last-child').textContent;
}
}
});
};
window.addEventListener('scroll', animateSkillBars);
animateSkillBars();
// Keyboard navigation support
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') {
closeCaseStudy();
}
});
// Performance optimization - Debounce scroll events
let scrollTimeout;
window.addEventListener('scroll', () => {
if (scrollTimeout) {
window.cancelAnimationFrame(scrollTimeout);
}
scrollTimeout = window.requestAnimationFrame(() => {
// Scroll-based animations here
revealOnScroll();
animateSkillBars();
});
}); |