{"id":20529582,"url":"https://github.com/bmcmahen/use-scroll-lock","last_synced_at":"2025-04-14T05:19:28.730Z","repository":{"id":39466313,"uuid":"196947825","full_name":"bmcmahen/use-scroll-lock","owner":"bmcmahen","description":"a simple react hook for scroll-locking","archived":false,"fork":false,"pushed_at":"2022-12-10T22:33:39.000Z","size":4031,"stargazers_count":19,"open_issues_count":26,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-14T03:48:34.880Z","etag":null,"topics":["hooks","react","scroll-lock"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bmcmahen.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-15T07:32:13.000Z","updated_at":"2024-05-23T12:00:37.000Z","dependencies_parsed_at":"2022-08-29T02:12:00.739Z","dependency_job_id":null,"html_url":"https://github.com/bmcmahen/use-scroll-lock","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmcmahen%2Fuse-scroll-lock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmcmahen%2Fuse-scroll-lock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmcmahen%2Fuse-scroll-lock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmcmahen%2Fuse-scroll-lock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bmcmahen","download_url":"https://codeload.github.com/bmcmahen/use-scroll-lock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248824757,"owners_count":21167356,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hooks","react","scroll-lock"],"created_at":"2024-11-15T23:33:06.307Z","updated_at":"2025-04-14T05:19:28.708Z","avatar_url":"https://github.com/bmcmahen.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# use-scroll-lock\n\n[scroll-lock](https://github.com/FL3NKEY/scroll-lock) is the most reliable scroll-locking library from my experience, and I wanted to use it in hook form. This super simple hook is the result.\n\n## Install\n\n```\nyarn add use-scroll-lock\n```\n\n## Basic usage\n\n`useScrollLock` accepts two optional arguments.\n\n- **enabled** - Whether the scroll locking is enabled. By default this is true.\n- **container** - An optional container which permits scrollable content even when scrolling is locked.\n\n```jsx\nfunction Example() {\n  const [enabled, setEnabled] = React.useState(false);\n  const ref = React.useRef(null);\n\n  useScrollLock(enabled, ref);\n\n  return (\n    \u003cdiv\u003e\n      \u003cbutton onClick={() =\u003e setEnabled(!enabled)}\u003e\n        {enabled ? \"turn off\" : \"turn on\"}\n      \u003c/button\u003e\n      \u003cdiv style={{ overflow: \"auto\" }} ref={ref}\u003e\n        Scrollable content\n      \u003c/div\u003e\n    \u003c/div\u003e\n  );\n}\n```\n\nYou can also use the `data-scroll-lock-scrollable` attribute on whatever element you want to enable scrolling and omit the second argument.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmcmahen%2Fuse-scroll-lock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbmcmahen%2Fuse-scroll-lock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmcmahen%2Fuse-scroll-lock/lists"}