@tarojs/components-advanced 4.0.8-beta.0 → 4.0.8-beta.3
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.
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +8 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/list/ListItem.d.ts +9 -0
- package/dist/components/list/ListItem.js +9 -0
- package/dist/components/list/ListItem.js.map +1 -0
- package/dist/components/list/StickyHeader.d.ts +9 -0
- package/dist/components/list/StickyHeader.js +9 -0
- package/dist/components/list/StickyHeader.js.map +1 -0
- package/dist/components/list/StickySection.d.ts +9 -0
- package/dist/components/list/StickySection.js +9 -0
- package/dist/components/list/StickySection.js.map +1 -0
- package/dist/components/list/index.d.ts +37 -0
- package/dist/components/list/index.js +350 -0
- package/dist/components/list/index.js.map +1 -0
- package/dist/components/virtual-list/dom-helpers.js.map +1 -1
- package/dist/components/virtual-list/index.d.ts +5 -5
- package/dist/components/virtual-list/index.js.map +1 -1
- package/dist/components/virtual-list/list-set.js.map +1 -1
- package/dist/components/virtual-list/preset.d.ts +0 -1
- package/dist/components/virtual-list/preset.js.map +1 -1
- package/dist/components/virtual-list/react/index.js.map +1 -1
- package/dist/components/virtual-list/react/list.js.map +1 -1
- package/dist/components/virtual-list/react/validate.js.map +1 -1
- package/dist/components/virtual-list/react/wrapper.js.map +1 -1
- package/dist/components/virtual-list/utils.js.map +1 -1
- package/dist/components/virtual-list/vue/index.js.map +1 -1
- package/dist/components/virtual-list/vue/list.d.ts +13 -13
- package/dist/components/virtual-list/vue/list.js +3 -3
- package/dist/components/virtual-list/vue/list.js.map +1 -1
- package/dist/components/virtual-waterfall/index.js.map +1 -1
- package/dist/components/virtual-waterfall/list-map.js.map +1 -1
- package/dist/components/virtual-waterfall/preset.d.ts +0 -1
- package/dist/components/virtual-waterfall/preset.js.map +1 -1
- package/dist/components/virtual-waterfall/react/index.js.map +1 -1
- package/dist/components/virtual-waterfall/react/waterfall.js.map +1 -1
- package/dist/components/virtual-waterfall/react/wrapper.js +7 -5
- package/dist/components/virtual-waterfall/react/wrapper.js.map +1 -1
- package/dist/components/virtual-waterfall/vue/index.js.map +1 -1
- package/dist/components/virtual-waterfall/vue/waterfall.d.ts +11 -11
- package/dist/components/virtual-waterfall/vue/waterfall.js +3 -3
- package/dist/components/virtual-waterfall/vue/waterfall.js.map +1 -1
- package/dist/components/water-flow/flow-item.d.ts +11 -0
- package/dist/components/water-flow/flow-item.js +70 -0
- package/dist/components/water-flow/flow-item.js.map +1 -0
- package/dist/components/water-flow/flow-section.d.ts +7 -0
- package/dist/components/water-flow/flow-section.js +66 -0
- package/dist/components/water-flow/flow-section.js.map +1 -0
- package/dist/components/water-flow/index.d.ts +4 -0
- package/dist/components/water-flow/index.js +4 -0
- package/dist/components/water-flow/index.js.map +1 -0
- package/dist/components/water-flow/interface.d.ts +54 -0
- package/dist/components/water-flow/node.d.ts +63 -0
- package/dist/components/water-flow/node.js +99 -0
- package/dist/components/water-flow/node.js.map +1 -0
- package/dist/components/water-flow/root.d.ts +144 -0
- package/dist/components/water-flow/root.js +383 -0
- package/dist/components/water-flow/root.js.map +1 -0
- package/dist/components/water-flow/section.d.ts +112 -0
- package/dist/components/water-flow/section.js +233 -0
- package/dist/components/water-flow/section.js.map +1 -0
- package/dist/components/water-flow/stateful-event-bus.d.ts +33 -0
- package/dist/components/water-flow/stateful-event-bus.js +70 -0
- package/dist/components/water-flow/stateful-event-bus.js.map +1 -0
- package/dist/components/water-flow/use-memoized-fn.d.ts +4 -0
- package/dist/components/water-flow/use-memoized-fn.js +16 -0
- package/dist/components/water-flow/use-memoized-fn.js.map +1 -0
- package/dist/components/water-flow/use-observed-attr.d.ts +2 -0
- package/dist/components/water-flow/use-observed-attr.js +20 -0
- package/dist/components/water-flow/use-observed-attr.js.map +1 -0
- package/dist/components/water-flow/use-unmount.d.ts +1 -0
- package/dist/components/water-flow/utils.d.ts +30 -0
- package/dist/components/water-flow/utils.js +45 -0
- package/dist/components/water-flow/utils.js.map +1 -0
- package/dist/components/water-flow/water-flow.d.ts +4 -0
- package/dist/components/water-flow/water-flow.js +159 -0
- package/dist/components/water-flow/water-flow.js.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/convert.js.map +1 -1
- package/dist/utils/dom.js.map +1 -1
- package/dist/utils/helper.js.map +1 -1
- package/dist/utils/lodash.js.map +1 -1
- package/dist/utils/math.js.map +1 -1
- package/dist/utils/timer.js.map +1 -1
- package/dist/utils/vue-render.js.map +1 -1
- package/package.json +10 -12
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import '../../utils/index.js';
|
|
2
|
+
import { SectionEvents } from './section.js';
|
|
3
|
+
import { StatefulEventBus } from './stateful-event-bus.js';
|
|
4
|
+
import { getRectSizeSync } from '../../utils/dom.js';
|
|
5
|
+
|
|
6
|
+
const NodeEvents = {
|
|
7
|
+
Resize: Symbol.for('resize'),
|
|
8
|
+
};
|
|
9
|
+
class Node extends StatefulEventBus {
|
|
10
|
+
constructor(root, section, props) {
|
|
11
|
+
const { height, childIndex, order, col } = props;
|
|
12
|
+
super({
|
|
13
|
+
top: 0,
|
|
14
|
+
width: 0,
|
|
15
|
+
height,
|
|
16
|
+
scrollTop: 0,
|
|
17
|
+
layouted: false,
|
|
18
|
+
});
|
|
19
|
+
this.root = root;
|
|
20
|
+
this.section = section;
|
|
21
|
+
const nodeId = `${root.id}-${section.id}-item-${childIndex}`;
|
|
22
|
+
Object.assign(this, { id: nodeId, childIndex, order, col });
|
|
23
|
+
this.setupSubscriptions();
|
|
24
|
+
}
|
|
25
|
+
setupSubscriptions() {
|
|
26
|
+
this.sub('layouted', () => {
|
|
27
|
+
/**
|
|
28
|
+
* 如果当前分组所有的节点都完成布局计算,那么向分组推送 `AllNodesLayouted` 事件,section会在这个时机做一些计算
|
|
29
|
+
*/
|
|
30
|
+
if ([...this.section.nodes.values()].every((node) => node.getState().layouted)) {
|
|
31
|
+
this.section.notify(SectionEvents.AllNodesLayouted);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* 如果节点的尺寸发生了变化(这通常出现在节点内容包含网络数据的情况下,比如图片,这时要求用户调用 useFlowItemPositioner 返回的 resize 方法通知数据模型去重新计算布局)
|
|
36
|
+
*
|
|
37
|
+
* - 更新当前节点所在列之后的所有节点的位置信息
|
|
38
|
+
*
|
|
39
|
+
* - 通知 section 更新布局
|
|
40
|
+
*/
|
|
41
|
+
this.sub(NodeEvents.Resize, async () => {
|
|
42
|
+
const { width, height } = this.getState();
|
|
43
|
+
const newSize = await this.measure();
|
|
44
|
+
if (newSize.height === height && newSize.width === width) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
this.updateBehindNodesPosition();
|
|
48
|
+
this.section.pub(SectionEvents.Resize, {
|
|
49
|
+
node: this,
|
|
50
|
+
newSize,
|
|
51
|
+
originalSize: { width, height },
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 测量节点的尺寸信息
|
|
57
|
+
*/
|
|
58
|
+
async measure() {
|
|
59
|
+
const { height, width } = await getRectSizeSync(`#${this.id}`, 100, 3);
|
|
60
|
+
this.setStateBatch({
|
|
61
|
+
width,
|
|
62
|
+
height,
|
|
63
|
+
layouted: true,
|
|
64
|
+
});
|
|
65
|
+
return { width, height };
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* 更新节点所在列后面的节点的位置
|
|
69
|
+
*/
|
|
70
|
+
updateBehindNodesPosition() {
|
|
71
|
+
const currentColumn = this.section.columnMap[this.col];
|
|
72
|
+
let start = this.order + 1;
|
|
73
|
+
if (start > currentColumn.length - 1) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
for (; start < currentColumn.length; start++) {
|
|
77
|
+
const node = currentColumn[start];
|
|
78
|
+
const previousNode = currentColumn[start - 1];
|
|
79
|
+
const { top: previousNodeTop, height: previousNodeHeight, scrollTop: previousNodeScrollTop, } = previousNode.getState();
|
|
80
|
+
const rowGap = this.section.rowGap;
|
|
81
|
+
node.setStateBatch({
|
|
82
|
+
top: previousNodeTop + previousNodeHeight + rowGap,
|
|
83
|
+
scrollTop: previousNodeScrollTop + previousNodeHeight + rowGap,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* 节点是否可见
|
|
89
|
+
*/
|
|
90
|
+
get isInRange() {
|
|
91
|
+
const { scrollBoundaryStart, scrollBoundaryEnd } = this.root;
|
|
92
|
+
const { height: nodeHeight, scrollTop: nodeScrollTop } = this.getState();
|
|
93
|
+
return (nodeScrollTop < scrollBoundaryEnd &&
|
|
94
|
+
nodeScrollTop + nodeHeight > scrollBoundaryStart);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export { Node, NodeEvents };
|
|
99
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sources":["../../../src/components/water-flow/node.ts"],"sourcesContent":["import { getRectSizeSync } from '../../utils'\nimport { Root } from './root'\nimport { Section, SectionEvents } from './section'\nimport { StatefulEventBus } from './stateful-event-bus'\n\ninterface NodeProps {\n /**\n * 原始索引,即一维数组中的索引\n */\n childIndex: number\n /**\n * 在列里的顺序\n */\n order: number\n /**\n * 位于哪一列\n */\n col: number\n height: number\n}\n\ntype NodeState = {\n top: number\n width: number\n height: number\n layouted: boolean\n scrollTop: number\n};\n\nexport const NodeEvents = {\n Resize: Symbol.for('resize'),\n}\n\nexport class Node extends StatefulEventBus<NodeState> {\n id: string\n /**\n * 原始索引,即一维数组中的索引\n */\n childIndex: number\n /**\n * 在列里的顺序\n */\n order: number\n /**\n * 位于哪一列\n */\n col: number\n constructor(public root: Root, public section: Section, props: NodeProps) {\n const { height, childIndex, order, col } = props\n super({\n top: 0,\n width: 0,\n height,\n scrollTop: 0,\n layouted: false,\n })\n const nodeId = `${root.id}-${section.id}-item-${childIndex}`\n Object.assign(this, { id: nodeId, childIndex, order, col })\n this.setupSubscriptions()\n }\n\n private setupSubscriptions() {\n this.sub('layouted', () => {\n /**\n * 如果当前分组所有的节点都完成布局计算,那么向分组推送 `AllNodesLayouted` 事件,section会在这个时机做一些计算\n */\n if (\n [...this.section.nodes.values()].every(\n (node) => node.getState().layouted\n )\n ) {\n this.section.notify(SectionEvents.AllNodesLayouted)\n }\n })\n\n /**\n * 如果节点的尺寸发生了变化(这通常出现在节点内容包含网络数据的情况下,比如图片,这时要求用户调用 useFlowItemPositioner 返回的 resize 方法通知数据模型去重新计算布局)\n *\n * - 更新当前节点所在列之后的所有节点的位置信息\n *\n * - 通知 section 更新布局\n */\n this.sub(NodeEvents.Resize, async () => {\n const { width, height } = this.getState()\n const newSize = await this.measure()\n if (newSize.height === height && newSize.width === width) {\n return\n }\n this.updateBehindNodesPosition()\n this.section.pub(SectionEvents.Resize, {\n node: this,\n newSize,\n originalSize: { width, height },\n })\n })\n }\n\n /**\n * 测量节点的尺寸信息\n */\n public async measure() {\n const { height, width } = await getRectSizeSync(`#${this.id}`, 100, 3)\n this.setStateBatch({\n width,\n height,\n layouted: true,\n })\n return { width, height }\n }\n\n /**\n * 更新节点所在列后面的节点的位置\n */\n updateBehindNodesPosition() {\n const currentColumn = this.section.columnMap[this.col]\n let start = this.order + 1\n\n if (start > currentColumn.length - 1) {\n return\n }\n for (; start < currentColumn.length; start++) {\n const node = currentColumn[start]\n const previousNode = currentColumn[start - 1]\n const {\n top: previousNodeTop,\n height: previousNodeHeight,\n scrollTop: previousNodeScrollTop,\n } = previousNode.getState()\n const rowGap = this.section.rowGap\n node.setStateBatch({\n top: previousNodeTop + previousNodeHeight + rowGap,\n scrollTop: previousNodeScrollTop + previousNodeHeight + rowGap,\n })\n }\n }\n\n /**\n * 节点是否可见\n */\n get isInRange() {\n const { scrollBoundaryStart, scrollBoundaryEnd } = this.root\n const { height: nodeHeight, scrollTop: nodeScrollTop } = this.getState()\n return (\n nodeScrollTop < scrollBoundaryEnd &&\n nodeScrollTop + nodeHeight > scrollBoundaryStart\n )\n }\n}\n"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { Node } from './node';
|
|
2
|
+
import { Section } from './section';
|
|
3
|
+
import { StatefulEventBus } from './stateful-event-bus';
|
|
4
|
+
import type { BaseProps, ScrollDirection, Size, WaterFlowProps } from './interface';
|
|
5
|
+
export type RootProps = Pick<WaterFlowProps, 'cacheCount' | 'lowerThresholdCount' | 'upperThresholdCount'> & Required<Pick<BaseProps, 'id'>>;
|
|
6
|
+
type RootState = {
|
|
7
|
+
/** 是否在滚动中 */
|
|
8
|
+
isScrolling: boolean;
|
|
9
|
+
/** 滚动偏移量 */
|
|
10
|
+
scrollOffset: number;
|
|
11
|
+
/**
|
|
12
|
+
* 滚动方向
|
|
13
|
+
*
|
|
14
|
+
* - forward 向下滚动
|
|
15
|
+
*
|
|
16
|
+
* - backward 向上滚动
|
|
17
|
+
*/
|
|
18
|
+
scrollDirection: ScrollDirection;
|
|
19
|
+
/** 滚动高度 */
|
|
20
|
+
scrollHeight: number;
|
|
21
|
+
/** 容器的尺寸信息 */
|
|
22
|
+
containerSize: Size;
|
|
23
|
+
/** 渲染的分组区间范围 */
|
|
24
|
+
renderRange: [number, number];
|
|
25
|
+
};
|
|
26
|
+
export declare const RootEvents: {
|
|
27
|
+
ReachUpperThreshold: symbol;
|
|
28
|
+
ReachLowerThreshold: symbol;
|
|
29
|
+
Resize: symbol;
|
|
30
|
+
AllSectionsLayouted: symbol;
|
|
31
|
+
InitialRenderCompleted: symbol;
|
|
32
|
+
};
|
|
33
|
+
type Events = keyof typeof RootEvents;
|
|
34
|
+
/**
|
|
35
|
+
* 数据模型继承自有状态的事件总线,便于在节点之间通信,以及通过 useSyncExternalStore 关联 React 视图
|
|
36
|
+
*/
|
|
37
|
+
export declare class Root extends StatefulEventBus<RootState, Events> {
|
|
38
|
+
/**
|
|
39
|
+
* 瀑布流根节点唯一标识
|
|
40
|
+
*/
|
|
41
|
+
id: string;
|
|
42
|
+
/**
|
|
43
|
+
* 分组映射表,便于查找分组
|
|
44
|
+
*/
|
|
45
|
+
sectionMap: Map<string, Section>;
|
|
46
|
+
/**
|
|
47
|
+
* 节点映射表,便于查找节点
|
|
48
|
+
*/
|
|
49
|
+
nodeMap: Map<string, Node>;
|
|
50
|
+
/**
|
|
51
|
+
* 分组列表,基于计算出的渲染的分组区间范围 sections.slice(start, end + 1) 进行渲染
|
|
52
|
+
*/
|
|
53
|
+
sections: Section[];
|
|
54
|
+
/**
|
|
55
|
+
* 设置预加载的 Item 条数。
|
|
56
|
+
*/
|
|
57
|
+
cacheCount: number;
|
|
58
|
+
upperThresholdCount: number;
|
|
59
|
+
lowerThresholdCount: number;
|
|
60
|
+
/**
|
|
61
|
+
* 触发滚动阈值对应的 scrollTop 值
|
|
62
|
+
*/
|
|
63
|
+
upperThresholdScrollTop: number;
|
|
64
|
+
/**
|
|
65
|
+
* 触发滚动阈值对应的 scrollTop 值
|
|
66
|
+
*/
|
|
67
|
+
lowerThresholdScrollTop: number;
|
|
68
|
+
constructor(props: RootProps);
|
|
69
|
+
/**
|
|
70
|
+
* 设置订阅事件
|
|
71
|
+
*/
|
|
72
|
+
private setupSubscriptions;
|
|
73
|
+
/**
|
|
74
|
+
* 渐进式渲染
|
|
75
|
+
*
|
|
76
|
+
* 因为初始没法知道每个分组的高度信息,不知道渲染边界,所以需要渐进式渲染
|
|
77
|
+
*
|
|
78
|
+
* 当目前的渲染批次的首个分组的scrollTop大于容器的高度,说明容器可视区域已经填满,没必要再往下渲染了
|
|
79
|
+
*
|
|
80
|
+
* @param [i=0] 从第几个分组开始渲染
|
|
81
|
+
*
|
|
82
|
+
*/
|
|
83
|
+
renderInitialLayout(i?: number): void;
|
|
84
|
+
/**
|
|
85
|
+
* 计算滚动阈值对应的 scrollTop 并设置 upperThresholdScrollTop
|
|
86
|
+
* 当距顶部还有 upperThresholdCount 个 FlowItem 时的 scrollTop 值
|
|
87
|
+
*/
|
|
88
|
+
private setUpperThresholdScrollTop;
|
|
89
|
+
/**
|
|
90
|
+
* 计算滚动阈值对应的 scrollTop 并设置 lowerThresholdScrollTop
|
|
91
|
+
* 当距底部还有 lowerThresholdCount 个 FlowItem 时的 scrollTop 值
|
|
92
|
+
*/
|
|
93
|
+
private setLowerThresholdScrollTop;
|
|
94
|
+
/**
|
|
95
|
+
* 处理滚动到阈值的情况
|
|
96
|
+
* 检测当前滚动位置是否达到了上下阈值,并触发相应的事件
|
|
97
|
+
*/
|
|
98
|
+
private handleReachThreshold;
|
|
99
|
+
/**
|
|
100
|
+
* 容器的滚动上边界
|
|
101
|
+
*/
|
|
102
|
+
get scrollBoundaryStart(): number;
|
|
103
|
+
/**
|
|
104
|
+
* 容器的滚动下边界
|
|
105
|
+
*/
|
|
106
|
+
get scrollBoundaryEnd(): number;
|
|
107
|
+
/**
|
|
108
|
+
* 计算每个section的底部位置
|
|
109
|
+
*
|
|
110
|
+
* sectionBottomRange = [ [section1.top, section1.bottom], [section2.top, section2.bottom], ..., [sectionN.top, sectionN.bottom] ]
|
|
111
|
+
*
|
|
112
|
+
* @returns [number,number][]
|
|
113
|
+
*/
|
|
114
|
+
get sectionRange(): number[][];
|
|
115
|
+
/**
|
|
116
|
+
* 计算滚动高度
|
|
117
|
+
*/
|
|
118
|
+
updateScrollHeight(): void;
|
|
119
|
+
/**
|
|
120
|
+
* 注册分组
|
|
121
|
+
*/
|
|
122
|
+
registerSection(section: Section): void;
|
|
123
|
+
/**
|
|
124
|
+
* 注册节点
|
|
125
|
+
*/
|
|
126
|
+
registerNode(node: Node): void;
|
|
127
|
+
/**
|
|
128
|
+
* 查找分组
|
|
129
|
+
*/
|
|
130
|
+
findSection(id: string): Section;
|
|
131
|
+
/**
|
|
132
|
+
* 查找节点
|
|
133
|
+
*/
|
|
134
|
+
findNode(id: string): Node;
|
|
135
|
+
/**
|
|
136
|
+
* 获取分组渲染区间
|
|
137
|
+
*/
|
|
138
|
+
getSectionRenderRange(): [number, number];
|
|
139
|
+
/**
|
|
140
|
+
* 计算预渲染的分组个数
|
|
141
|
+
*/
|
|
142
|
+
private calcCacheSection;
|
|
143
|
+
}
|
|
144
|
+
export {};
|
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
import { nextTick } from '@tarojs/taro';
|
|
2
|
+
import '../../utils/index.js';
|
|
3
|
+
import { StatefulEventBus } from './stateful-event-bus.js';
|
|
4
|
+
import { getSysInfo, isSameRenderRange } from './utils.js';
|
|
5
|
+
import { getRectSizeSync } from '../../utils/dom.js';
|
|
6
|
+
|
|
7
|
+
/* eslint-disable no-labels */
|
|
8
|
+
const { windowHeight, windowWidth } = getSysInfo();
|
|
9
|
+
const RootEvents = {
|
|
10
|
+
ReachUpperThreshold: Symbol.for('ReachUpperThreshold'),
|
|
11
|
+
ReachLowerThreshold: Symbol.for('ReachLowerThreshold'),
|
|
12
|
+
Resize: Symbol.for('Resize'),
|
|
13
|
+
AllSectionsLayouted: Symbol.for('AllSectionsLayouted'),
|
|
14
|
+
InitialRenderCompleted: Symbol.for('InitialRenderCompleted'),
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* 数据模型继承自有状态的事件总线,便于在节点之间通信,以及通过 useSyncExternalStore 关联 React 视图
|
|
18
|
+
*/
|
|
19
|
+
class Root extends StatefulEventBus {
|
|
20
|
+
constructor(props) {
|
|
21
|
+
const { id, cacheCount, lowerThresholdCount, upperThresholdCount } = props;
|
|
22
|
+
super({
|
|
23
|
+
isScrolling: false,
|
|
24
|
+
scrollOffset: 0,
|
|
25
|
+
scrollDirection: 'forward',
|
|
26
|
+
scrollHeight: windowHeight,
|
|
27
|
+
renderRange: [0, 0],
|
|
28
|
+
containerSize: {
|
|
29
|
+
width: windowWidth,
|
|
30
|
+
height: windowHeight,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* 分组映射表,便于查找分组
|
|
35
|
+
*/
|
|
36
|
+
this.sectionMap = new Map();
|
|
37
|
+
/**
|
|
38
|
+
* 节点映射表,便于查找节点
|
|
39
|
+
*/
|
|
40
|
+
this.nodeMap = new Map();
|
|
41
|
+
/**
|
|
42
|
+
* 分组列表,基于计算出的渲染的分组区间范围 sections.slice(start, end + 1) 进行渲染
|
|
43
|
+
*/
|
|
44
|
+
this.sections = [];
|
|
45
|
+
/**
|
|
46
|
+
* 设置预加载的 Item 条数。
|
|
47
|
+
*/
|
|
48
|
+
this.cacheCount = 1;
|
|
49
|
+
this.upperThresholdCount = 0;
|
|
50
|
+
this.lowerThresholdCount = 0;
|
|
51
|
+
/**
|
|
52
|
+
* 触发滚动阈值对应的 scrollTop 值
|
|
53
|
+
*/
|
|
54
|
+
this.upperThresholdScrollTop = -Infinity;
|
|
55
|
+
/**
|
|
56
|
+
* 触发滚动阈值对应的 scrollTop 值
|
|
57
|
+
*/
|
|
58
|
+
this.lowerThresholdScrollTop = Infinity;
|
|
59
|
+
Object.assign(this, {
|
|
60
|
+
id,
|
|
61
|
+
cacheCount,
|
|
62
|
+
lowerThresholdCount,
|
|
63
|
+
upperThresholdCount,
|
|
64
|
+
});
|
|
65
|
+
this.setupSubscriptions();
|
|
66
|
+
getRectSizeSync(`#${id}`, 100).then(({ width = windowWidth, height = windowHeight }) => {
|
|
67
|
+
this.setStateIn('containerSize', {
|
|
68
|
+
width,
|
|
69
|
+
height,
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
this.renderInitialLayout();
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 设置订阅事件
|
|
76
|
+
*/
|
|
77
|
+
setupSubscriptions() {
|
|
78
|
+
/**
|
|
79
|
+
* 滚动过程中计算渲染的分组区间
|
|
80
|
+
* 滚动过程中分组的最大高度会发生更新,可以在这时计算滚动高度
|
|
81
|
+
*/
|
|
82
|
+
this.sub('scrollOffset', () => {
|
|
83
|
+
this.setStateIn('renderRange', this.getSectionRenderRange());
|
|
84
|
+
this.handleReachThreshold();
|
|
85
|
+
if (this.getState().scrollDirection === 'forward') {
|
|
86
|
+
this.updateScrollHeight();
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
this.sub('scrollOffset', () => {
|
|
90
|
+
const sectionSize = this.sections.length;
|
|
91
|
+
const lastSection = this.sections[sectionSize - 1];
|
|
92
|
+
// 最后一个分组的每一列最后一行都已经完成了布局计算,那么这个时候的总高度应该是准确的
|
|
93
|
+
if (lastSection.columnMap.every((column) => column[column.length - 1].getState().layouted)) {
|
|
94
|
+
this.setLowerThresholdScrollTop();
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
this.sub(RootEvents.AllSectionsLayouted, () => {
|
|
98
|
+
this.setUpperThresholdScrollTop();
|
|
99
|
+
});
|
|
100
|
+
this.sub(RootEvents.Resize, () => {
|
|
101
|
+
this.setUpperThresholdScrollTop();
|
|
102
|
+
this.setLowerThresholdScrollTop();
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* 渐进式渲染
|
|
107
|
+
*
|
|
108
|
+
* 因为初始没法知道每个分组的高度信息,不知道渲染边界,所以需要渐进式渲染
|
|
109
|
+
*
|
|
110
|
+
* 当目前的渲染批次的首个分组的scrollTop大于容器的高度,说明容器可视区域已经填满,没必要再往下渲染了
|
|
111
|
+
*
|
|
112
|
+
* @param [i=0] 从第几个分组开始渲染
|
|
113
|
+
*
|
|
114
|
+
*/
|
|
115
|
+
renderInitialLayout(i = 0) {
|
|
116
|
+
nextTick(() => {
|
|
117
|
+
const sectionSize = this.sections.length;
|
|
118
|
+
if (i >= sectionSize || i < 0) {
|
|
119
|
+
this.pub(RootEvents.InitialRenderCompleted, null);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const section = this.sections[i];
|
|
123
|
+
section.layoutedSignal.promise.then(() => {
|
|
124
|
+
this.setStateIn('renderRange', [0, i + 1 > sectionSize ? sectionSize - 1 : i + 1]);
|
|
125
|
+
// 容器可视区域已经填满了,没必要再继续
|
|
126
|
+
if (section.getState().scrollTop > this.getState().containerSize.height) {
|
|
127
|
+
this.pub(RootEvents.InitialRenderCompleted, section);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
this.renderInitialLayout(i + 1);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* 计算滚动阈值对应的 scrollTop 并设置 upperThresholdScrollTop
|
|
136
|
+
* 当距顶部还有 upperThresholdCount 个 FlowItem 时的 scrollTop 值
|
|
137
|
+
*/
|
|
138
|
+
setUpperThresholdScrollTop() {
|
|
139
|
+
// 如果没有设置阈值或阈值为0,则返回0
|
|
140
|
+
if (!this.upperThresholdCount) {
|
|
141
|
+
this.upperThresholdScrollTop = 0;
|
|
142
|
+
return 0;
|
|
143
|
+
}
|
|
144
|
+
const sectionSize = this.sections.length;
|
|
145
|
+
const tracker = Array.from({ length: sectionSize }, () => new Map() // Map<列, { 当前列累计个数,当前列累计高度 }>
|
|
146
|
+
);
|
|
147
|
+
// 从第一个分组开始扫描
|
|
148
|
+
loopSeciton: for (let i = 0; i < sectionSize; i++) {
|
|
149
|
+
const section = this.sections[i];
|
|
150
|
+
const sectionTracker = tracker[i];
|
|
151
|
+
const columnMap = section.columnMap;
|
|
152
|
+
// 扫描当前分组的每一列
|
|
153
|
+
for (let col = 0; col < columnMap.length; col++) {
|
|
154
|
+
const column = columnMap[col];
|
|
155
|
+
const columnSize = column.length;
|
|
156
|
+
if (!sectionTracker.has(col)) {
|
|
157
|
+
if (i === 0) {
|
|
158
|
+
sectionTracker.set(col, { accCount: 0, accHeight: 0 });
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
const previousSectionTracker = tracker[i - 1];
|
|
162
|
+
sectionTracker.set(col, {
|
|
163
|
+
accCount: Math.max(...[...previousSectionTracker.values()].map((nodeTracker) => nodeTracker.accCount)),
|
|
164
|
+
accHeight: section.getState().scrollTop,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const colTracker = sectionTracker.get(col);
|
|
169
|
+
// 扫描当前列的每一行
|
|
170
|
+
loopItem: for (let j = 0; j < columnSize; j++) {
|
|
171
|
+
colTracker.accCount += 1;
|
|
172
|
+
colTracker.accHeight += column[j].getState().height + (j === 0 ? 0 : section.rowGap);
|
|
173
|
+
if (colTracker.accCount >= this.upperThresholdCount) {
|
|
174
|
+
break loopItem;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
for (const [, colTracker] of sectionTracker) {
|
|
179
|
+
if (colTracker.accCount >= this.upperThresholdCount) {
|
|
180
|
+
this.upperThresholdScrollTop = colTracker.accHeight;
|
|
181
|
+
break loopSeciton;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return this.upperThresholdScrollTop;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* 计算滚动阈值对应的 scrollTop 并设置 lowerThresholdScrollTop
|
|
189
|
+
* 当距底部还有 lowerThresholdCount 个 FlowItem 时的 scrollTop 值
|
|
190
|
+
*/
|
|
191
|
+
setLowerThresholdScrollTop() {
|
|
192
|
+
if (this.lowerThresholdCount === 0) {
|
|
193
|
+
this.lowerThresholdScrollTop = this.getState().scrollHeight - this.getState().containerSize.height;
|
|
194
|
+
return 0;
|
|
195
|
+
}
|
|
196
|
+
const sectionSize = this.sections.length;
|
|
197
|
+
const tracker = Array.from({ length: sectionSize }, () => new Map());
|
|
198
|
+
// 从最后一个分组开始计算
|
|
199
|
+
loopSeciton: for (let i = sectionSize - 1; i >= 0; i--) {
|
|
200
|
+
const section = this.sections[i];
|
|
201
|
+
const sectionTracker = tracker[i];
|
|
202
|
+
const columnMap = section.columnMap;
|
|
203
|
+
// 扫描当前分组的每一列
|
|
204
|
+
for (let col = 0; col < columnMap.length; col++) {
|
|
205
|
+
const column = columnMap[col];
|
|
206
|
+
const columnSize = column.length;
|
|
207
|
+
if (!sectionTracker.has(col)) {
|
|
208
|
+
if (i === sectionSize - 1) {
|
|
209
|
+
sectionTracker.set(col, { accCount: 0, scrollTop: 0 });
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
const belowSectionTracker = tracker[i + 1];
|
|
213
|
+
sectionTracker.set(col, {
|
|
214
|
+
accCount: Math.max(...[...belowSectionTracker.values()].map((nodeTracker) => nodeTracker.accCount)),
|
|
215
|
+
scrollTop: 0,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
const colTracker = sectionTracker.get(col);
|
|
220
|
+
// 从当前列的最后一行开始往前扫描
|
|
221
|
+
loopItem: for (let j = columnSize - 1; j >= 0; j--) {
|
|
222
|
+
colTracker.accCount += 1;
|
|
223
|
+
colTracker.scrollTop = column[j].getState().scrollTop;
|
|
224
|
+
if (colTracker.accCount >= this.lowerThresholdCount) {
|
|
225
|
+
break loopItem;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
for (const [, colTracker] of sectionTracker) {
|
|
230
|
+
if (colTracker.accCount >= this.lowerThresholdCount) {
|
|
231
|
+
this.lowerThresholdScrollTop = colTracker.scrollTop;
|
|
232
|
+
break loopSeciton;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return this.lowerThresholdScrollTop;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* 处理滚动到阈值的情况
|
|
240
|
+
* 检测当前滚动位置是否达到了上下阈值,并触发相应的事件
|
|
241
|
+
*/
|
|
242
|
+
handleReachThreshold() {
|
|
243
|
+
const { upperThresholdScrollTop } = this;
|
|
244
|
+
const { scrollOffset, scrollDirection, containerSize } = this.getState();
|
|
245
|
+
if (scrollDirection === 'backward' &&
|
|
246
|
+
this.upperThresholdScrollTop !== -Infinity &&
|
|
247
|
+
scrollOffset <= upperThresholdScrollTop) {
|
|
248
|
+
this.pub(RootEvents.ReachUpperThreshold);
|
|
249
|
+
}
|
|
250
|
+
if (scrollDirection === 'forward' &&
|
|
251
|
+
this.lowerThresholdCount !== Infinity &&
|
|
252
|
+
scrollOffset + containerSize.height >= this.lowerThresholdScrollTop) {
|
|
253
|
+
this.pub(RootEvents.ReachLowerThreshold);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* 容器的滚动上边界
|
|
258
|
+
*/
|
|
259
|
+
get scrollBoundaryStart() {
|
|
260
|
+
return this.getState().scrollOffset;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* 容器的滚动下边界
|
|
264
|
+
*/
|
|
265
|
+
get scrollBoundaryEnd() {
|
|
266
|
+
return this.scrollBoundaryStart + this.getStateIn('containerSize').height;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* 计算每个section的底部位置
|
|
270
|
+
*
|
|
271
|
+
* sectionBottomRange = [ [section1.top, section1.bottom], [section2.top, section2.bottom], ..., [sectionN.top, sectionN.bottom] ]
|
|
272
|
+
*
|
|
273
|
+
* @returns [number,number][]
|
|
274
|
+
*/
|
|
275
|
+
get sectionRange() {
|
|
276
|
+
const length = this.sections.length;
|
|
277
|
+
if (length === 0)
|
|
278
|
+
return [];
|
|
279
|
+
const range = Array.from({ length }, () => [0, this.sections[0].maxColumnHeight]);
|
|
280
|
+
for (let i = 1; i < length; i++) {
|
|
281
|
+
const previous = range[i - 1];
|
|
282
|
+
range[i] = [previous[1], previous[1] + this.sections[i].maxColumnHeight];
|
|
283
|
+
}
|
|
284
|
+
return range;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* 计算滚动高度
|
|
288
|
+
*/
|
|
289
|
+
updateScrollHeight() {
|
|
290
|
+
this.setStateIn('scrollHeight', this.sectionRange[this.sectionRange.length - 1][1]);
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* 注册分组
|
|
294
|
+
*/
|
|
295
|
+
registerSection(section) {
|
|
296
|
+
const { id, order } = section;
|
|
297
|
+
this.sectionMap.set(id, section);
|
|
298
|
+
this.sections[order] = section;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* 注册节点
|
|
302
|
+
*/
|
|
303
|
+
registerNode(node) {
|
|
304
|
+
this.nodeMap.set(node.id, node);
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* 查找分组
|
|
308
|
+
*/
|
|
309
|
+
findSection(id) {
|
|
310
|
+
return this.sectionMap.get(id);
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* 查找节点
|
|
314
|
+
*/
|
|
315
|
+
findNode(id) {
|
|
316
|
+
return this.nodeMap.get(id);
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* 获取分组渲染区间
|
|
320
|
+
*/
|
|
321
|
+
getSectionRenderRange() {
|
|
322
|
+
const result = [Infinity, -Infinity];
|
|
323
|
+
for (let i = 0; i < this.sections.length; i++) {
|
|
324
|
+
const section = this.sections[i];
|
|
325
|
+
if (section.isInRange) {
|
|
326
|
+
result[0] = Math.min(result[0], i);
|
|
327
|
+
result[1] = Math.max(result[1], i);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
if (result[0] === Infinity) {
|
|
331
|
+
result[0] = 0;
|
|
332
|
+
}
|
|
333
|
+
if (result[1] === -Infinity) {
|
|
334
|
+
result[1] = this.sections.length - 1;
|
|
335
|
+
}
|
|
336
|
+
const scrollDirection = this.getState().scrollDirection;
|
|
337
|
+
const [backwardCache, forwardCache] = this.calcCacheSection(result);
|
|
338
|
+
const backwardDistance = scrollDirection === 'backward' ? backwardCache : 0;
|
|
339
|
+
const forwardDistance = scrollDirection === 'forward' ? forwardCache : 0;
|
|
340
|
+
const overscanBackward = result[0] - backwardDistance;
|
|
341
|
+
const overscanForward = result[1] + forwardDistance;
|
|
342
|
+
result[0] = overscanBackward < 0 ? 0 : overscanBackward;
|
|
343
|
+
result[1] = overscanForward > this.sections.length ? this.sections.length - 1 : overscanForward;
|
|
344
|
+
return isSameRenderRange(result, this.getState().renderRange) ? this.getState().renderRange : result;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* 计算预渲染的分组个数
|
|
348
|
+
*/
|
|
349
|
+
calcCacheSection(renderRange) {
|
|
350
|
+
var _a, _b, _c, _d;
|
|
351
|
+
const clientHeight = this.getState().containerSize.height;
|
|
352
|
+
const sectionCount = this.sectionMap.size;
|
|
353
|
+
let [start, end] = renderRange;
|
|
354
|
+
let cacheBackward = 1;
|
|
355
|
+
let cacheForward = 1;
|
|
356
|
+
if (start > 0) {
|
|
357
|
+
let acc = (_b = (_a = this.sections[--start]) === null || _a === void 0 ? void 0 : _a.getState().height) !== null && _b !== void 0 ? _b : 0;
|
|
358
|
+
while (--start > 0) {
|
|
359
|
+
const prevSection = this.sections[start];
|
|
360
|
+
acc += prevSection.getState().height;
|
|
361
|
+
cacheBackward += 1;
|
|
362
|
+
if (acc >= clientHeight >>> 1) {
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
if (end < sectionCount - 1) {
|
|
368
|
+
let acc = (_d = (_c = this.sections[++end]) === null || _c === void 0 ? void 0 : _c.getState().height) !== null && _d !== void 0 ? _d : 0;
|
|
369
|
+
while (++end < sectionCount - 1) {
|
|
370
|
+
const nextSection = this.sections[end];
|
|
371
|
+
acc += nextSection.getState().height;
|
|
372
|
+
cacheForward += 1;
|
|
373
|
+
if (acc >= clientHeight >>> 1) {
|
|
374
|
+
break;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
return [cacheBackward, cacheForward];
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
export { Root, RootEvents };
|
|
383
|
+
//# sourceMappingURL=root.js.map
|