Skip to content

UseScrollTo

katanakit-js / useScrollTo

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

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

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

Parameter Type Default value Description
x? number 0 Horizontal scroll target (default: 0).
y? number 0 Vertical scroll target (default: 0).
behavior? ScrollBehavior "smooth" Scroll behavior (default: "smooth").

void

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