Files
payload/packages/ui/src/utilities/scrollToID.ts
2023-12-02 03:44:52 -05:00

12 lines
255 B
TypeScript

export const scrollToID = (id: string): void => {
const element = document.getElementById(id)
if (element) {
const bounds = element.getBoundingClientRect()
window.scrollBy({
behavior: 'smooth',
top: bounds.top - 100,
})
}
}