Spaces:
Running
Running
File size: 13,207 Bytes
9254844 8950060 9254844 |
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 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 |
// Initialize on DOM load
document.addEventListener('DOMContentLoaded', function() {
// Generate stars for parallax background
generateStars();
// Initialize gallery
populateGallery();
// Initialize counters
initCounters();
// Initialize form
initContactForm();
// Initialize scroll effects
initScrollEffects();
// Initialize parallax
initParallax();
// Initialize typewriter effect
initTypewriter();
});
// Initialize typewriter effect
function initTypewriter() {
const texts = [
"Where Dreams Meet Digital Reality",
"Where Innovation Meets Imagination",
"Where Code Meets Creativity",
"Where Vision Meets Technology"
];
let textIndex = 0;
let charIndex = 0;
let isDeleting = false;
let typewriterElement = document.getElementById('typewriter-text');
if (!typewriterElement) return;
function type() {
const currentText = texts[textIndex];
if (isDeleting) {
typewriterElement.textContent = currentText.substring(0, charIndex - 1);
charIndex--;
} else {
typewriterElement.textContent = currentText.substring(0, charIndex + 1);
charIndex++;
}
let typeSpeed = isDeleting ? 50 : 100;
if (!isDeleting && charIndex === currentText.length) {
typeSpeed = 2000; // Pause at end
isDeleting = true;
} else if (isDeleting && charIndex === 0) {
isDeleting = false;
textIndex = (textIndex + 1) % texts.length;
typeSpeed = 500; // Pause before typing new text
}
setTimeout(type, typeSpeed);
}
// Start the typewriter effect
type();
}
// Generate animated stars
function generateStars() {
const parallaxBg = document.getElementById('parallaxBg');
const starCount = 100;
for (let i = 0; i < starCount; i++) {
const star = document.createElement('div');
star.className = 'star';
star.style.width = Math.random() * 3 + 'px';
star.style.height = star.style.width;
star.style.left = Math.random() * 100 + '%';
star.style.top = Math.random() * 100 + '%';
star.style.animationDelay = Math.random() * 3 + 's';
parallaxBg.appendChild(star);
}
}
// Populate gallery with dynamic content
function populateGallery() {
const gallery = document.getElementById('gallery');
const categories = ['nature', 'technology', 'abstract', 'cityscape', 'workspace', 'food'];
const colors = ['purple', 'blue', 'green', 'pink', 'yellow', 'red'];
for (let i = 0; i < 9; i++) {
const card = document.createElement('div');
const category = categories[i % categories.length];
const color = colors[i % colors.length];
const imageUrl = `https://static.photos/${category}/640x360/${i + 42}`;
card.className = 'card-hover glass-morphism rounded-2xl overflow-hidden group cursor-pointer';
card.innerHTML = `
<div class="relative h-64 overflow-hidden">
<img src="${imageUrl}" alt="Gallery Item ${i + 1}" class="w-full h-full object-cover transition-transform duration-500 group-hover:scale-110">
<div class="absolute inset-0 bg-gradient-to-t from-gray-900 via-transparent to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300"></div>
<div class="absolute bottom-0 left-0 p-6 transform translate-y-full group-hover:translate-y-0 transition-transform duration-300">
<h3 class="text-xl font-bold mb-2">Masterpiece ${i + 1}</h3>
<p class="text-sm text-gray-300">Click to explore infinite possibilities</p>
</div>
</div>
`;
card.addEventListener('click', function() {
createParticleEffect(event);
});
gallery.appendChild(card);
}
}
// Initialize animated counters
function initCounters() {
const counters = document.querySelectorAll('.counter');
const speed = 200;
const observerOptions = {
threshold: 0.5
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const counter = entry.target;
const target = +counter.getAttribute('data-target');
const increment = target / speed;
const updateCount = () => {
const count = +counter.innerText;
if (count < target) {
counter.innerText = Math.ceil(count + increment);
setTimeout(updateCount, 1);
} else {
counter.innerText = target + '+';
}
};
updateCount();
observer.unobserve(counter);
}
});
}, observerOptions);
counters.forEach(counter => observer.observe(counter));
}
// Initialize contact form
function initContactForm() {
const form = document.getElementById('contactForm');
form.addEventListener('submit', function(e) {
e.preventDefault();
// Create success message
const successMsg = document.createElement('div');
successMsg.className = 'fixed top-20 right-6 bg-green-500 text-white px-6 py-3 rounded-lg shadow-lg z-50 fade-in';
successMsg.innerHTML = `
<div class="flex items-center gap-2">
<i data-feather="check-circle" class="w-5 h-5"></i>
<span>Message sent successfully!</span>
</div>
`;
document.body.appendChild(successMsg);
feather.replace();
// Reset form
form.reset();
// Remove message after 3 seconds
setTimeout(() => {
successMsg.remove();
}, 3000);
// Create particle effect
createParticleEffect(e);
});
}
// Initialize scroll effects
function initScrollEffects() {
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('fade-in');
}
});
}, observerOptions);
document.querySelectorAll('section').forEach(section => {
observer.observe(section);
});
}
// Initialize parallax effect
function initParallax() {
window.addEventListener('scroll', () => {
const scrolled = window.pageYOffset;
const parallaxBg = document.getElementById('parallaxBg');
parallaxBg.style.transform = `translateY(${scrolled * 0.5}px)`;
});
}
// Create particle effect on click
function createParticleEffect(event) {
const colors = ['#9333ea', '#ec4899', '#3b82f6', '#10b981', '#f59e0b'];
const particleCount = 20;
for (let i = 0; i < particleCount; i++) {
const particle = document.createElement('div');
particle.className = 'particle';
const size = Math.random() * 8 + 4;
const color = colors[Math.floor(Math.random() * colors.length)];
const angle = (Math.PI * 2 * i) / particleCount;
const velocity = Math.random() * 100 + 50;
particle.style.width = size + 'px';
particle.style.height = size + 'px';
particle.style.backgroundColor = color;
particle.style.borderRadius = '50%';
particle.style.left = event.clientX + 'px';
particle.style.top = event.clientY + 'px';
particle.style.setProperty('--tx', Math.cos(angle) * velocity + 'px');
particle.style.setProperty('--ty', Math.sin(angle) * velocity + 'px');
document.body.appendChild(particle);
setTimeout(() => particle.remove(), 3000);
}
}
// Add cursor trail effect
document.addEventListener('mousemove', (e) => {
if (Math.random() > 0.98) {
const trail = document.createElement('div');
trail.className = 'fixed w-2 h-2 bg-purple-500 rounded-full pointer-events-none z-40';
trail.style.left = e.clientX + 'px';
trail.style.top = e.clientY + 'px';
trail.style.animation = 'fadeOut 1s ease-out forwards';
document.body.appendChild(trail);
setTimeout(() => trail.remove(), 1000);
}
});
// Earth interaction
function initEarthInteraction() {
const earthContainer = document.querySelector('.earth-container');
if (!earthContainer) return;
let mouseX = 0;
let mouseY = 0;
let currentX = 0;
let currentY = 0;
document.addEventListener('mousemove', (e) => {
const rect = earthContainer.getBoundingClientRect();
const centerX = rect.left + rect.width / 2;
const centerY = rect.top + rect.height / 2;
mouseX = (e.clientX - centerX) / 20;
mouseY = (e.clientY - centerY) / 20;
});
function animateEarth() {
currentX += (mouseX - currentX) * 0.1;
currentY += (mouseY - currentY) * 0.1;
const earthSphere = earthContainer.querySelector('.earth-sphere');
if (earthSphere) {
earthSphere.style.transform = `rotateY(${currentX}deg) rotateX(${-currentY}deg) rotateZ(-23.5deg)`;
}
requestAnimationFrame(animateEarth);
}
animateEarth();
// Add click event for earthquake effect
earthContainer.addEventListener('click', function(e) {
const earthSphere = this.querySelector('.earth-sphere');
earthSphere.style.animation = 'none';
setTimeout(() => {
earthSphere.style.animation = 'earthRotation 30s linear infinite, earthquake 0.5s ease-in-out';
}, 10);
setTimeout(() => {
earthSphere.style.animation = 'earthRotation 30s linear infinite';
}, 500);
createEarthParticles(e);
});
}
// Create Earth particles on click
function createEarthParticles(event) {
const colors = ['#4a90e2', '#228b22', '#87ceeb', '#ffffff'];
const particleCount = 15;
for (let i = 0; i < particleCount; i++) {
const particle = document.createElement('div');
particle.className = 'earth-particle';
const size = Math.random() * 6 + 2;
const color = colors[Math.floor(Math.random() * colors.length)];
const angle = (Math.PI * 2 * i) / particleCount;
const velocity = Math.random() * 80 + 40;
particle.style.width = size + 'px';
particle.style.height = size + 'px';
particle.style.backgroundColor = color;
particle.style.borderRadius = '50%';
particle.style.position = 'fixed';
particle.style.pointerEvents = 'none';
particle.style.zIndex = '1000';
particle.style.left = event.clientX + 'px';
particle.style.top = event.clientY + 'px';
particle.style.boxShadow = `0 0 10px ${color}`;
particle.style.setProperty('--tx', Math.cos(angle) * velocity + 'px');
particle.style.setProperty('--ty', Math.sin(angle) * velocity + 'px');
document.body.appendChild(particle);
setTimeout(() => particle.remove(), 2000);
}
}
// Add earthquake animation
const earthquakeStyle = document.createElement('style');
earthquakeStyle.textContent = `
@keyframes earthquake {
0%, 100% { transform: rotateY(0deg) rotateX(0deg) translateX(0); }
25% { transform: rotateY(2deg) rotateX(-1deg) translateX(-2px); }
50% { transform: rotateY(-1deg) rotateX(2deg) translateX(2px); }
75% { transform: rotateY(1deg) rotateX(-2deg) translateX(-1px); }
}
.earth-particle {
opacity: 1;
animation: earthParticleAnimation 2s ease-out forwards;
}
@keyframes earthParticleAnimation {
0% {
opacity: 1;
transform: translate(0, 0) scale(0);
}
50% {
opacity: 1;
transform: translate(var(--tx), var(--ty)) scale(1);
}
100% {
opacity: 0;
transform: translate(calc(var(--tx) * 1.5), calc(var(--ty) * 1.5)) scale(0.5);
}
}
`;
document.head.appendChild(earthquakeStyle);
// Initialize Earth interaction on DOM load
document.addEventListener('DOMContentLoaded', function() {
initEarthInteraction();
});
// Add keyboard navigation
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') {
window.scrollTo({ top: 0, behavior: 'smooth' });
}
});
// Performance optimization - Debounce scroll events
let scrollTimeout;
window.addEventListener('scroll', () => {
if (scrollTimeout) {
window.cancelAnimationFrame(scrollTimeout);
}
scrollTimeout = window.requestAnimationFrame(() => {
// Add any scroll-based animations here
});
}); |