Skip to content

UseScrollToElement

katanakit-js / useScrollToElement

function useScrollToElement(target, options?): boolean;

Defined in: infrastructure/viewport/viewport.service.ts:201

Scrolls an element into view.

Parameter Type Description
target string | HTMLElement An HTMLElement or a CSS selector string.
options? ScrollOptions Scroll options (behavior, block, inline).

boolean

true if the element was found and scrolled to.

useScrollToElement("#section-2", { behavior: "smooth", block: "start" });