React 列表虚拟化如何实现使用 CSS Grid 布局的同时支持拖动元素?

1 月 15 日
 TrackBack

开源的几乎所有虚拟化库都是要么支持单列列表,要么支持显式指定列数的网格(类似表格), 都没法处理 css grid 这种本质上是一维表格但是一行有多个元素的情况 魔改一番用上了,要么高度计算总是出问题,要么和拖拽不兼容

这个场景应该是很常见的需求吧?什么文件浏览不是应该都会用到? 开发者工具看了下几家大厂的页面,居然都是 media query 按宽度直接设置 grid 布局列数。。。

各位大佬有优雅一点的原生支持 css grid 的方案吗

1306 次点击
所在节点    React
2 条回复
shunia
1 月 15 日
问 AI:

2. TanStack Virtual
A headless virtualization utility that is highly flexible because it does not provide its own UI components. It allows you to build custom grid layouts, including responsive grids with aspect ratios.

Grid Support: Excellent for complex or "sticky" table grids where you need full control over the DOM structure.
Framework Agnostic: While used heavily in React, it can also work with other frameworks if needed.
Chuckle
1 月 15 日
看看这个表格?用的就是 css-grid https://comcast.github.io/react-data-grid

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1185833

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX