timeproof / script.js
lourealiza's picture
# TimeProof
1b047df verified
Raw History Blame Contribute Delete
1.39 kB
// 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 - 80,
behavior: 'smooth'
});
}
});
});
// Animation on scroll
const observerOptions = {
root: null,
rootMargin: '0px',
threshold: 0.1
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if(entry.isIntersecting) {
entry.target.classList.add('animate-fadeInUp');
}
});
}, observerOptions);
document.querySelectorAll('.bg-gray-800, .bg-gray-900').forEach(el => {
observer.observe(el);
});
// Add animation classes
const style = document.createElement('style');
style.innerHTML = `
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.animate-fadeInUp {
animation: fadeInUp 0.6s ease-out forwards;
}
`;
document.head.appendChild(style);