// Main JavaScript file document.addEventListener('DOMContentLoaded', function() { // Add animations to sections when they come into view const sections = document.querySelectorAll('section'); const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('slide-up'); } }); }, { threshold: 0.1, rootMargin: '0px 0px -100px 0px' }); sections.forEach(section => { observer.observe(section); }); // Smooth scrolling for anchor links document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function(e) { e.preventDefault(); const targetId = this.getAttribute('href'); if (targetId === '#') return; const targetElement = document.querySelector(targetId); if (targetElement) { window.scrollTo({ top: targetElement.offsetTop - 100, behavior: 'smooth' }); } }); }); // Typewriter effect for hero section const typewriterTexts = [ "Creative Developer", "UI/UX Designer", "Problem Solver", "Tech Enthusiast" ]; const typewriterElement = document.querySelector('.typewriter-text'); if (typewriterElement) { let currentTextIndex = 0; let charIndex = 0; let isDeleting = false; let typingSpeed = 100; function typeWriter() { const currentText = typewriterTexts[currentTextIndex]; if (isDeleting) { typewriterElement.textContent = currentText.substring(0, charIndex - 1); charIndex--; typingSpeed = 50; } else { typewriterElement.textContent = currentText.substring(0, charIndex + 1); charIndex++; typingSpeed = 100; } if (!isDeleting && charIndex === currentText.length) { isDeleting = true; typingSpeed = 1500; // Pause at end of word } else if (isDeleting && charIndex === 0) { isDeleting = false; currentTextIndex = (currentTextIndex + 1) % typewriterTexts.length; typingSpeed = 500; // Pause before typing next word } setTimeout(typeWriter, typingSpeed); } setTimeout(typeWriter, 1000); } // Add scroll reveal animations const scrollReveal = ScrollReveal({ origin: 'bottom', distance: '60px', duration: 1000, delay: 200, reset: true }); scrollReveal.reveal('.reveal', { interval: 200 }); });