{"id":19273916,"url":"https://github.com/rintoj/react-virtualscroll","last_synced_at":"2025-08-01T04:10:50.592Z","repository":{"id":47439513,"uuid":"91257282","full_name":"rintoj/react-virtualscroll","owner":"rintoj","description":"Virtual Scroll displays a virtual, \"infinite\" list. Supports multi-column.","archived":false,"fork":false,"pushed_at":"2017-05-14T20:54:53.000Z","size":676,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-08T16:04:10.928Z","etag":null,"topics":[],"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/rintoj.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":"2017-05-14T16:41:06.000Z","updated_at":"2024-05-10T09:32:24.000Z","dependencies_parsed_at":"2022-08-30T17:20:46.964Z","dependency_job_id":null,"html_url":"https://github.com/rintoj/react-virtualscroll","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/rintoj%2Freact-virtualscroll","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rintoj%2Freact-virtualscroll/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rintoj%2Freact-virtualscroll/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rintoj%2Freact-virtualscroll/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rintoj","download_url":"https://codeload.github.com/rintoj/react-virtualscroll/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249685312,"owners_count":21310582,"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":[],"created_at":"2024-11-09T20:44:29.320Z","updated_at":"2025-04-21T22:33:12.581Z","avatar_url":"https://github.com/rintoj.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# react-virtualscroll\n\nVirtual Scroll displays a virtual, \"infinite\" list. Supports multi-column.\n\n## About\n\nThis module displays a small subset of records just enough to fill the viewport and uses the same DOM elements as the user scrolls.\nThis method is effective because the number of DOM elements are always constant and tiny irrespective of the size of the list. Thus virtual scroll can display infinitely growing list of items in an efficient way.\n\n* React compatible module\n* Supports multi-column\n* Easy to use apis\n* OpenSource and available in [GitHub](https://github.com/rintoj/react-virtualscroll)\n\n## Usage\n\n```jsx\n  \u003cVirtualScroll className=\"flx flxw\"\n    items={this.state.items}\n    onChange={(event) =\u003e this.setState(event)}\n    renderItem={this.renderItem.bind(this)} /\u003e\n```\n\n## Get Started\n\n**Step 1:** Install react-virtualscroll\n\n```sh\nnpm install react-virtualscroll --save\n```\n\n**Step 2:** Import virtual scroll module into your app module\n\n```ts\nimport { VirtualScroll } from 'react-virtualscroll';\n```\n\n**Step 3:** Wrap virtual-scroll tag around list items;\n\n```ts\n \u003cVirtualScroll className=\"flx flxw\"\n    items={this.state.items}\n    onChange={(event) =\u003e this.setState(event)}\n    renderItem={this.renderItem.bind(this)} /\u003e\n```\n\n**Step 4:** Create 'renderItem' function.\n\n```tsx\nrenderItem(item) {\n  return \u003cdiv key={item.index} className=\"flx mb1 divider-b primary\"\u003e\n    \u003cdiv className=\"fw1\"\u003e{item.name}\u003c/div\u003e\n  \u003c/div\u003e\n}\n```\n\n## API\n\n| Attribute      | Type   | Description\n|----------------|--------|------------\n| items          | any[]  | The data that builds the templates within the virtual scroll. This is the same data that you'd pass to ngFor. It's important to note that when this data has changed, then the entire virtual scroll is refreshed.\n| childWidth     | number | The minimum width of the item template's cell. This dimension is used to help determine how many cells should be created when initialized, and to help calculate the height of the scrollable area. Note that the actual rendered size of the first cell is used by default if not specified.\n| childHeight    | number | The minimum height of the item template's cell. This dimension is used to help determine how many cells should be created when initialized, and to help calculate the height of the scrollable area. Note that the actual rendered size of the first cell is used by default if not specified.\n| onStart         | Event  | This event is fired every time `start` reaches 0\n| onEnd           | Event  | This event is fired every time `end` reaches total number of items in `items` array\n| onUpdate         | Event  | This event is fired every time `start` or `end` index change and emits list of items from `start` to `end`. The list emitted by this event must be used with `*ngFor` to render the actual list of items within `\u003cvirtual-scroll\u003e`\n| onChange         | Event  | This event is fired every time `start` or `end` index change and emits `ChangeEvent` which of format: `{ start: number, end: number }`\n\n## Items with variable size\n\nItems must have fixed height and width for this module to work perfectly. However if your list happen to have items with variable width and height, set inputs `childWidth` and `childHeight` to the smallest possible values to make this work.\n\n```jsx\n \u003cVirtualScroll className=\"flx flxw\"\n    items={this.state.items}\n    childWidth={80}\n    childHeight={30}\n    onChange={(event) =\u003e this.setState(event)}\n    renderItem={this.renderItem.bind(this)} /\u003e\n```\n\n## Loading in chunk\n\nThe event `onEnd` is fired every time scroll reaches at the end of the list. You could use this to load more items at the end of the scroll. See below.\n\n```jsx\n  render() {\n  return \u003cVirtualScroll className=\"flx flxw\"\n    items={this.state.items}\n    onEnd={(event) =\u003e this.fetchMore()}\n    renderItem={this.renderItem.bind(this)} /\u003e\n  }\n\n  ....\n\n  fetchMore(event) {\n    if (event.end !== this.buffer.length) return;\n    this.fetchNextChunk(this.buffer.length, 10).then(chunk =\u003e {\n      this.setState(state =\u003e ({ items: state.items.concat(chunk) }))\n    })\n  }\n\n  fetchNextChunk(skip: number, limit: number): Promise\u003cListItem[]\u003e {\n    return new Promise((resolve, reject) =\u003e {\n        ....\n    });\n  }\n}\n```\n\n## If container size change\n\nIf virtual scroll is used within a dropdown or collapsible menu, virtual scroll needs to know when the container size change. Use `refresh()` function after container is resized (include time for animation as well).\n\n## Sorting Items\n\nAlways be sure to send an immutable copy of items to virtual scroll to avoid unintended behavior. You need to be careful when doing non-immutable operations such as sorting:\n\n```ts\nsort() {\n  this.setState(state =\u003e ({\n    items: [].concat(state.items || []).sort()\n  }))\n}\n```\n\nThis will be deprecated once [Resize Observer](https://wicg.github.io/ResizeObserver/) is fully implemented.\n\n## Contributing\nContributions are very welcome! Just send a pull request. Feel free to contact me or checkout my [GitHub](https://github.com/rintoj) page.\n\n## Author\n\n**Rinto Jose** (rintoj)\n\n### Hope this module is helpful to you. If you are looking for Angular version please check [https://github.com/rintoj/angular2-virtual-scroll](https://github.com/rintoj/angular2-virtual-scroll) Please make sure to checkout my other [projects](https://github.com/rintoj) and [articles](https://medium.com/@rintoj). Enjoy coding!\n\nFollow me:\n  [GitHub](https://github.com/rintoj)\n| [Facebook](https://www.facebook.com/rinto.jose)\n| [Twitter](https://twitter.com/rintoj)\n| [Google+](https://plus.google.com/+RintoJoseMankudy)\n| [Youtube](https://youtube.com/+RintoJoseMankudy)\n\n## Versions\n[Check CHANGELOG](https://github.com/rintoj/react-virtualscroll/blob/master/CHANGELOG.md)\n\n## License\n```\nThe MIT License (MIT)\n\nCopyright (c) 2016 Rinto Jose (rintoj)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frintoj%2Freact-virtualscroll","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frintoj%2Freact-virtualscroll","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frintoj%2Freact-virtualscroll/lists"}