useScrollTo ​
Hook for scrolling to a specific element
typescript
import { useScrollTo } from '@siberiacancode/reactuse';
Usage ​
typescript
const trigger = useScrollTo(ref, options);
// or
const { ref, trigger } = useScrollTo(options);
Demo ​
Api ​
Parameters
Name | Type | Default | Note |
---|---|---|---|
target | Target | - | The target element for scrolling to |
options.x | number | - | The horizontal position to scroll to |
options.y | number | - | The vertical position to scroll to |
options.behavior? | ScrollBehavior | 'auto' | The scrolling behavior |
Returns
boolean
Parameters
Name | Type | Default | Note |
---|---|---|---|
options.x | number | - | The horizontal position to scroll to |
options.y | number | - | The vertical position to scroll to |
options.behavior? | ScrollBehavior | 'auto' | The scrolling behavior |