overview / js /utils /dom.js
yjernite's picture
yjernite HF Staff
Upload 4 files
98f8ae8 verified
raw
history blame
457 Bytes
export function scrollToSection(sectionId) {
const element = document.getElementById(sectionId);
if (element) {
const elementRect = element.getBoundingClientRect();
const absoluteElementTop = elementRect.top + window.pageYOffset;
const offset = 120; // Account for fixed header + some padding
window.scrollTo({
top: absoluteElementTop - offset,
behavior: 'smooth'
});
}
}