fsdvsdrfge's picture
make a beatifull website of your choice. But make it the most beatifull website in existance.
ef139ca verified
Raw History Blame Contribute Delete
2.6 kB
// Initialize cosmic effects
document.addEventListener('DOMContentLoaded', () => {
// Parallax effect
const parallaxElements = document.querySelectorAll('.cosmic-item, .feature-card');
window.addEventListener('mousemove', (e) => {
const x = (window.innerWidth / 2 - e.pageX) / 20;
const y = (window.innerHeight / 2 - e.pageY) / 20;
parallaxElements.forEach(el => {
el.style.transform = `translate(${x}px, ${y}px)`;
});
});
// Testimonial slider
const testimonials = document.querySelectorAll('.testimonial');
const sliderButtons = document.querySelectorAll('.slider-btn');
let currentIndex = 0;
function showTestimonial(index) {
testimonials.forEach(testimonial => testimonial.classList.remove('active'));
sliderButtons.forEach(btn => btn.classList.remove('active'));
testimonials[index].classList.add('active');
sliderButtons[index].classList.add('active');
currentIndex = index;
}
sliderButtons.forEach((btn, index) => {
btn.addEventListener('click', () => showTestimonial(index));
});
// Auto-rotate testimonials
setInterval(() => {
let nextIndex = (currentIndex + 1) % testimonials.length;
showTestimonial(nextIndex);
}, 5000);
// Animate cosmic items on scroll
const cosmicItems = document.querySelectorAll('.cosmic-item');
function checkScroll() {
cosmicItems.forEach(item => {
const itemPosition = item.getBoundingClientRect().top;
const screenPosition = window.innerHeight / 1.3;
if(itemPosition < screenPosition) {
item.classList.add('animated');
}
});
}
window.addEventListener('scroll', checkScroll);
checkScroll(); // Run once on load
// Particle click effect
document.addEventListener('click', (e) => {
const particles = document.createElement('div');
particles.className = 'particles';
particles.style.left = `${e.clientX}px`;
particles.style.top = `${e.clientY}px`;
document.body.appendChild(particles);
setTimeout(() => {
particles.remove();
}, 1000);
});
});
// Smooth scroll for navigation
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});