k-render-architect / script.js
Shaiknoor's picture
<!DOCTYPE html>
6010350 verified
raw
history blame contribute delete
979 Bytes
// Set current year in footer
document.getElementById('year').textContent = new Date().getFullYear();
// Smooth scroll with offset for fixed header
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
const offset = 80;
const targetPosition = target.offsetTop - offset;
window.scrollTo({
top: targetPosition,
behavior: 'smooth'
});
}
});
});
// Add scroll animation to elements
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('visible');
}
});
}, observerOptions);
document.querySelectorAll('.service-card, .portfolio-card').forEach(el => {
observer.observe(el);
});