{"id":16785549,"url":"https://github.com/joaom00/scrollen","last_synced_at":"2025-03-22T00:32:21.180Z","repository":{"id":174990586,"uuid":"651946087","full_name":"joaom00/scrollen","owner":"joaom00","description":"A performant utility scroll hook for React.","archived":false,"fork":false,"pushed_at":"2023-06-13T18:14:49.000Z","size":205,"stargazers_count":23,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-18T06:35:57.976Z","etag":null,"topics":["hook","react","scroll"],"latest_commit_sha":null,"homepage":"https://scrollen.vercel.app","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/joaom00.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-10T15:25:54.000Z","updated_at":"2024-09-18T15:30:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"5f661c3d-2b7b-4d3d-bfd2-a2e95b22b794","html_url":"https://github.com/joaom00/scrollen","commit_stats":null,"previous_names":["joaom00/scrollen"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joaom00%2Fscrollen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joaom00%2Fscrollen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joaom00%2Fscrollen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joaom00%2Fscrollen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joaom00","download_url":"https://codeload.github.com/joaom00/scrollen/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244890102,"owners_count":20527030,"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":["hook","react","scroll"],"created_at":"2024-10-13T08:09:41.537Z","updated_at":"2025-03-22T00:32:21.175Z","avatar_url":"https://github.com/joaom00.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003cimg src=\"./website/public/og.png\" /\u003e\n\u003c/p\u003e\n\n# Scrollen\n\nA performant utility scroll hook for React.\n\n## Install\n\n```sh\nnpm install scrollen\n```\n\n## Getting Started\n\nTo start using the scrollen you need import and call the `useScroller` hook\n\n```js\nimport { useScroller } from 'scrollen'\n\nconst scroller = useScroller()\n```\n\nAnd that's it! By default the hook will listen to scroll on document.\n\nIf you want to use a different scroll container, you can use the `setScrollerElement` function\n\n```jsx\nimport { useScroller } from 'scrollen'\n\nconst scroller = useScroller()\n\n\u003cdiv ref={scroller.setScrollerElement}\u003e\n  ...\n\u003c/div\u003e\n```\n\n### Example\n\nSee this [small example](https://github.com/joaom00/scrollen/blob/main/website/src/app/page.tsx) of how you can use the hook.\n\n## Documentation\n\nFirst of all, a huge thanks to [@diegohaz](https://twitter.com/diegohaz) as this library uses the\nAriakit Component Stores API, so refer to the Ariakit [Component Stores Guide](https://ariakit.org/guide/component-stores) to learn the core\nof the hook.\n\n### Props\n\n| Prop                | Description                                                    |\n| ------------------- | -------------------------------------------------------------- |\n| `initialScrollTop`  | The initial `scrollTop` value to the scroller element.         |\n| `initialScrollLeft` | The initial `scrollLeft` value to the scroller element.        |\n| `startScrollAt`     | Where the scroll should start. You can pass `bottom \\| right`. |\n\n### State\n\n| State              | Description                                                         |\n| ------------------ | ------------------------------------------------------------------- |\n| `element`          | The scroller element.                                               |\n| `scrollTop`        | The `scrollTop` value for the scroller element.                     |\n| `scrollLeft`       | The `scrollLeft` value for the scroller element.                    |\n| `scrollWidth`      | The `scrollWidth` value for the scroller element.                   |\n| `scrollHeight`     | The `scrollHeight` value for the scroller element.                  |\n| `scrollY`          | The progress of the vertical scroll. (between 0 and 1)              |\n| `scrollX`          | The progress of the horizontal scroll. (between 0 and 1)            |\n| `scrollLengthY`    | The length of the vertical scroll.                                  |\n| `scrollLengthX`    | The length of the horizontal scroll.                                |\n| `scrollDirectionY` | The direction of the vertical scroll. (`static \\| up \\| down`)      |\n| `scrollDirectionX` | The direction of the horizontal scroll. (`static \\| left \\| right`) |\n| `isAtTop`          | A boolean to check if the scroll reached the top.                   |\n| `isAtBottom`       | A boolean to check if the scroll reached the bottom.                |\n| `isAtLeft`         | A boolean to check if the scroll reached the left.                  |\n| `isAtRight`        | A boolean to check if the scroll reached the right.                 |\n\n### Functions\n\n| Function             | Description                                                                             |\n| -------------------- | --------------------------------------------------------------------------------------- |\n| `setScrollerElement` | Function to set the scroller element.                                                   |\n| `scrollToTop`        | Function to scroll programatically to top.                                              |\n| `scrollToLeft`       | Function to scroll programatically to left.                                             |\n| `scrollToBottom`     | Function to scroll programatically to bottom.                                           |\n| `scrollToRight`      | Function to scroll programtically to right.                                             |\n| `useOnScrollTop`     | A custom hook to register a callback that is called when the scroll reached the top.    |\n| `useOnScrollBottom`  | A custom hook to register a callback that is called when the scroll reached the bottom. |\n\n## Acknowledgements\n\n- Ariakit - Thanks to [@diegohaz](https://twitter.com/diegohaz) for the Component Stores API that\n  made it possible to create a performant hook.\n- react-virtuoso - Where did I get ideas for utilities.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoaom00%2Fscrollen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoaom00%2Fscrollen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoaom00%2Fscrollen/lists"}