Skip to content
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (!target) return;
const targetPosition = target.getBoundingClientRect().top + window.pageYOffset;
const startPosition = window.pageYOffset;
const distance = targetPosition - startPosition;
const duration = 3000; // <<< SCROLL DURATION set to 3000 milliseconds (1 second)
let start = null;
function step(timestamp) {
if (!start) start = timestamp;
const progress = timestamp - start;
const ease = progress / duration;
const eased = ease < 1 ? ease : 1;
window.scrollTo(0, startPosition + distance * eased);
if (progress < duration) {
window.requestAnimationFrame(step);
}
}
window.requestAnimationFrame(step);
});
});