{"_id":"@byndyusoft-ui/use-scroll-lock","name":"@byndyusoft-ui/use-scroll-lock","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@byndyusoft-ui/use-scroll-lock","version":"0.1.0","description":"Byndyusoft UI React Hook","keywords":["byndyusoft","byndyusoft-ui","react","hook","use-scroll-lock"],"author":{"name":"Dmitrii Maletskii","email":"maleckij@byndyusoft.com"},"homepage":"https://github.com/Byndyusoft/ui/tree/master/hooks/use-scroll-lock#readme","license":"Apache-2.0","main":"dist/index.js","types":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/Byndyusoft/ui.git"},"scripts":{"build":"tsc --project tsconfig.build.json","clean":"rimraf dist","lint":"eslint src --config ../../eslint.config.js","test":"jest --config ../../jest.config.js --roots hooks/use-scroll-lock/src"},"bugs":{"url":"https://github.com/Byndyusoft/ui/issues"},"publishConfig":{"access":"public"},"_id":"@byndyusoft-ui/use-scroll-lock@0.1.0","gitHead":"54672ef41d4a012274c8ce4e7f3d0444671e3dba","_nodeVersion":"20.14.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-CYNqAxC1GlAYWCWRZYH81le4B9/4E9/V7/Jzt0so2KIp6ZxUoGei33VQs2eHcEHiG9Tmgm56dS9A7V+jOvsCvg==","shasum":"99531fbe4e8d5ef7627535f17ba8c9bd988dd85a","tarball":"https://registry.npmjs.org/@byndyusoft-ui/use-scroll-lock/-/use-scroll-lock-0.1.0.tgz","fileCount":10,"unpackedSize":8394,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD7UNE7K3KQ7M1x4PesdEMgEsIigLnFf8cVndq5fsavbgIhALqqWRspE9O29mVeWBj1t04olmTau4DqKPE/JiBwxV+E"}]},"_npmUser":{"name":"sadcitizen","email":"sadcitizen@yandex.ru"},"directories":{},"maintainers":[{"name":"sadcitizen","email":"sadcitizen@yandex.ru"},{"name":"alexanderbyndyu","email":"alexander.byndyu@yandex.ru"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/use-scroll-lock_0.1.0_1738758597669_0.45936678828182154"},"_hasShrinkwrap":false}},"time":{"created":"2025-02-05T12:29:57.550Z","0.1.0":"2025-02-05T12:29:57.892Z","modified":"2025-02-05T12:29:58.181Z"},"maintainers":[{"name":"sadcitizen","email":"sadcitizen@yandex.ru"},{"name":"alexanderbyndyu","email":"alexander.byndyu@yandex.ru"}],"description":"Byndyusoft UI React Hook","homepage":"https://github.com/Byndyusoft/ui/tree/master/hooks/use-scroll-lock#readme","keywords":["byndyusoft","byndyusoft-ui","react","hook","use-scroll-lock"],"repository":{"type":"git","url":"git+https://github.com/Byndyusoft/ui.git"},"author":{"name":"Dmitrii Maletskii","email":"maleckij@byndyusoft.com"},"bugs":{"url":"https://github.com/Byndyusoft/ui/issues"},"license":"Apache-2.0","readme":"# useScrollLock\r\n\r\nA React hook for locking element scroll.\r\n\r\nThis hook manages the scrollability of either the body element or a specified target element. When `isLocked` is set to `true`, scrolling is prevented by setting `overflow: hidden` on the target element. When set to `false` or when the component unmounts, the original overflow value is restored.\r\n\r\n## Installation\r\n\r\n```\r\nnpm install @byndyusoft-ui/use-scroll-lock\r\n```\r\n\r\n## Usage\r\n\r\n```typescript\r\nimport useScrollLock from '@byndyusoft-ui/use-scroll-lock';\r\n\r\n// Basic usage\r\nfunction Modal({ isOpen }) {\r\n    useScrollLock(isOpen);\r\n\r\n    return isOpen && <div className=\"modal\">{/* modal content */}</div>;\r\n}\r\n\r\n// Usage with custom target element\r\nfunction CustomScrollLock({ isLocked }) {\r\n    const containerRef = useRef<HTMLDivElement>(null);\r\n    useScrollLock(isLocked, containerRef.current);\r\n\r\n    return (\r\n        <div ref={containerRef} className=\"scrollable-container\">\r\n            {/* content */}\r\n        </div>\r\n    );\r\n}\r\n```\r\n\r\n## API\r\n\r\n```typescript\r\nuseScrollLock(isLocked?: boolean, target?: HTMLElement | null): void\r\n```\r\n\r\n#### Parameters\r\n\r\n-   `isLocked` (boolean) - When `true`, element scroll will be locked. When `false` or `undefined`, scroll will be unlocked.\r\n-   `target` (HTMLElement | null) - Optional. The HTML element to lock scrolling on. If not provided or null, defaults to document.body.\r\n","readmeFilename":"README.md"}