百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
E

egjs-infinitegrid

> 前端框架
开源

一个用于在网格布局中无限排列卡片元素(包括内容)的模块。

2.4K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

一个用于在网格布局中无限排列卡片元素(包括内容)的模块。


@egjs/infinitegrid

 

Demo / Documentation / Other components

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
  • Supports both Desktop & Mobile
  • Support Dynamic Options
  • Rich API

Articles

  • InfiniteGrid 4 Release!!

⚙️ 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

xml

ES Modules

typescript
import { MasonryInfiniteGrid } from "@egjs/infinitegrid";

const ig = new MasonryInfiniteGrid(".container", { gap: 5 });

With CDN

xml

<script src="https://unpkg.com/@egjs/infinitegrid/dist/infinitegrid.min.js"></script>
javascript
var ig = new InfiniteGrid.MasonryInfiniteGrid(".container", { gap: 5 });
javascript
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.
xml
  • 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.
xml
  • 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.
xml

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 for you.

Provides useResizeObserver option to detect size change of container and observeChildren option to detect size change of children.

javascript
import { MasonryInfiniteGrid, JustifiedInfiniteGrid, FrameInfiniteGrid, PackingInfiniteGrid } from "@egjs/infinitegrid";

// InfiniteGrid.MasonryInfiniteGrid
const grid = new MasonryInfiniteGrid(container, {
  gap: 5,
  useResizeObserver: true,
  observeChildren: true,
});

grid.renderItems();

Pre-guess size for performance or invisible items.

What if all items were the same size?

If you use the isEqualSize option, all items are considered to be the same size. Each resize only calculates the size of one item. Add data-grid-not-equal-size="true" attribute if there is an exceptional item whose size needs to be calculated while using isEqualSize.

xml

What if a size group exists?

isEqualSize assumes all items are equal. But if there are more than two size-groups, use data-grid-size-group.

xml

What if all items don't change size?

If all items do not have a constant size, use the isConstantSize option. Resizing doesn't calculate the item's size. If you want to recalculate, use .updateItems(items, { useOrgResize: true }) method or .renderItems({ useOrgResize: true }) method.

Packages

Package Version Description
@egjs/infinitegrid Vanilla Module of InfiniteGrid
@egjs/ngx-infinitegrid Angular port of @egjs/infinitegrid
@egjs/react-infinitegrid React port of @egjs/infinitegrid
@egjs/vue-infinitegrid Vue.js@2 port of @egjs/infinitegrid
@egjs/vue3-infinitegrid Vue.js@3 port of @egjs/infinitegrid
@egjs/svelte-infinitegrid Svelte port of @egjs/infinitegrid

Supported Browsers

9+(With polyfill), 11+ for Angular & Svelte Latest Latest Latest 7+ 4+

Demos

Check our Demos.

Documentation

See Documentation page.

Contributing

See CONTRIBUTING.md.

Feedback

Please file an Issue.

️ Roadmap

See our Roadmap.

License

@egjs/infinitegrid is released under the MIT license.

…

      

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptangluardom-recycleegjsgrid

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架