UseScrollToElement
katanakit-js / useScrollToElement
Function: useScrollToElement()
Section titled “Function: useScrollToElement()”function useScrollToElement(target, options?): boolean;Defined in: infrastructure/viewport/viewport.service.ts:201
Scrolls an element into view.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
target |
string | HTMLElement |
An HTMLElement or a CSS selector string. |
options? |
ScrollOptions |
Scroll options (behavior, block, inline). |
Returns
Section titled “Returns”boolean
true if the element was found and scrolled to.
Example
Section titled “Example”useScrollToElement("#section-2", { behavior: "smooth", block: "start" });