useAutoScroll
Hook that automatically scrolls a list element to the bottom
elements
low
test coverage
Last changed: 24 days ago
Installation
Library
CLI
Manual
typescript
import { useAutoScroll } from '@siberiacancode/reactuse';Usage
typescript
## Demo useAutoScroll(ref);
// or
const { ref } = useAutoScroll();Api
Parameters
| Name | Type | Default | Note |
|---|---|---|---|
| target | HookTarget | - | The target element to auto-scroll |
| options.enabled? | boolean | - | Whether auto-scrolling is enabled |
Returns
void
Parameters
| Name | Type | Default | Note |
|---|---|---|---|
| options.enabled? | boolean | - | Whether auto-scrolling is enabled |
Returns
{ ref: StateRef<Target> }
Type declaration
typescript
import type { HookTarget } from '@/utils/helpers';
import type { StateRef } from '../useRefState/useRefState';
export interface UseAutoScrollOptions {
/** Whether auto-scrolling is enabled */
enabled?: boolean;
/** Whether to force auto-scrolling regardless of user interactions */
force?: boolean;
}
export interface UseAutoScroll {
(target: HookTarget, options?: UseAutoScrollOptions): void;
<Target extends HTMLElement>(
options?: UseAutoScrollOptions
): {
ref: StateRef<Target>;
};
}Source
Source • DemoContributors
D