A module used to arrange elements including content infinitely according to grid type. With this module, you can implement various grids composed of different card elements whose sizes vary. It guarantees performance by maintaining the number of DOMs the module is handling under any circumstance
📱💻🖥
Supported Frameworks
-----
## ✨ Features
- Use it in a framework you like.
- We supports all major JS frameworks like React, Vue, Angular
- Restore state like position and active slide with [persist](https://naver.github.io/egjs-persist/)
- Supports both Desktop & Mobile
- Support Dynamic Options
- Rich API
## 📖 Articles
* [InfiniteGrid 4 Release!!](https://medium.com/naver-fe-platform/infinitegrid-4-release-f4e2d05b0292)
## ⚙️ Installation
#### npm
```bash
$ npm install --save @egjs/infinitegrid
```
#### CDN
- jsDelivr: https://cdn.jsdelivr.net/npm/@egjs/infinitegrid/dist/
- unpkg: https://unpkg.com/@egjs/infinitegrid/dist/
- cdnjs: https://cdnjs.com/libraries/egjs-infinitegrid
## 🏃 Quick Start
#### HTML
```html
```
#### ES Modules
```ts
import { MasonryInfiniteGrid } from "@egjs/infinitegrid";
const ig = new MasonryInfiniteGrid(".container", { gap: 5 });
```
#### With CDN
```html
```
```js
var ig = new InfiniteGrid.MasonryInfiniteGrid(".container", { gap: 5 });
```
```js
import { MasonryInfiniteGrid } from "@egjs/infinitegrid";
function getItems(nextGroupKey, count) {
const nextItems = [];
for (let i = 0; i < count; ++i) {
const num = nextGroupKey * count + i;
nextItems.push(``);
}
return nextItems;
}
const ig = new MasonryInfiniteGrid(".container", {
gap: 5,
});
ig.on("requestAppend", (e) => {
const nextGroupKey = (+e.groupKey || 0) + 1;
ig.append(getItems(nextGroupKey, 10), nextGroupKey);
});
ig.renderItems();
```
### Use Faster & Lazy Rendering
* When the `loading="lazy"` or `data-grid-lazy="true"`(external lazy loading) attribute is used, Rendering of the items occurs immediately. When items are loaded, they are rendered sequentially.
```html
```
* If you use `data-grid-width` and `data-grid-height` attributes, the size of self, child image, and video elements is automatically adjusted until loading is complete.
```html
```
* If you use `data-grid-skip="true"` attribute, you can omit it even if there are images in itself and child image, and video elements.
```html
```
### Detect resize of Container & Children
InfiniteGrid calculates the size of container and children by window resizing event. However, even if the size of the window does not change, the size of the event container and children can change. Most of the first rendering issues are also like this.
In this case, I recommend [ResizeObserver](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver) for you.
Provides `useResizeObserver` option to detect size change of container and `observeChildren` option to detect size change of children.
```js
import { MasonryInfiniteGrid, JustifiedInfiniteGrid, FrameInfiniteGrid, PackingInfiniteGrid } from "@egjs/infinitegrid";
// InfiniteGrid.MasonryInfiniteGrid
const grid = new MasonryInfiniteGrid(container, {
gap: 5,
useResizeObserver: true,
observeChildren: true,
});
grid.renderItems();
```
## 📦 Packages
|Package|Version|Description|
|:-----:|:-----:|:-----:|
|[**@egjs/infinitegrid**](https://github.com/naver/egjs-infinitegrid/blob/master/packages/infinitegrid/README.md)||Vanilla Module of InfiniteGrid|
|[**@egjs/ngx-infinitegrid**](https://github.com/naver/egjs-infinitegrid/blob/master/packages/ngx-infinitegrid/README.md)|| [Angular](https://angular.io/) port of @egjs/infinitegrid|
|[**@egjs/react-infinitegrid**](https://github.com/naver/egjs-infinitegrid/blob/master/packages/react-infinitegrid/README.md)|| [React](https://reactjs.org/) port of @egjs/infinitegrid|
|[**@egjs/vue-infinitegrid**](https://github.com/naver/egjs-infinitegrid/blob/master/packages/vue-infinitegrid/README.md)|| [Vue.js@2](https://vuejs.org/v2/guide/index.html) port of @egjs/infinitegrid|
|[**@egjs/vue3-infinitegrid**](https://github.com/naver/egjs-infinitegrid/blob/master/packages/vue3-infinitegrid/README.md)|| [Vue.js@3](https://v3.vuejs.org/) port of @egjs/infinitegrid|
|[**@egjs/svelte-infinitegrid**](https://github.com/naver/egjs-infinitegrid/blob/master/packages/svelte-infinitegrid/README.md)|| [Svelte](https://svelte.dev/) port of @egjs/infinitegrid|
## 🌐 Supported Browsers
|||||||
|:---:|:---:|:---:|:---:|:---:|:---:|
|9+(With polyfill), 11+ for Angular & Svelte|Latest|Latest|Latest|7+|4+|
## 📼 Demos
Check our [Demos](https://naver.github.io/egjs-infinitegrid/).
## 📖 Documentation
See [Documentation](https://naver.github.io/egjs-infinitegrid/release/latest/doc/index.html) page.
## 🙌 Contributing
See [CONTRIBUTING.md](https://github.com/naver/egjs-infinitegrid/blob/master/CONTRIBUTING.md).
## 📝 Feedback
Please file an [Issue](https://github.com/naver/egjs-infinitegrid/issues).
## 🛣️ Roadmap
See our [Roadmap](https://github.com/naver/egjs-infinitegrid/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%F0%9F%9B%A3%EF%B8%8FRoadmap+).
## 📜 License
@egjs/infinitegrid is released under the [MIT license](https://github.com/naver/egjs-infinitegrid/blob/master/LICENSE).
```
Copyright (c) 2015-present NAVER Corp.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
```