useScrollLock
A custom hook that locks and unlocks scroll.
Installation
npx sse-hooks add use-scroll-lock
yarn dlx sse-hooks add use-scroll-lock
pnpm dlx sse-hooks add use-scroll-lock
deno run -A npm:sse-hooks add use-scroll-lock
bunx sse-hooks add use-scroll-lock
Usage
example.ts
import { useScrollLock } from "./{hooks file}";
// Lock the scroll when the modal is mounted, and unlock it when it's unmounted
useScrollLock();
API
Parameters
| Prop | Default | Type |
|---|---|---|
options |
|
Options to configure the hook, by default it will lock the scroll automatically.
|
Returns
| Return Value | Default | Type |
|---|---|---|
isLocked | - |
Whether the scroll is locked. |
lock | - |
Lock the scroll. |
unlock | - |
Unlock the scroll. |
Types Aliases
No specific type aliases defined for this component.