{"id":34996487,"url":"https://github.com/avisek/scroll-size-observer","last_synced_at":"2026-05-20T18:36:18.425Z","repository":{"id":221656534,"uuid":"755006963","full_name":"avisek/scroll-size-observer","owner":"avisek","description":"A lightweight JavaScript library that provides a simple and efficient way to observe changes to elements' `scrollWidth` and `scrollHeight` properties. It offers a similar API to `ResizeObserver`.","archived":false,"fork":false,"pushed_at":"2024-02-09T08:49:20.000Z","size":23,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-10T12:36:45.623Z","etag":null,"topics":["dimensions","event","library","lightweight","observer","resize","scroll","scrollheight","scrollwidth","size","typescript","zero-dependencies"],"latest_commit_sha":null,"homepage":"https://avisek.github.io/scroll-size-observer/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/avisek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2024-02-09T08:28:52.000Z","updated_at":"2025-01-13T09:26:38.000Z","dependencies_parsed_at":"2024-02-09T09:44:26.717Z","dependency_job_id":"3f49889a-0f6e-4eb2-9fd5-28d1ca4f116f","html_url":"https://github.com/avisek/scroll-size-observer","commit_stats":null,"previous_names":["avisek/scroll-size-observer"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/avisek/scroll-size-observer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avisek%2Fscroll-size-observer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avisek%2Fscroll-size-observer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avisek%2Fscroll-size-observer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avisek%2Fscroll-size-observer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/avisek","download_url":"https://codeload.github.com/avisek/scroll-size-observer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avisek%2Fscroll-size-observer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28069262,"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","status":"online","status_checked_at":"2025-12-27T02:00:05.897Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["dimensions","event","library","lightweight","observer","resize","scroll","scrollheight","scrollwidth","size","typescript","zero-dependencies"],"created_at":"2025-12-27T02:16:17.515Z","updated_at":"2025-12-27T02:16:37.208Z","avatar_url":"https://github.com/avisek.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ScrollSizeObserver\n\nScrollSizeObserver is a lightweight JavaScript library that provides a simple and efficient way to observe changes to elements' [`scrollWidth`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollWidth) and [`scrollHeight`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight) properties. It offers a similar API to [`ResizeObserver`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver).\n\n## Features\n\n- **Easy Integration**: Simple to integrate into existing projects with minimal setup.\n- **Flexible Configuration**: Offers options to observe horizontal and/or vertical scroll sizes based on requirements.\n- **Efficient Observations**: Utilizes modern browser APIs to efficiently track changes without impacting performance.\n- **Cross-Browser Compatibility**: Compatible with major modern browsers, ensuring consistent behavior across different environments.\n- **TypeScript Support**: Provides full support for TypeScript, enabling type-checking and enhanced development experience.\n- **Lightweight**: Zero-dependency minimal footprint ensures fast loading times and optimal performance.\n\n## Demo\n\nCheck out the [demo page](https://avisek.github.io/scroll-size-observer/) to see a simple demonstration of the ScrollSizeObserver library in action.\n\n## Installation\n\nYou can install ScrollSizeObserver via npm:\n\n```sh\nnpm install scroll-size-observer\n```\n\n## Usage\n\n```javascript\nimport { ScrollSizeObserver } from 'scroll-size-observer'\n\n// Just like `ResizeObserver`\nconst observer = new ScrollSizeObserver((entries, observer) =\u003e {\n  entries.forEach((entry) =\u003e {\n    console.log('Target element:', entry.target)\n    console.log('New scrollWidth:', entry.scrollWidth)\n    console.log('New scrollHeight:', entry.scrollHeight)\n    console.log('Previous scrollWidth:', entry.previousScrollWidth)\n    console.log('Previous scrollHeight:', entry.previousScrollHeight)\n  })\n})\n\n// Observe an element\nobserver.observe(elementToObserve)\n\n// Observe only `scrollHeight`\nobserver.observe(elementToObserve, { scrollWidth: false })\n\n// Unobserve an element\nobserver.unobserve(elementToUnobserve)\n\n// Unobserve all observed elements\nobserver.disconnect()\n```\n\n## API\n\n- **`ScrollSizeObserver(callback: ScrollSizeObserverCallback)`**\n\n  Creates a new `ScrollSizeObserver` instance.\n\n  - `callback`: A function called whenever an observed scroll size change occurs.\n\n- **`observe(target: Element, options?: ScrollSizeObserverOptions): void`**\n\n  Starts observing the specified `Element`.\n\n  - `target`: A reference to the `Element` to be observed.\n  - `options`: An options object allowing you to set options for the observation.\n\n- **`unobserve(target: Element): void`**\n\n  Ends the observation of a specified `Element`.\n\n  - `target`: A reference to the `Element` to be unobserved.\n\n- **`disconnect(): void`**\n\n  Unobserves all observed `Element` targets.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Contributing\n\nContributions are welcome! Fork the repository, make your changes, and submit a pull request. Thank you for helping improve our project!\n\n## Support\n\nFor any questions, issues, or feature requests, please [open an issue](https://github.com/avisek/scroll-size-observer/issues/new).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favisek%2Fscroll-size-observer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favisek%2Fscroll-size-observer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favisek%2Fscroll-size-observer/lists"}