36788-vm/assets/js/main.js
2025-12-09 14:35:31 +00:00

49 lines
1.6 KiB
JavaScript

document.addEventListener('DOMContentLoaded', function() {
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// Navbar scroll effect
const navbar = document.querySelector('.navbar');
window.addEventListener('scroll', () => {
if (window.scrollY > 50) {
navbar.classList.add('scrolled');
} else {
navbar.classList.remove('scrolled');
}
});
// Floating hearts animation
const finalSection = document.querySelector('.final-section');
if (finalSection) {
const heartsContainer = document.createElement('div');
heartsContainer.className = 'floating-hearts';
finalSection.appendChild(heartsContainer);
for (let i = 0; i < 15; i++) {
const heart = document.createElement('div');
heart.className = 'heart';
heart.style.left = Math.random() * 100 + 'vw';
heart.style.animationDuration = (Math.random() * 5 + 5) + 's'; // 5-10 seconds
heart.style.animationDelay = Math.random() * 5 + 's';
heartsContainer.appendChild(heart);
}
}
// Music button placeholder
const musicBtn = document.getElementById('play-music-btn');
if(musicBtn) {
musicBtn.addEventListener('click', () => {
alert('Background music coming soon!');
});
}
});