vane-waterfall 1.0.5 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/README.md +174 -365
  2. package/dist/chunks/WaterfallCore-BSXw7bl_.js +581 -0
  3. package/dist/chunks/doc-3Fpag2G8.js +84 -0
  4. package/dist/chunks/doc-78xF08vt.js +82 -0
  5. package/dist/chunks/doc-B-7dugGv.js +79 -0
  6. package/dist/chunks/doc-B6kLfMPv.js +121 -0
  7. package/dist/chunks/doc-BCGQ8Cp5.js +114 -0
  8. package/dist/chunks/doc-BIzjYAZW.js +50 -0
  9. package/dist/chunks/doc-BP0DmB7-.js +91 -0
  10. package/dist/chunks/doc-BXElhF2h.js +138 -0
  11. package/dist/chunks/doc-BXSy2aPP.js +59 -0
  12. package/dist/chunks/doc-BfWnfTst.js +83 -0
  13. package/dist/chunks/doc-BtzhgTYj.js +85 -0
  14. package/dist/chunks/doc-C5xrHNoC.js +70 -0
  15. package/dist/chunks/doc-CBHjiDG7.js +88 -0
  16. package/dist/chunks/doc-CTUoMe7o.js +79 -0
  17. package/dist/chunks/doc-CcPFavOs.js +56 -0
  18. package/dist/chunks/doc-CraXjOaA.js +68 -0
  19. package/dist/chunks/doc-DElLNjIc.js +61 -0
  20. package/dist/chunks/doc-DJjxOYzW.js +111 -0
  21. package/dist/chunks/doc-DukOmDCo.js +95 -0
  22. package/dist/chunks/doc-DzvTrZ13.js +60 -0
  23. package/dist/chunks/doc-NhL4Ux8q.js +125 -0
  24. package/dist/chunks/doc-bTHwfIVb.js +78 -0
  25. package/dist/chunks/doc-f4Uijujv.js +102 -0
  26. package/dist/chunks/doc-gTAsLjVx.js +55 -0
  27. package/dist/chunks/doc-j4W9SUrY.js +76 -0
  28. package/dist/chunks/doc-kTbJE7rY.js +92 -0
  29. package/dist/chunks/index-BAWlVYr3.js +5 -0
  30. package/dist/chunks/index-COaun3nf.js +15 -0
  31. package/dist/chunks/index-DXAtA2f6.js +11 -0
  32. package/dist/chunks/index-DsRLmBW-.js +13 -0
  33. package/dist/chunks/index-gjoCq0yC.js +21 -0
  34. package/dist/chunks/index-wLI6UXkY.js +5 -0
  35. package/dist/chunks/withPlugins-DLoKg4AP.js +559 -0
  36. package/dist/components/WaterfallPlugin/WaterfallCore.d.ts +124 -0
  37. package/dist/components/WaterfallPlugin/WaterfallCore.d.ts.map +1 -0
  38. package/dist/components/WaterfallPlugin/index.d.ts +9 -10
  39. package/dist/components/WaterfallPlugin/index.d.ts.map +1 -0
  40. package/dist/components/WaterfallPlugin/layout.d.ts +41 -0
  41. package/dist/components/WaterfallPlugin/layout.d.ts.map +1 -0
  42. package/dist/components/WaterfallPlugin/plugins/types.d.ts +76 -380
  43. package/dist/components/WaterfallPlugin/plugins/types.d.ts.map +1 -0
  44. package/dist/components/WaterfallPlugin/virtualize.d.ts +62 -0
  45. package/dist/components/WaterfallPlugin/virtualize.d.ts.map +1 -0
  46. package/dist/components/WaterfallPlugin/{plugins/withPlugins.d.ts → withPlugins.d.ts} +4 -2
  47. package/dist/components/WaterfallPlugin/withPlugins.d.ts.map +1 -0
  48. package/dist/custom-plugins/A11yPlugin/create.d.ts +23 -0
  49. package/dist/custom-plugins/A11yPlugin/create.d.ts.map +1 -0
  50. package/dist/custom-plugins/A11yPlugin/doc.json.d.ts +52 -0
  51. package/dist/custom-plugins/A11yPlugin/index.d.ts +11 -0
  52. package/dist/custom-plugins/A11yPlugin/index.d.ts.map +1 -0
  53. package/dist/custom-plugins/A11yPlugin/index.js +5 -0
  54. package/dist/{components/WaterfallPlugin/custom-plugins/Alignment/index.d.ts → custom-plugins/AlignmentPlugin/create.d.ts} +3 -3
  55. package/dist/custom-plugins/AlignmentPlugin/create.d.ts.map +1 -0
  56. package/dist/custom-plugins/AlignmentPlugin/doc.json.d.ts +34 -0
  57. package/dist/custom-plugins/AlignmentPlugin/index.d.ts +11 -0
  58. package/dist/custom-plugins/AlignmentPlugin/index.d.ts.map +1 -0
  59. package/dist/custom-plugins/AlignmentPlugin/index.js +5 -0
  60. package/dist/custom-plugins/AutoColumnPlugin/create.d.ts +18 -0
  61. package/dist/custom-plugins/AutoColumnPlugin/create.d.ts.map +1 -0
  62. package/dist/custom-plugins/AutoColumnPlugin/doc.json.d.ts +50 -0
  63. package/dist/custom-plugins/AutoColumnPlugin/index.d.ts +11 -0
  64. package/dist/custom-plugins/AutoColumnPlugin/index.d.ts.map +1 -0
  65. package/dist/custom-plugins/AutoColumnPlugin/index.js +5 -0
  66. package/dist/{components/WaterfallPlugin/custom-plugins/Bookmark/index.d.ts → custom-plugins/BookmarkPlugin/create.d.ts} +3 -3
  67. package/dist/custom-plugins/BookmarkPlugin/create.d.ts.map +1 -0
  68. package/dist/custom-plugins/BookmarkPlugin/doc.json.d.ts +41 -0
  69. package/dist/custom-plugins/BookmarkPlugin/index.d.ts +11 -0
  70. package/dist/custom-plugins/BookmarkPlugin/index.d.ts.map +1 -0
  71. package/dist/custom-plugins/BookmarkPlugin/index.js +5 -0
  72. package/dist/custom-plugins/ClickAnalyticsPlugin/create.d.ts +25 -0
  73. package/dist/custom-plugins/ClickAnalyticsPlugin/create.d.ts.map +1 -0
  74. package/dist/custom-plugins/ClickAnalyticsPlugin/doc.json.d.ts +41 -0
  75. package/dist/custom-plugins/ClickAnalyticsPlugin/index.d.ts +11 -0
  76. package/dist/custom-plugins/ClickAnalyticsPlugin/index.d.ts.map +1 -0
  77. package/dist/custom-plugins/ClickAnalyticsPlugin/index.js +5 -0
  78. package/dist/{components/WaterfallPlugin/custom-plugins/DebounceLayout/index.d.ts → custom-plugins/DebounceLayoutPlugin/create.d.ts} +3 -3
  79. package/dist/custom-plugins/DebounceLayoutPlugin/create.d.ts.map +1 -0
  80. package/dist/custom-plugins/DebounceLayoutPlugin/doc.json.d.ts +34 -0
  81. package/dist/custom-plugins/DebounceLayoutPlugin/index.d.ts +11 -0
  82. package/dist/custom-plugins/DebounceLayoutPlugin/index.d.ts.map +1 -0
  83. package/dist/custom-plugins/DebounceLayoutPlugin/index.js +5 -0
  84. package/dist/custom-plugins/DragReorderPlugin/create.d.ts +33 -0
  85. package/dist/custom-plugins/DragReorderPlugin/create.d.ts.map +1 -0
  86. package/dist/custom-plugins/DragReorderPlugin/doc.json.d.ts +53 -0
  87. package/dist/custom-plugins/DragReorderPlugin/index.d.ts +11 -0
  88. package/dist/custom-plugins/DragReorderPlugin/index.d.ts.map +1 -0
  89. package/dist/custom-plugins/DragReorderPlugin/index.js +5 -0
  90. package/dist/{components/WaterfallPlugin/custom-plugins/Filter/index.d.ts → custom-plugins/FilterPlugin/create.d.ts} +3 -3
  91. package/dist/custom-plugins/FilterPlugin/create.d.ts.map +1 -0
  92. package/dist/custom-plugins/FilterPlugin/doc.json.d.ts +47 -0
  93. package/dist/custom-plugins/FilterPlugin/index.d.ts +11 -0
  94. package/dist/custom-plugins/FilterPlugin/index.d.ts.map +1 -0
  95. package/dist/custom-plugins/FilterPlugin/index.js +5 -0
  96. package/dist/{components/WaterfallPlugin/custom-plugins/FixedHeight/index.d.ts → custom-plugins/FixedHeightPlugin/create.d.ts} +3 -3
  97. package/dist/custom-plugins/FixedHeightPlugin/create.d.ts.map +1 -0
  98. package/dist/custom-plugins/FixedHeightPlugin/doc.json.d.ts +34 -0
  99. package/dist/custom-plugins/FixedHeightPlugin/index.d.ts +11 -0
  100. package/dist/custom-plugins/FixedHeightPlugin/index.d.ts.map +1 -0
  101. package/dist/custom-plugins/FixedHeightPlugin/index.js +5 -0
  102. package/dist/{components/WaterfallPlugin/custom-plugins/Gap/index.d.ts → custom-plugins/GapPlugin/create.d.ts} +3 -3
  103. package/dist/custom-plugins/GapPlugin/create.d.ts.map +1 -0
  104. package/dist/custom-plugins/GapPlugin/doc.json.d.ts +47 -0
  105. package/dist/custom-plugins/GapPlugin/index.d.ts +11 -0
  106. package/dist/custom-plugins/GapPlugin/index.d.ts.map +1 -0
  107. package/dist/custom-plugins/GapPlugin/index.js +5 -0
  108. package/dist/custom-plugins/GroupingPlugin/create.d.ts +16 -0
  109. package/dist/custom-plugins/GroupingPlugin/create.d.ts.map +1 -0
  110. package/dist/custom-plugins/GroupingPlugin/doc.json.d.ts +40 -0
  111. package/dist/custom-plugins/GroupingPlugin/index.d.ts +11 -0
  112. package/dist/custom-plugins/GroupingPlugin/index.d.ts.map +1 -0
  113. package/dist/custom-plugins/GroupingPlugin/index.js +5 -0
  114. package/dist/custom-plugins/HeatmapAnalyticsPlugin/create.d.ts +31 -0
  115. package/dist/custom-plugins/HeatmapAnalyticsPlugin/create.d.ts.map +1 -0
  116. package/dist/custom-plugins/HeatmapAnalyticsPlugin/doc.json.d.ts +43 -0
  117. package/dist/custom-plugins/HeatmapAnalyticsPlugin/index.d.ts +11 -0
  118. package/dist/custom-plugins/HeatmapAnalyticsPlugin/index.d.ts.map +1 -0
  119. package/dist/custom-plugins/HeatmapAnalyticsPlugin/index.js +5 -0
  120. package/dist/custom-plugins/InfiniteScrollPlugin/create.d.ts +17 -0
  121. package/dist/custom-plugins/InfiniteScrollPlugin/create.d.ts.map +1 -0
  122. package/dist/custom-plugins/InfiniteScrollPlugin/doc.json.d.ts +44 -0
  123. package/dist/custom-plugins/InfiniteScrollPlugin/index.d.ts +11 -0
  124. package/dist/custom-plugins/InfiniteScrollPlugin/index.d.ts.map +1 -0
  125. package/dist/custom-plugins/InfiniteScrollPlugin/index.js +5 -0
  126. package/dist/{components/WaterfallPlugin/custom-plugins/Pagination/index.d.ts → custom-plugins/PaginationPlugin/create.d.ts} +3 -3
  127. package/dist/custom-plugins/PaginationPlugin/create.d.ts.map +1 -0
  128. package/dist/custom-plugins/PaginationPlugin/doc.json.d.ts +50 -0
  129. package/dist/custom-plugins/PaginationPlugin/index.d.ts +11 -0
  130. package/dist/custom-plugins/PaginationPlugin/index.d.ts.map +1 -0
  131. package/dist/custom-plugins/PaginationPlugin/index.js +5 -0
  132. package/dist/custom-plugins/PinItemPlugin/create.d.ts +23 -0
  133. package/dist/custom-plugins/PinItemPlugin/create.d.ts.map +1 -0
  134. package/dist/custom-plugins/PinItemPlugin/doc.json.d.ts +43 -0
  135. package/dist/custom-plugins/PinItemPlugin/index.d.ts +11 -0
  136. package/dist/custom-plugins/PinItemPlugin/index.d.ts.map +1 -0
  137. package/dist/custom-plugins/PinItemPlugin/index.js +5 -0
  138. package/dist/{components/WaterfallPlugin/custom-plugins/Recycle/index.d.ts → custom-plugins/RecyclePlugin/create.d.ts} +3 -3
  139. package/dist/custom-plugins/RecyclePlugin/create.d.ts.map +1 -0
  140. package/dist/custom-plugins/RecyclePlugin/doc.json.d.ts +35 -0
  141. package/dist/custom-plugins/RecyclePlugin/index.d.ts +11 -0
  142. package/dist/custom-plugins/RecyclePlugin/index.d.ts.map +1 -0
  143. package/dist/custom-plugins/RecyclePlugin/index.js +5 -0
  144. package/dist/custom-plugins/ReducedMotionPlugin/create.d.ts +25 -0
  145. package/dist/custom-plugins/ReducedMotionPlugin/create.d.ts.map +1 -0
  146. package/dist/custom-plugins/ReducedMotionPlugin/doc.json.d.ts +42 -0
  147. package/dist/custom-plugins/ReducedMotionPlugin/index.d.ts +11 -0
  148. package/dist/custom-plugins/ReducedMotionPlugin/index.d.ts.map +1 -0
  149. package/dist/custom-plugins/ReducedMotionPlugin/index.js +5 -0
  150. package/dist/custom-plugins/ResponsiveColumnsPlugin/create.d.ts +22 -0
  151. package/dist/custom-plugins/ResponsiveColumnsPlugin/create.d.ts.map +1 -0
  152. package/dist/custom-plugins/ResponsiveColumnsPlugin/doc.json.d.ts +37 -0
  153. package/dist/custom-plugins/ResponsiveColumnsPlugin/index.d.ts +10 -0
  154. package/dist/custom-plugins/ResponsiveColumnsPlugin/index.d.ts.map +1 -0
  155. package/dist/custom-plugins/ResponsiveColumnsPlugin/index.js +5 -0
  156. package/dist/{components/WaterfallPlugin/custom-plugins/ScrollAnchor/index.d.ts → custom-plugins/ScrollAnchorPlugin/create.d.ts} +3 -3
  157. package/dist/custom-plugins/ScrollAnchorPlugin/create.d.ts.map +1 -0
  158. package/dist/custom-plugins/ScrollAnchorPlugin/doc.json.d.ts +34 -0
  159. package/dist/custom-plugins/ScrollAnchorPlugin/index.d.ts +11 -0
  160. package/dist/custom-plugins/ScrollAnchorPlugin/index.d.ts.map +1 -0
  161. package/dist/custom-plugins/ScrollAnchorPlugin/index.js +5 -0
  162. package/dist/{components/WaterfallPlugin/custom-plugins/Search/index.d.ts → custom-plugins/SearchPlugin/create.d.ts} +3 -3
  163. package/dist/custom-plugins/SearchPlugin/create.d.ts.map +1 -0
  164. package/dist/custom-plugins/SearchPlugin/doc.json.d.ts +47 -0
  165. package/dist/custom-plugins/SearchPlugin/index.d.ts +11 -0
  166. package/dist/custom-plugins/SearchPlugin/index.d.ts.map +1 -0
  167. package/dist/custom-plugins/SearchPlugin/index.js +5 -0
  168. package/dist/{components/WaterfallPlugin/custom-plugins/Sort/index.d.ts → custom-plugins/SortPlugin/create.d.ts} +3 -3
  169. package/dist/custom-plugins/SortPlugin/create.d.ts.map +1 -0
  170. package/dist/custom-plugins/SortPlugin/doc.json.d.ts +46 -0
  171. package/dist/custom-plugins/SortPlugin/index.d.ts +11 -0
  172. package/dist/custom-plugins/SortPlugin/index.d.ts.map +1 -0
  173. package/dist/custom-plugins/SortPlugin/index.js +5 -0
  174. package/dist/{components/WaterfallPlugin/custom-plugins/StatePersistence/index.d.ts → custom-plugins/StatePersistencePlugin/create.d.ts} +3 -3
  175. package/dist/custom-plugins/StatePersistencePlugin/create.d.ts.map +1 -0
  176. package/dist/custom-plugins/StatePersistencePlugin/doc.json.d.ts +47 -0
  177. package/dist/custom-plugins/StatePersistencePlugin/index.d.ts +11 -0
  178. package/dist/custom-plugins/StatePersistencePlugin/index.d.ts.map +1 -0
  179. package/dist/custom-plugins/StatePersistencePlugin/index.js +5 -0
  180. package/dist/custom-plugins/StickyHeaderPlugin/create.d.ts +13 -0
  181. package/dist/custom-plugins/StickyHeaderPlugin/create.d.ts.map +1 -0
  182. package/dist/custom-plugins/StickyHeaderPlugin/doc.json.d.ts +40 -0
  183. package/dist/custom-plugins/StickyHeaderPlugin/index.d.ts +11 -0
  184. package/dist/custom-plugins/StickyHeaderPlugin/index.d.ts.map +1 -0
  185. package/dist/custom-plugins/StickyHeaderPlugin/index.js +5 -0
  186. package/dist/{components/WaterfallPlugin/custom-plugins/Throttle/index.d.ts → custom-plugins/ThrottlePlugin/create.d.ts} +3 -3
  187. package/dist/custom-plugins/ThrottlePlugin/create.d.ts.map +1 -0
  188. package/dist/custom-plugins/ThrottlePlugin/doc.json.d.ts +40 -0
  189. package/dist/custom-plugins/ThrottlePlugin/index.d.ts +11 -0
  190. package/dist/custom-plugins/ThrottlePlugin/index.d.ts.map +1 -0
  191. package/dist/custom-plugins/ThrottlePlugin/index.js +5 -0
  192. package/dist/{components/WaterfallPlugin/custom-plugins/Transition/index.d.ts → custom-plugins/TransitionPlugin/create.d.ts} +3 -3
  193. package/dist/custom-plugins/TransitionPlugin/create.d.ts.map +1 -0
  194. package/dist/custom-plugins/TransitionPlugin/doc.json.d.ts +43 -0
  195. package/dist/custom-plugins/TransitionPlugin/index.d.ts +11 -0
  196. package/dist/custom-plugins/TransitionPlugin/index.d.ts.map +1 -0
  197. package/dist/custom-plugins/TransitionPlugin/index.js +5 -0
  198. package/dist/{components/WaterfallPlugin/custom-plugins/URLSync/index.d.ts → custom-plugins/URLSyncPlugin/create.d.ts} +3 -3
  199. package/dist/custom-plugins/URLSyncPlugin/create.d.ts.map +1 -0
  200. package/dist/custom-plugins/URLSyncPlugin/doc.json.d.ts +41 -0
  201. package/dist/custom-plugins/URLSyncPlugin/index.d.ts +11 -0
  202. package/dist/custom-plugins/URLSyncPlugin/index.d.ts.map +1 -0
  203. package/dist/custom-plugins/URLSyncPlugin/index.js +5 -0
  204. package/dist/custom-plugins/index.d.ts +61 -0
  205. package/dist/custom-plugins/index.d.ts.map +1 -0
  206. package/dist/custom-plugins/index.js +34 -0
  207. package/dist/entries/core.d.ts +8 -0
  208. package/dist/entries/core.d.ts.map +1 -0
  209. package/dist/entries/core.js +7 -0
  210. package/dist/entries/plugins.d.ts +7 -0
  211. package/dist/entries/plugins.d.ts.map +1 -0
  212. package/dist/entries/plugins.js +36 -0
  213. package/dist/index.d.ts +14 -9
  214. package/dist/index.d.ts.map +1 -0
  215. package/dist/index.js +8 -0
  216. package/dist/presets/dashboard/index.d.ts +13 -0
  217. package/dist/presets/dashboard/index.d.ts.map +1 -0
  218. package/dist/presets/dashboard/index.js +21 -0
  219. package/dist/presets/photo-feed/index.d.ts +13 -0
  220. package/dist/presets/photo-feed/index.d.ts.map +1 -0
  221. package/dist/presets/photo-feed/index.js +17 -0
  222. package/dist/presets/product-feed/index.d.ts +9 -0
  223. package/dist/presets/product-feed/index.d.ts.map +1 -0
  224. package/dist/presets/product-feed/index.js +23 -0
  225. package/package.json +221 -82
  226. package/dist/404.jpg +0 -0
  227. package/dist/components/WaterfallPlugin/core/WaterfallCore.d.ts +0 -174
  228. package/dist/components/WaterfallPlugin/custom-plugins/A11y/index.d.ts +0 -16
  229. package/dist/components/WaterfallPlugin/custom-plugins/AutoColumn/index.d.ts +0 -17
  230. package/dist/components/WaterfallPlugin/custom-plugins/ClickAnalytics/index.d.ts +0 -12
  231. package/dist/components/WaterfallPlugin/custom-plugins/DragReorder/index.d.ts +0 -13
  232. package/dist/components/WaterfallPlugin/custom-plugins/Grouping/index.d.ts +0 -12
  233. package/dist/components/WaterfallPlugin/custom-plugins/HeatmapAnalytics/index.d.ts +0 -14
  234. package/dist/components/WaterfallPlugin/custom-plugins/InfiniteScroll/index.d.ts +0 -13
  235. package/dist/components/WaterfallPlugin/custom-plugins/PinItem/index.d.ts +0 -13
  236. package/dist/components/WaterfallPlugin/custom-plugins/ReducedMotion/index.d.ts +0 -13
  237. package/dist/components/WaterfallPlugin/custom-plugins/ResponsiveColumns/index.d.ts +0 -10
  238. package/dist/components/WaterfallPlugin/custom-plugins/StickyHeader/index.d.ts +0 -11
  239. package/dist/components/WaterfallPlugin/custom-plugins/VirtualWaterfall/index.d.ts +0 -12
  240. package/dist/components/WaterfallPlugin/custom-plugins/index.d.ts +0 -30
  241. package/dist/components/WaterfallPlugin/plugins/PluginBus.d.ts +0 -2
  242. package/dist/components/WaterfallPlugin/plugins/PluginManager.d.ts +0 -2
  243. package/dist/components/WaterfallPlugin/plugins/index.d.ts +0 -8
  244. package/dist/index.es.js +0 -2382
  245. package/dist/index.umd.js +0 -30
  246. package/dist/vite.svg +0 -1
package/README.md CHANGED
@@ -1,365 +1,174 @@
1
- # 🧱 Vane Waterfall
2
-
3
- 一个功能强大、高度可扩展的 React 瀑布流布局插件式组件库(WaterfallPlugin)
4
-
5
- [![License](https://img.shields.io/badge/license-MIT-green)](./LICENSE)
6
- [![TypeScript](https://img.shields.io/badge/TypeScript-5.x-blue)](https://www.typescriptlang.org/)
7
- [![React](https://img.shields.io/badge/React-18.x-blue)](https://reactjs.org/)
8
-
9
- [在线演示](https://chinavane.netlify.app/) | [快速开始](#快速开始) | [插件列表](#插件列表) | [API 文档](#api-文档)
10
-
11
- ---
12
-
13
- ## ✨ 核心特性
14
-
15
- ### 🔌 插件化架构
16
-
17
- - 基于事件总线的插件系统,支持灵活组合
18
- - 30+ 内置插件,覆盖各种使用场景
19
- - 易于扩展,支持自定义插件开发(如 `calculateItemPosition` 覆盖布局)
20
-
21
- ### 🧱 布局与渲染
22
-
23
- - 多种列分配策略:最矮列、平均列、固定列数、响应式列数
24
- - 支持列间距 `gap` 与容器内边距 `padding`,保证两侧留白参与布局计算
25
- - 过渡动画、固定高度、虚拟化渲染、工作线程布局等
26
-
27
- ### ⚡ 性能优化
28
-
29
- - 布局防抖/节流
30
- - 复用与回收(Recycle)
31
- - 虚拟化(VirtualWaterfall)
32
-
33
- ### 🛡️ 稳健性
34
-
35
- - 书签定位、滚动锚点、粘性头部
36
- - 状态持久化与 URL 同步
37
-
38
- ### ♿ 可访问性与易用性
39
-
40
- - A11y 增强、简洁 API、完善的示例
41
-
42
- ### 📊 监控与分析
43
-
44
- - 热力图/交互分析、滚动性能采集(示例插件)
45
-
46
- ---
47
-
48
- ## 📦 安装
49
-
50
- ### NPM / Yarn / PNPM(作为工程示例运行)
51
-
52
- ```bash
53
- # 安装依赖
54
- npm install
55
-
56
- # 启动开发服务器
57
- npm run dev
58
-
59
- # 构建生产版本
60
- npm run build
61
- ```
62
-
63
- ### 本地开发
64
-
65
- 启动后访问:`http://localhost:3000`。
66
-
67
- ---
68
-
69
- ## 📊 包大小与优化
70
-
71
- ### 模块大小(示意)
72
-
73
- | 模块 | 原始大小 | Gzip 后 | 说明 |
74
- | ---------- | -------- | ------- | ----------------------------------- |
75
- | 核心组件 | ~10 KB | ~3 KB | `WaterfallCore` 仅包含基础布局逻辑 |
76
- | 插件系统 | ~12 KB | ~4 KB | 插件管理器 + 事件总线 |
77
- | 单个插件 | ~2-5 KB | ~1-2 KB | 每个插件平均大小 |
78
- | 完整插件组 | ~80+ KB | ~25 KB | 包含常用插件的组合示例 |
79
-
80
- > 💡 提示:使用按需导入与插件精简组合,可显著降低打包体积。
81
-
82
- ### Tree-Shaking 支持
83
-
84
- 本库完全支持 **Tree-Shaking**,未使用的插件不会被打包到最终产物中。
85
-
86
- #### 为什么支持 Tree-Shaking?
87
-
88
- 1. ESM 模块发布,便于静态分析
89
- 2. 无副作用标记:`"sideEffects": false`
90
- 3. 命名导出,便于按需引用
91
- 4. 插件均为独立模块,可单独引入
92
-
93
- ```json
94
- {
95
- "sideEffects": false,
96
- "module": "dist/index.es.js",
97
- "exports": {
98
- ".": {
99
- "import": "./dist/index.es.js",
100
- "types": "./dist/index.d.ts"
101
- }
102
- }
103
- }
104
- ```
105
-
106
- #### ✅ 支持 Tree-Shaking 的导入方式
107
-
108
- ```tsx
109
- import {
110
- WaterfallCore,
111
- withPlugins,
112
- createAlignmentPlugin,
113
- createTransitionPlugin,
114
- } from "vane-waterfall";
115
-
116
- const Waterfall = withPlugins(WaterfallCore, [
117
- createAlignmentPlugin({ mode: "shortest" }),
118
- createTransitionPlugin({ duration: 180 }),
119
- ]);
120
- ```
121
-
122
- #### ⚠️ 不推荐的导入方式
123
-
124
- ```tsx
125
- // ❌ 不推荐:一次性导入所有插件(会失去 Tree-Shaking 优势)
126
- import * as Waterfall from "vane-waterfall";
127
- ```
128
-
129
- ### 按需导入示例
130
-
131
- #### 方式一:精确导入(最小体积)
132
-
133
- ```tsx
134
- import { WaterfallCore, withPlugins, createAlignmentPlugin, createTransitionPlugin } from "vane-waterfall";
135
- ```
136
-
137
- #### 方式二:分类导入(推荐)
138
-
139
- ```tsx
140
- import {
141
- WaterfallCore,
142
- withPlugins,
143
- createAutoColumnPlugin,
144
- createResponsiveColumnsPlugin,
145
- } from "vane-waterfall";
146
- ```
147
-
148
- #### 方式三:分组导入
149
-
150
- ```tsx
151
- import {
152
- createAlignmentPlugin,
153
- createFixedHeightPlugin,
154
- createGapPlugin,
155
- } from "vane-waterfall";
156
- ```
157
-
158
- ### 不同场景的包大小对比(示意)
159
-
160
- | 使用场景 | 导入插件数 | 预估大小(Gzip) |
161
- | -------------- | ---------- | ---------------- |
162
- | 最小化(仅核心) | 0 | ~3 KB |
163
- | 基础使用 | 2-3 个 | ~8-12 KB |
164
- | 常规项目 | 5-8 个 | ~15-25 KB |
165
- | 功能丰富 | 10-15 个 | ~30-45 KB |
166
-
167
- ### 打包优化建议
168
-
169
- #### 1. 使用动态导入
170
-
171
- ```tsx
172
- const Waterfall = withPlugins(WaterfallCore, [createTransitionPlugin()]);
173
-
174
- async function loadAdvancedPlugins() {
175
- const { createVirtualWaterfallPlugin } = await import("vane-waterfall");
176
- return [createVirtualWaterfallPlugin()];
177
- }
178
- ```
179
-
180
- #### 2. Vite 配置优化
181
-
182
- ```ts
183
- // vite.config.ts(示例)
184
- export default {
185
- build: {
186
- rollupOptions: {
187
- output: {
188
- manualChunks: {
189
- waterfall: ["vane-waterfall"],
190
- },
191
- },
192
- },
193
- },
194
- };
195
- ```
196
-
197
- #### 3. Webpack 配置优化
198
-
199
- ```js
200
- module.exports = {
201
- optimization: {
202
- usedExports: true,
203
- sideEffects: false,
204
- splitChunks: {
205
- cacheGroups: {
206
- waterfall: {
207
- test: /vane-waterfall/,
208
- name: "vane-waterfall",
209
- chunks: "all",
210
- },
211
- },
212
- },
213
- },
214
- };
215
- ```
216
-
217
- ### 验证 Tree-Shaking 效果
218
-
219
- 同样可通过打包分析工具或比较测试文件大小的方式进行验证。
220
-
221
- ### 性能监控
222
-
223
- 可通过示例插件采集滚动与布局时序,或在页面中注入简单统计逻辑。
224
-
225
- ---
226
-
227
- ## 🚀 快速开始
228
-
229
- ### 基础使用
230
-
231
- ```tsx
232
- import { WaterfallCore } from "vane-waterfall";
233
-
234
- <WaterfallCore
235
- items={items}
236
- columns={4}
237
- gap={12}
238
- padding={12}
239
- renderItem={(item) => <div style={{ height: item.height }} />}
240
- />;
241
- ```
242
-
243
- ### 使用插件
244
-
245
- ```tsx
246
- import {
247
- withPlugins,
248
- createAlignmentPlugin,
249
- createAutoColumnPlugin,
250
- createResponsiveColumnsPlugin,
251
- createTransitionPlugin,
252
- } from "vane-waterfall";
253
-
254
- const Waterfall = withPlugins(WaterfallCore, [
255
- createAutoColumnPlugin({ minColumnWidth: 220 }),
256
- createResponsiveColumnsPlugin({
257
- breakpoints: {
258
- xs: { width: 0, columns: 1 },
259
- sm: { width: 640, columns: 2 },
260
- md: { width: 768, columns: 3 },
261
- lg: { width: 1024, columns: 4 },
262
- xl: { width: 1280, columns: 5 },
263
- },
264
- }),
265
- createAlignmentPlugin({ mode: "shortest" }),
266
- createTransitionPlugin({ duration: 180, easing: "ease-out" }),
267
- ]);
268
- ```
269
-
270
- ### 组合示例:性能优化
271
-
272
- ```tsx
273
- const WaterfallPerf = withPlugins(WaterfallCore, [
274
- createTransitionPlugin({ duration: 150 }),
275
- ]);
276
- ```
277
-
278
- ---
279
-
280
- ## 📚 插件列表
281
-
282
- 本项目提供多个开箱即用的插件,按功能分类如下:
283
-
284
- ### 🎨 布局与效果
285
-
286
- `Alignment`、`AutoColumn`、`ResponsiveColumns`、`FixedHeight`、`Gap`、`Transition`
287
-
288
- ### ⚡ 性能与渲染
289
-
290
- `DebounceLayout`、`Recycle`、`VirtualWaterfall`、`WorkerLayout`、`Throttle`
291
-
292
- ### 🛡️ 稳健性与交互
293
-
294
- `Bookmark`、`DragReorder`、`Grouping`、`ScrollAnchor`、`StickyHeader`
295
-
296
- ### 🔧 其他
297
-
298
- `StatePersistence`、`PinItem`、`HeatmapAnalytics`、`A11y`
299
-
300
- > 💡 提示:所有插件位于 `src/components/WaterfallPlugin/custom-plugins/` 目录,可直接查看实现与示例。
301
-
302
- ---
303
-
304
- ## 📂 项目结构
305
-
306
- ```
307
- vane-waterfall/
308
- ├── src/
309
- │ ├── components/
310
- │ │ └── WaterfallPlugin/
311
- │ │ ├── core/
312
- │ │ │ └── WaterfallCore.tsx
313
- │ │ ├── plugins/
314
- │ │ │ ├── types.ts
315
- │ │ │ ├── PluginBus.ts
316
- │ │ │ ├── PluginManager.ts
317
- │ │ │ └── withPlugins.tsx
318
- │ │ ├── custom-plugins/
319
- │ │ │ ├── Alignment/
320
- │ │ │ ├── AutoColumn/
321
- │ │ │ ├── InfiniteScroll/
322
- │ │ │ └── ...
323
- │ │ └── README.md
324
- │ └── pages/
325
- │ └── WaterfallPlugin/
326
- │ └── LazyImageIntegrationDemo.tsx
327
- └── README.md
328
- ```
329
-
330
- ---
331
-
332
- ## 🎯 API 文档
333
-
334
- ### 核心组件:`WaterfallCore`
335
-
336
- #### Props(节选)
337
-
338
- | 属性 | 类型 | 说明 |
339
- | --------------- | ------------------- | --------------------------------- |
340
- | `items` | `any[]` | 数据集合(含高度或可测量高度) |
341
- | `renderItem` | `(item,i)=>ReactNode` | 渲染函数 |
342
- | `columns` | `number` | 列数(可被插件覆盖) |
343
- | `gap` | `number` | 列间距 |
344
- | `padding` | `number` | 容器内边距(参与布局计算) |
345
- | `alignmentMode` | `"shortest"` | 列分配策略 |
346
- | `onReachBottom` | `()=>void` | 触底回调 |
347
-
348
- ### 插件钩子(节选)
349
-
350
- - `beforeLayout`、`afterLayout`
351
- - `calculateItemPosition(item, index)`:返回值可覆盖默认位置
352
-
353
- ---
354
-
355
- ## 🛠️ 开发建议
356
-
357
- - 优先使用 `padding` 控制容器留白,避免仅用 `containerStyle.padding`
358
- - 通过插件扩展行为,保持核心组件简洁稳定
359
- - 大型场景建议结合虚拟化与工作线程布局
360
-
361
- ---
362
-
363
- ## 📜 版权许可
364
-
365
- 本项目以 MIT 许可发布。
1
+ <p align="center">
2
+ <a href="https://www.npmjs.com/package/vane-waterfall"><img src="https://img.shields.io/npm/v/vane-waterfall.svg" alt="npm version" /></a>
3
+ <a href="https://www.npmjs.com/package/vane-waterfall"><img src="https://img.shields.io/npm/dm/vane-waterfall.svg" alt="npm downloads" /></a>
4
+ <a href="https://chinavane.netlify.app/"><img src="https://img.shields.io/badge/demo-online-brightgreen.svg" alt="demo" /></a>
5
+ </p>
6
+ # 瀑布流布局
7
+
8
+ > 瀑布流本身很简单,难的是它旁边那一堆需求:可变高、响应式列数、置顶、分组吸顶、拖拽换位、无限加载、千项虚拟化。这些不该揉进一个 800 行的组件里。
9
+
10
+ `vane-waterfall` 把它们拆成 **26 个领域插件**,`WaterfallCore` 只负责「测量 + 布局 + 滚动」。
11
+
12
+ ## 特性
13
+
14
+ - **布局是纯函数**:`computeLayout` 不碰 DOM,可以直接对数字快照做等价性单测(8 组断言锁住旧行为)
15
+ - **布局钩子有执行点**:`calculateColumns` / `calculateColumnWidth` / `calculateItemPosition` 三个钩子真的会被调用(旧版声明了但从不执行,插件因此空转)
16
+ - **虚拟化只裁渲染**:未渲染项按估值占位(默认跟实测样本的中位数走),总高不缩水、滚动条不跳
17
+ - **量到就重排**:项挂载量到真高与位置不一致时,下一帧立刻修正,不等布局防抖 —— 这是「快速滚动时卡片重叠」的真正解法(抬高估值只是把误差换成滚动条虚长)
18
+ - **钩子有生命周期**:`onMount` 返回的函数会在卸载时执行,监听不会泄漏
19
+ - **priority 越大越先执行**:与旧版语义同向,不做 `1000 - x` 反转
20
+ - **零运行时依赖**(`vane-plugin-core` / react / react-dom 均为 peer),不引 CSS 文件
21
+
22
+ ## 安装
23
+
24
+ ```bash
25
+ npm install vane-waterfall
26
+ ```
27
+
28
+ ## 30 秒上手
29
+
30
+ ```tsx
31
+ import { WaterfallCore, withPlugins } from "vane-waterfall";
32
+ import { createAutoColumnPlugin } from "vane-waterfall/custom-plugins/AutoColumnPlugin";
33
+ import { createGapPlugin } from "vane-waterfall/custom-plugins/GapPlugin";
34
+
35
+ // 装配:一个组件类型,模块顶层调一次
36
+ const Waterfall = withPlugins(WaterfallCore, [
37
+ createAutoColumnPlugin({ minColumnWidth: 220, maxColumns: 4 }),
38
+ createGapPlugin({ columnGap: 16, rowGap: 16 }),
39
+ ]);
40
+
41
+ // 使用:和普通列表组件一样
42
+ export function Feed({ items }: { items: Item[] }) {
43
+ return (
44
+ <Waterfall
45
+ items={items}
46
+ containerStyle={{ height: "100vh" }}
47
+ keyExtractor={(item) => item.id}
48
+ renderItem={(item) => <Card data={item} />}
49
+ />
50
+ );
51
+ }
52
+ ```
53
+
54
+ 容器必须有确定高度(或由父级撑开),否则没有滚动上下文,虚拟化与 `onReachBottom` 都不会触发。
55
+
56
+ ## 导入方式与体积
57
+
58
+ | 导入 | 内容 | 实测 Gzip |
59
+ | --- | --- | --- |
60
+ | `vane-waterfall` | 核心 + 装配 + 类型(不含任何插件) | **10.5 KB** |
61
+ | `vane-waterfall/core` | 同上,语义化别名 | 10.5 KB |
62
+ | `vane-waterfall/plugins` | 装配层 + 领域类型 + 26 个插件(逃生口,常规不推荐) | 大,仅在「全都要」时用 |
63
+ | `vane-waterfall/custom-plugins/XxxPlugin` | 单个插件 | 0.3–1.2 KB |
64
+ | `vane-waterfall/presets/X` | 场景配方(3 选 1) | 0.3 KB + 插件本体 |
65
+
66
+ 单文件实测:`WaterfallCore` 4.68 KB gzip、`withPlugins` 5.62 KB gzip。
67
+
68
+ > 根入口**不桶导出插件**——插件请走子路径,未引入的不进产物。插件目录见 [插件](plugins.md),现成组合见 [组合配方](recipes.md)。
69
+
70
+ ## 包内有什么
71
+
72
+ ```
73
+ WaterfallCore 测量 / 布局 / 滚动 / ref 契约,不含业务行为
74
+ withPlugins 装配层:内核 runtime + 领域上下文 + Core 回调桥接
75
+ layout.ts computeLayout 纯函数(含 3 个布局钩子执行点)
76
+ virtualize.ts computeVisibleRange + 占位高度策略(resolveEstimateHeight)
77
+ custom-plugins/ 26 个领域插件(5 组)
78
+ presets/ photo-feed / product-feed / dashboard
79
+ demo/ 演示站:34 页逐项示例 + 工坊 + 13 场景(不随包发布)
80
+ ```
81
+
82
+ ## 插件目录速览
83
+
84
+ | 组 | 插件 | 说明 |
85
+ | --- | --- | --- |
86
+ | 布局 | AutoColumn / ResponsiveColumns / Alignment / Gap / FixedHeight / PinItem | 列数与列宽、间距、等高、置顶 |
87
+ | 性能与动效 | Throttle / DebounceLayout / Transition / ReducedMotion | 滚动节流、布局防抖、位移过渡 |
88
+ | 数据管线 | Filter / Sort / Search / Pagination / InfiniteScroll | 固定顺序 `40 → 30 → 20 → 10` |
89
+ | 交互与埋点 | ClickAnalytics / HeatmapAnalytics / DragReorder / ScrollAnchor / Recycle | 点击与曝光统计、拖拽、锚点、离屏回收 |
90
+ | 语义与状态 | A11y / Grouping / StickyHeader / Bookmark / StatePersistence / URLSync | 可访问性、分组、吸顶、位置书签、状态与 URL 同步 |
91
+
92
+ 完整配置项见 [插件](plugins.md)。
93
+
94
+ ## 虚拟化的估值策略
95
+
96
+ 虚拟化只渲染视口附近的项,**没渲染的项测不到高度**,只能用估值占位。这是它唯一算不准的地方,也是最容易翻车的地方:
97
+
98
+ | 估值偏低 | 估值偏高 |
99
+ | --- | --- |
100
+ | 同一列后面按估值排的项会压上来 —— 卡片重叠 | 总高虚长,滚动条比实际长 |
101
+
102
+ 默认策略(`adaptiveEstimate: true`):
103
+
104
+ - **`estimateHeight` 只是冷启动兜底**:还没有实测样本时用它,样本够 8 个就不再看了;
105
+ - **改用实测样本的中位数**:中位数让「总高 = 所有项高度之和」的误差最小。实测 1000 项、项高 190–350 的数据集,中位数估值下总高 95337px,实际 94700px(+0.7%);换成 P90 会虚长到 117225px(+24%),滚动条一眼就不对;
106
+ - **重叠不靠抬高估值解决**:真正管用的是「量到真高就立刻重排」(一帧内合并,不等布局防抖)。实测快速滚动 20 屏,可见重叠 0 帧;拖动滚动条瞬移时最多十来帧(≤0.2s)、峰值 60px,停手即收敛,停手即收敛;
107
+ - **`estimateQuantile` 可调**:项高分布极离散时往上调(0.9 / 1),代价是总高偏大。
108
+
109
+ ```ts
110
+ // 默认:自适应中位数
111
+ virtualize={{ overscan: 1 }}
112
+
113
+ // 项等高(商品卡)→ 估值就是精确值,关掉自适应更省一次采样
114
+ virtualize={{ estimateHeight: 320, adaptiveEstimate: false }}
115
+
116
+ // 项高分布极离散,宁可留空也不要重叠
117
+ virtualize={{ estimateQuantile: 0.95 }}
118
+ ```
119
+
120
+ 演示站的两个能力页把这几个参数做成了控件:`#/demo/virtual`(虚拟瀑布流)与 `#/demo/virtual-dynamic`(动态高度)—— 拖分位、关自适应,都能当场看到总高与重叠的变化。
121
+
122
+ ## 从 1.x 迁移
123
+
124
+ 2.0.0 是破坏性大版本,插件系统内核已换成 `vane-plugin-core`(与 `vane-lazy-image` 同一套):
125
+
126
+ | 变化 | 影响 | 怎么改 |
127
+ | --- | --- | --- |
128
+ | 插件系统换成内核 | 自建 `PluginBus` / `PluginManager` 删除 | 不要再 import 它们;`withPlugins` / `Plugin` 从包里取 |
129
+ | 钩子面 48 → 20 | 31 个从未被执行过的钩子删除 | 按 [API](api.md) 的钩子表逐个核对,被删的钩子本来也没生效 |
130
+ | 插件状态与清理 | `onMount` 返回值统一当清理函数 | 把 `unsubscribe` 逻辑放进返回的函数 |
131
+ | 虚拟化下沉 Core | `VirtualWaterfallPlugin` 删除 | 去掉插件,改传 `virtualize` |
132
+ | 多入口 | 插件不再桶导出进根入口 | `import { createXxxPlugin } from "vane-waterfall/custom-plugins/XxxPlugin"` |
133
+ | 事件语义 | `priority` **同向**(大 = 先执行) | 与 1.x 一致,不要按 `vane-lazy-image` 的 `1000 - x` 去改 |
134
+ | `renderItemWrapper` 签名 | 统一为 `(context, node, index)` | 旧版 A11y 与 DragReorder 顺序相反,需按新签名改 |
135
+ | `reachBottomOffset` | 由 props 控制(默认 100) | 无限滚动用 `InfiniteScrollPlugin({ threshold })`,不再写死 |
136
+
137
+ ## 在线示例
138
+
139
+ 演示站是三种视角,各管一件事:
140
+
141
+ | 页面 | 数量 | 解决什么 |
142
+ | --- | --- | --- |
143
+ | **逐项示例** | 34 页 | 一插件一页:拖参数看行为变化,装配代码跟着参数实时变 |
144
+ | **插件工坊** | 26 插件 | 组合实验台:勾选任意组合,现场看冲突提示并生成装配代码 |
145
+ | **场景库** | 13 版式 | 组合视角:真实版式(图文 / 电商 / 视频 / 看板 / 长文…),每卡两份源码 |
146
+
147
+ 逐项示例分三组,与 [API](api.md) 的钩子表一一对得上:
148
+
149
+ - **基础功能**(3):基础示例、自定义列数、自定义间距 —— 只用 Core props
150
+ - **高级功能**(3):Ref 方法调用(13 个方法逐个点)、生命周期和事件(13 个回调接满)、高级配置(padding / useTransform / alignmentMode / 节流防抖)
151
+ - **插件功能**(28):26 个插件各一页,另有 2 页是内核能力(虚拟瀑布流 / 动态高度虚拟化)
152
+
153
+ 每页固定四块:一句话 + 什么时候用 → 参数控件 → 可交互舞台(含事件日志 / 读数条)→ 通栏代码(最小装配 / 完整源码)。
154
+
155
+ 本地跑:
156
+
157
+ ```bash
158
+ pnpm --filter vane-waterfall dev # 开发(端口 3300)
159
+ pnpm --filter vane-waterfall demo # 构建 + 静态托管 demo-dist
160
+ pnpm --filter vane-waterfall verify:scenarios # 目录 / 源码 / 插件名一致性闸门(场景 + 示例)
161
+ PLAYWRIGHT_PATH=<playwright> node scripts/audit-demos.mjs # 37 个页面逐页几何体检
162
+ PLAYWRIGHT_PATH=<playwright> node scripts/audit-controls.mjs # 每个滑杆推开看版式是否真变
163
+ ```
164
+
165
+ 三道闸门各管一段,缺一段就有盲区:
166
+
167
+ | 闸门 | 抓什么 | 抓不到什么 |
168
+ | --- | --- | --- |
169
+ | `verify:scenarios` | 元信息 ↔ 源码 ↔ 插件名双向对不上(写了没实现、实现了没登记) | 运行时行为 |
170
+ | `audit-demos` | 真浏览器里的几何坏味道:重叠 / 越界 / 零尺寸 / `scrollHeight` 盖不住底边 | 「控件没接上」——3 列排得整整齐齐也是合法几何 |
171
+ | `audit:controls` | 逐个滑杆推到两端,比较逐项指纹(列号 + 位置 + 列宽 + 总高 + 渲染项数);标了 `nonLayout` 的(耗时 / 池大小 / 阈值)跳过 | 耗时类参数的效果(得看读数或日志) |
172
+
173
+ 两个判定细节,都是被误报逼出来的:`audit-demos` 读不到 `transform` 时会退回 `offsetLeft/offsetTop`(`-prefers-reduced-motion` 下 ReducedMotion 会把定位切成 `left/top`,只读 transform 会误报「容器里没有已布局项」);`audit:controls` 的「拖回原值」检查对开了 `virtualize` 的页面忽略 `scrollHeight`(估值高度被实测高度替换后总高合法变大)。
174
+