Skip to content
0

katanakit-js / useScrollTo

Function: useScrollTo() ​

ts
function useScrollTo(
   x?, 
   y?, 
   behavior?
): void;

Defined in: src/infrastructure/viewport/viewport.service.ts:160

Scrolls the window to a specific position, respecting prefers-reduced-motion.

Parameters ​

ParameterTypeDefault valueDescription
xnumber0Horizontal scroll target (default: 0).
ynumber0Vertical scroll target (default: 0).
behaviorScrollBehavior"smooth"Scroll behavior (default: "smooth").

Returns ​

void

Example ​

ts
useScrollTo(0, 500); // scroll to 500px from top

Released under the MIT License.