@tarojs/components-advanced 4.1.12-beta.2 → 4.1.12-beta.21
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.js +2 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/list/NoMore.d.ts +30 -0
- package/dist/components/list/NoMore.js +10 -0
- package/dist/components/list/NoMore.js.map +1 -0
- package/dist/components/list/hooks/useItemSizeCache.d.ts +13 -0
- package/dist/components/list/hooks/useItemSizeCache.js +40 -0
- package/dist/components/list/hooks/useItemSizeCache.js.map +1 -0
- package/dist/components/list/hooks/useListNestedScroll.d.ts +18 -0
- package/dist/components/list/hooks/useListNestedScroll.js +61 -0
- package/dist/components/list/hooks/useListNestedScroll.js.map +1 -0
- package/dist/components/list/hooks/useListScrollElementAttach.d.ts +25 -0
- package/dist/components/list/hooks/useListScrollElementAttach.js +88 -0
- package/dist/components/list/hooks/useListScrollElementAttach.js.map +1 -0
- package/dist/components/list/hooks/useListScrollElementAttachWeapp.d.ts +27 -0
- package/dist/components/list/hooks/useListScrollElementAttachWeapp.js +153 -0
- package/dist/components/list/hooks/useListScrollElementAttachWeapp.js.map +1 -0
- package/dist/components/list/hooks/useMeasureStartOffset.d.ts +12 -0
- package/dist/components/list/hooks/useMeasureStartOffset.js +84 -0
- package/dist/components/list/hooks/useMeasureStartOffset.js.map +1 -0
- package/dist/components/list/hooks/useMeasureStartOffsetWeapp.d.ts +13 -0
- package/dist/components/list/hooks/useMeasureStartOffsetWeapp.js +85 -0
- package/dist/components/list/hooks/useMeasureStartOffsetWeapp.js.map +1 -0
- package/dist/components/list/hooks/useRefresher.d.ts +74 -0
- package/dist/components/list/hooks/useRefresher.js +503 -0
- package/dist/components/list/hooks/useRefresher.js.map +1 -0
- package/dist/components/list/hooks/useResizeObserver.d.ts +26 -0
- package/dist/components/list/hooks/useResizeObserver.js +152 -0
- package/dist/components/list/hooks/useResizeObserver.js.map +1 -0
- package/dist/components/list/hooks/useScrollCorrection.d.ts +19 -0
- package/dist/components/list/hooks/useScrollCorrection.js +73 -0
- package/dist/components/list/hooks/useScrollCorrection.js.map +1 -0
- package/dist/components/list/hooks/useScrollParentAutoFind.d.ts +20 -0
- package/dist/components/list/hooks/useScrollParentAutoFind.js +81 -0
- package/dist/components/list/hooks/useScrollParentAutoFind.js.map +1 -0
- package/dist/components/list/index.d.ts +64 -7
- package/dist/components/list/index.js +1041 -162
- package/dist/components/list/index.js.map +1 -1
- package/dist/components/list/utils.d.ts +16 -0
- package/dist/components/list/utils.js +19 -0
- package/dist/components/list/utils.js.map +1 -0
- package/dist/components/virtual-list/vue/list.d.ts +12 -12
- package/dist/components/virtual-waterfall/vue/waterfall.d.ts +11 -11
- package/dist/components/water-flow/flow-item.js +6 -4
- package/dist/components/water-flow/flow-item.js.map +1 -1
- package/dist/components/water-flow/flow-section.js +1 -1
- package/dist/components/water-flow/flow-section.js.map +1 -1
- package/dist/components/water-flow/index.d.ts +1 -1
- package/dist/components/water-flow/interface.d.ts +18 -2
- package/dist/components/water-flow/root.d.ts +35 -4
- package/dist/components/water-flow/root.js +114 -42
- package/dist/components/water-flow/root.js.map +1 -1
- package/dist/components/water-flow/section.d.ts +7 -1
- package/dist/components/water-flow/section.js +54 -9
- package/dist/components/water-flow/section.js.map +1 -1
- package/dist/components/water-flow/utils.d.ts +4 -0
- package/dist/components/water-flow/utils.js +5 -1
- package/dist/components/water-flow/utils.js.map +1 -1
- package/dist/components/water-flow/water-flow-node-cache.d.ts +24 -0
- package/dist/components/water-flow/water-flow-node-cache.js +161 -0
- package/dist/components/water-flow/water-flow-node-cache.js.map +1 -0
- package/dist/components/water-flow/water-flow.d.ts +2 -3
- package/dist/components/water-flow/water-flow.js +286 -31
- package/dist/components/water-flow/water-flow.js.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/scrollElementContext.d.ts +15 -0
- package/dist/utils/scrollElementContext.js +14 -0
- package/dist/utils/scrollElementContext.js.map +1 -0
- package/dist/utils/scrollParent.d.ts +33 -0
- package/dist/utils/scrollParent.js +88 -0
- package/dist/utils/scrollParent.js.map +1 -0
- package/package.json +9 -8
|
@@ -1,46 +1,114 @@
|
|
|
1
1
|
import { __rest } from 'tslib';
|
|
2
|
-
import {
|
|
3
|
-
import { nextTick } from '@tarojs/taro';
|
|
4
|
-
import { useId, useMemo,
|
|
2
|
+
import { View, ScrollView } from '@tarojs/components';
|
|
3
|
+
import Taro, { nextTick } from '@tarojs/taro';
|
|
4
|
+
import { useContext, useRef, useCallback, useId, useMemo, useLayoutEffect, useEffect, Children, cloneElement, createElement, forwardRef } from 'react';
|
|
5
5
|
import '../../utils/index.js';
|
|
6
|
+
import { ScrollElementContextOrFallback } from '../../utils/scrollElementContext.js';
|
|
7
|
+
import { useMeasureStartOffset } from '../list/hooks/useMeasureStartOffset.js';
|
|
8
|
+
import { useMeasureStartOffsetWeapp } from '../list/hooks/useMeasureStartOffsetWeapp.js';
|
|
9
|
+
import { useScrollParentAutoFind } from '../list/hooks/useScrollParentAutoFind.js';
|
|
6
10
|
import { Root, RootEvents } from './root.js';
|
|
7
11
|
import { Section } from './section.js';
|
|
8
12
|
import { useMemoizedFn } from './use-memoized-fn.js';
|
|
9
13
|
import { useObservedAttr } from './use-observed-attr.js';
|
|
10
|
-
import { getSysInfo } from './utils.js';
|
|
14
|
+
import { getSysInfo, isH5, isWeapp } from './utils.js';
|
|
15
|
+
import { createWaterFlowNodeCacheControl } from './water-flow-node-cache.js';
|
|
11
16
|
import { getScrollViewContextNode } from '../../utils/dom.js';
|
|
12
17
|
import { debounce } from '../../utils/lodash.js';
|
|
13
18
|
|
|
14
19
|
getSysInfo();
|
|
15
|
-
|
|
20
|
+
const InnerWaterFlow = (_a, ref) => {
|
|
21
|
+
var _b, _c, _d, _e;
|
|
16
22
|
var { children } = _a, props = __rest(_a, ["children"]);
|
|
17
|
-
const { id, style = {}, className, cacheCount = 1, onScrollToUpper, onScrollToLower, upperThresholdCount, lowerThresholdCount, scrollIntoView } = props, rest = __rest(props, ["id", "style", "className", "cacheCount", "onScrollToUpper", "onScrollToLower", "upperThresholdCount", "lowerThresholdCount", "scrollIntoView"]);
|
|
23
|
+
const { id, style = {}, className, cacheCount = 1, onScrollToUpper, onScrollToLower, upperThresholdCount, lowerThresholdCount, scrollIntoView, nestedScroll, scrollElement, startOffset, containerHeight, onScrollHeightChange, onScrollIntoViewComplete } = props, rest = __rest(props, ["id", "style", "className", "cacheCount", "onScrollToUpper", "onScrollToLower", "upperThresholdCount", "lowerThresholdCount", "scrollIntoView", "nestedScroll", "scrollElement", "startOffset", "containerHeight", "onScrollHeightChange", "onScrollIntoViewComplete"]);
|
|
24
|
+
const flowType = nestedScroll === true ? 'nested' : 'default';
|
|
25
|
+
// 从 ScrollElementContext 获取 scrollRef(List/ScrollView 内嵌时提供);无 Context 时兜底为 fallback
|
|
26
|
+
const scrollElementCtx = useContext(ScrollElementContextOrFallback);
|
|
27
|
+
const contentWrapperRef = useRef(null);
|
|
28
|
+
const setContainerRef = useCallback((el) => {
|
|
29
|
+
contentWrapperRef.current = el;
|
|
30
|
+
if (typeof ref === 'function')
|
|
31
|
+
ref(el);
|
|
32
|
+
else if (ref)
|
|
33
|
+
ref.current = el;
|
|
34
|
+
}, [ref]);
|
|
18
35
|
const defaultId = useId().replace(/:/g, '');
|
|
36
|
+
const contentId = useMemo(() => id !== null && id !== void 0 ? id : defaultId, [id, defaultId]);
|
|
37
|
+
const needAutoFind = flowType === 'nested' &&
|
|
38
|
+
!scrollElement &&
|
|
39
|
+
!(scrollElementCtx === null || scrollElementCtx === void 0 ? void 0 : scrollElementCtx.scrollRef) &&
|
|
40
|
+
(isH5 || isWeapp);
|
|
41
|
+
const { scrollParentRef: autoFoundRef, status: autoFindStatus } = useScrollParentAutoFind(contentWrapperRef, { enabled: !!needAutoFind, isHorizontal: false, contentId: isWeapp ? contentId : undefined });
|
|
42
|
+
const effectiveScrollElement = (_b = scrollElement !== null && scrollElement !== void 0 ? scrollElement : scrollElementCtx === null || scrollElementCtx === void 0 ? void 0 : scrollElementCtx.scrollRef) !== null && _b !== void 0 ? _b : (needAutoFind && autoFindStatus === 'found' ? autoFoundRef : null);
|
|
43
|
+
const ctxStart = scrollElementCtx === null || scrollElementCtx === void 0 ? void 0 : scrollElementCtx.startOffset;
|
|
44
|
+
const hasExplicitStartOffset = ctxStart != null && ctxStart > 0;
|
|
45
|
+
const needMeasureStartOffset = flowType === 'nested' &&
|
|
46
|
+
effectiveScrollElement &&
|
|
47
|
+
isH5 &&
|
|
48
|
+
startOffset == null &&
|
|
49
|
+
!hasExplicitStartOffset;
|
|
50
|
+
const needMeasureStartOffsetWeapp = flowType === 'nested' &&
|
|
51
|
+
effectiveScrollElement &&
|
|
52
|
+
isWeapp &&
|
|
53
|
+
startOffset == null &&
|
|
54
|
+
!hasExplicitStartOffset;
|
|
55
|
+
const measuredStartOffset = useMeasureStartOffset(effectiveScrollElement !== null && effectiveScrollElement !== void 0 ? effectiveScrollElement : { current: null }, contentWrapperRef, { enabled: !!needMeasureStartOffset, isHorizontal: false });
|
|
56
|
+
const effectiveStartOffsetRef = useRef(0);
|
|
57
|
+
const measuredStartOffsetWeapp = useMeasureStartOffsetWeapp(effectiveScrollElement !== null && effectiveScrollElement !== void 0 ? effectiveScrollElement : { current: null }, contentId, { enabled: !!needMeasureStartOffsetWeapp, isHorizontal: false, startOffsetRef: effectiveStartOffsetRef });
|
|
58
|
+
const effectiveStartOffset = (_e = (_d = (_c = startOffset !== null && startOffset !== void 0 ? startOffset : (ctxStart != null && ctxStart > 0 ? ctxStart : null)) !== null && _c !== void 0 ? _c : measuredStartOffset) !== null && _d !== void 0 ? _d : measuredStartOffsetWeapp) !== null && _e !== void 0 ? _e : 0;
|
|
59
|
+
const effectiveContainerHeight = containerHeight !== null && containerHeight !== void 0 ? containerHeight : scrollElementCtx === null || scrollElementCtx === void 0 ? void 0 : scrollElementCtx.containerHeight;
|
|
60
|
+
const startOffsetRef = useRef(effectiveStartOffset);
|
|
61
|
+
const containerHeightRef = useRef(effectiveContainerHeight);
|
|
62
|
+
const lastReportedHeightRef = useRef(0);
|
|
63
|
+
startOffsetRef.current = effectiveStartOffset;
|
|
64
|
+
if (!needMeasureStartOffsetWeapp) {
|
|
65
|
+
effectiveStartOffsetRef.current = effectiveStartOffset;
|
|
66
|
+
}
|
|
67
|
+
containerHeightRef.current = effectiveContainerHeight;
|
|
68
|
+
const useScrollElementMode = flowType === 'nested' && !!(effectiveScrollElement && (isH5 || isWeapp));
|
|
69
|
+
if (flowType === 'nested' && !effectiveScrollElement && (isH5 || isWeapp) && autoFindStatus === 'not-found') {
|
|
70
|
+
// eslint-disable-next-line no-console
|
|
71
|
+
console.warn('[WaterFlow] nestedScroll 模式但无 scrollElement(props/Context/自动查找),回退为 default,将渲染自有 ScrollView');
|
|
72
|
+
}
|
|
19
73
|
/**
|
|
20
74
|
* 初始化数据模型
|
|
21
75
|
*/
|
|
22
76
|
const root = useMemo(() => {
|
|
23
77
|
return new Root({
|
|
24
|
-
id:
|
|
78
|
+
id: contentId,
|
|
25
79
|
cacheCount,
|
|
26
80
|
upperThresholdCount,
|
|
27
81
|
lowerThresholdCount,
|
|
82
|
+
skipContainerMeasure: useScrollElementMode || (!!needAutoFind && autoFindStatus === 'pending'),
|
|
28
83
|
});
|
|
29
|
-
}, [
|
|
84
|
+
}, [contentId, upperThresholdCount, lowerThresholdCount, useScrollElementMode, needAutoFind, autoFindStatus]);
|
|
85
|
+
/** props 动态修改 cacheCount 时同步到 Root,避免重建 Root;并收敛快滑单边放大到新的基线 */
|
|
86
|
+
useLayoutEffect(() => {
|
|
87
|
+
root.cacheCount = cacheCount;
|
|
88
|
+
root.setNodeCacheRange(cacheCount, cacheCount);
|
|
89
|
+
}, [root, cacheCount]);
|
|
30
90
|
const isScrolling$ = useObservedAttr(root, 'isScrolling');
|
|
31
91
|
const scrollHeight$ = useObservedAttr(root, 'scrollHeight');
|
|
32
92
|
const renderRange$ = useObservedAttr(root, 'renderRange');
|
|
33
93
|
const refEventOrig = useRef();
|
|
94
|
+
const nodeCacheCtlRef = useRef(null);
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
const ctl = createWaterFlowNodeCacheControl(root, () => root.cacheCount);
|
|
97
|
+
nodeCacheCtlRef.current = ctl;
|
|
98
|
+
return () => {
|
|
99
|
+
ctl.dispose();
|
|
100
|
+
nodeCacheCtlRef.current = null;
|
|
101
|
+
};
|
|
102
|
+
}, [root]);
|
|
34
103
|
/**
|
|
35
104
|
* 滚动事件
|
|
36
105
|
*/
|
|
37
106
|
const handleScroll = useMemoizedFn((ev) => {
|
|
107
|
+
var _a;
|
|
38
108
|
refEventOrig.current = ev;
|
|
39
|
-
root.sections.forEach((section) => section.getNodeRenderRange());
|
|
40
109
|
const { scrollTop } = ev.detail;
|
|
41
|
-
|
|
110
|
+
(_a = nodeCacheCtlRef.current) === null || _a === void 0 ? void 0 : _a.onScrollSample(scrollTop);
|
|
42
111
|
const scrollDirection = root.getState().scrollOffset < scrollTop ? 'forward' : 'backward';
|
|
43
|
-
// 设置滚动信息,包括方向和偏移量
|
|
44
112
|
root.setStateBatch({
|
|
45
113
|
scrollDirection: scrollDirection,
|
|
46
114
|
scrollOffset: scrollTop,
|
|
@@ -62,7 +130,7 @@ function WaterFlow(_a) {
|
|
|
62
130
|
if (section) {
|
|
63
131
|
const originalCount = section.count;
|
|
64
132
|
if (childCount > originalCount) {
|
|
65
|
-
section.
|
|
133
|
+
section.pushNodesStructuralOnly(childCount - originalCount);
|
|
66
134
|
}
|
|
67
135
|
}
|
|
68
136
|
else {
|
|
@@ -78,10 +146,42 @@ function WaterFlow(_a) {
|
|
|
78
146
|
return cloneElement(child, { section, key: `${props.id}-${order}` });
|
|
79
147
|
})) === null || _a === void 0 ? void 0 : _a.slice(start, end + 1);
|
|
80
148
|
}, [renderRange$[0], renderRange$[1], children, root, props.id]);
|
|
149
|
+
/** 配对 pushNodesStructuralOnly:在 layout 阶段完成 Section 状态,避免 useMemo 内 setState 告警 */
|
|
150
|
+
useLayoutEffect(() => {
|
|
151
|
+
Children.forEach(children, (child, order) => {
|
|
152
|
+
var _a;
|
|
153
|
+
if (Object.is(child, null)) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const sectionProps = child.props;
|
|
157
|
+
const sectionId = sectionProps.id || `section-${order}`;
|
|
158
|
+
(_a = root.findSection(sectionId)) === null || _a === void 0 ? void 0 : _a.finalizePushNodesStateIfNeeded();
|
|
159
|
+
});
|
|
160
|
+
}, [children, root]);
|
|
81
161
|
const scrollTo = useMemoizedFn((scrollOffset = 0) => {
|
|
162
|
+
var _a;
|
|
82
163
|
scrollOffset = Math.max(0, scrollOffset);
|
|
83
164
|
if (root.getState().scrollOffset === scrollOffset)
|
|
84
165
|
return;
|
|
166
|
+
if (useScrollElementMode && (effectiveScrollElement === null || effectiveScrollElement === void 0 ? void 0 : effectiveScrollElement.current)) {
|
|
167
|
+
const el = effectiveScrollElement.current;
|
|
168
|
+
const startOff = isWeapp ? effectiveStartOffsetRef.current : ((_a = startOffsetRef.current) !== null && _a !== void 0 ? _a : 0);
|
|
169
|
+
const scrollTarget = scrollOffset + startOff;
|
|
170
|
+
if (isH5) {
|
|
171
|
+
el.scrollTo({ top: scrollTarget });
|
|
172
|
+
}
|
|
173
|
+
else if (isWeapp) {
|
|
174
|
+
const scrollViewId = el.id || `_wf_${contentId}`;
|
|
175
|
+
if (!el.id)
|
|
176
|
+
el.id = scrollViewId;
|
|
177
|
+
getScrollViewContextNode(`#${scrollViewId}`).then((node) => {
|
|
178
|
+
var _a;
|
|
179
|
+
(_a = node === null || node === void 0 ? void 0 : node.scrollTo) === null || _a === void 0 ? void 0 : _a.call(node, { top: scrollTarget, animated: true, duration: 300 });
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
root.setStateBatch({ scrollOffset, isScrolling: true });
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
85
185
|
getScrollViewContextNode(`#${root.id}`).then((node) => {
|
|
86
186
|
node.scrollTo({
|
|
87
187
|
animated: true,
|
|
@@ -99,6 +199,7 @@ function WaterFlow(_a) {
|
|
|
99
199
|
}, [isScrolling$]);
|
|
100
200
|
/**
|
|
101
201
|
* 处理滚动阈值
|
|
202
|
+
* root 需入参:autoFind 从 pending→found 时 root 会重建,必须对新 root 重新订阅
|
|
102
203
|
*/
|
|
103
204
|
useEffect(() => {
|
|
104
205
|
const disposers = [
|
|
@@ -114,37 +215,190 @@ function WaterFlow(_a) {
|
|
|
114
215
|
disposer();
|
|
115
216
|
});
|
|
116
217
|
};
|
|
117
|
-
}, [onScrollToUpper, onScrollToLower]);
|
|
218
|
+
}, [root, onScrollToUpper, onScrollToLower]);
|
|
118
219
|
/**
|
|
119
220
|
* 处理 scrollIntoView
|
|
221
|
+
* 竞态:快速切换目标时,取消前一次滚动,避免后发先至
|
|
120
222
|
*/
|
|
121
223
|
useEffect(() => {
|
|
224
|
+
let cancelled = false;
|
|
122
225
|
handleScrollIntoView();
|
|
123
226
|
async function handleScrollIntoView() {
|
|
124
|
-
if (scrollIntoView)
|
|
125
|
-
|
|
126
|
-
|
|
227
|
+
if (!scrollIntoView)
|
|
228
|
+
return;
|
|
229
|
+
const targetNode = root.findNode(scrollIntoView);
|
|
230
|
+
if (!targetNode) {
|
|
231
|
+
nextTick(() => { if (!cancelled)
|
|
232
|
+
onScrollIntoViewComplete === null || onScrollIntoViewComplete === void 0 ? void 0 : onScrollIntoViewComplete(); });
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const targetSection = targetNode.section;
|
|
236
|
+
const doScroll = () => {
|
|
237
|
+
if (cancelled)
|
|
238
|
+
return;
|
|
239
|
+
scrollTo(targetNode.getState().scrollTop);
|
|
240
|
+
if (cancelled)
|
|
127
241
|
return;
|
|
242
|
+
nextTick(() => { if (!cancelled)
|
|
243
|
+
onScrollIntoViewComplete === null || onScrollIntoViewComplete === void 0 ? void 0 : onScrollIntoViewComplete(); });
|
|
244
|
+
};
|
|
245
|
+
if (!targetSection.getState().layouted) {
|
|
246
|
+
const order = targetSection.order;
|
|
247
|
+
root.setStateIn('renderRange', [
|
|
248
|
+
Math.min(renderRange$[0], order),
|
|
249
|
+
Math.max(renderRange$[1], order),
|
|
250
|
+
]);
|
|
251
|
+
nextTick(async () => {
|
|
252
|
+
await targetNode.section.layoutedSignal.promise;
|
|
253
|
+
if (cancelled)
|
|
254
|
+
return;
|
|
255
|
+
doScroll();
|
|
256
|
+
});
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
await targetSection.layoutedSignal.promise;
|
|
260
|
+
if (cancelled)
|
|
261
|
+
return;
|
|
262
|
+
doScroll();
|
|
263
|
+
}
|
|
264
|
+
return () => { cancelled = true; };
|
|
265
|
+
}, [scrollIntoView, renderRange$[0], renderRange$[1], onScrollIntoViewComplete]);
|
|
266
|
+
// scrollElement 模式下监听外部滚动,更新 root.scrollOffset;effectiveStartOffset 变化时重新同步;内嵌时 scrollRef 可能尚未就绪,需重试
|
|
267
|
+
useEffect(() => {
|
|
268
|
+
if (!useScrollElementMode || !effectiveScrollElement)
|
|
269
|
+
return;
|
|
270
|
+
let cancelled = false;
|
|
271
|
+
let teardown = null;
|
|
272
|
+
const maxRetries = 20;
|
|
273
|
+
const tryAttach = (retryCount = 0) => {
|
|
274
|
+
if (cancelled)
|
|
275
|
+
return;
|
|
276
|
+
const target = effectiveScrollElement.current;
|
|
277
|
+
if (!target) {
|
|
278
|
+
if (retryCount < maxRetries) {
|
|
279
|
+
setTimeout(() => tryAttach(retryCount + 1), 50);
|
|
128
280
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
const getStartOffset = () => { var _a; return (isWeapp ? effectiveStartOffsetRef.current : ((_a = startOffsetRef.current) !== null && _a !== void 0 ? _a : 0)); };
|
|
284
|
+
const handler = (e) => {
|
|
285
|
+
var _a, _b, _c, _d, _e, _f;
|
|
286
|
+
const scrollTop = isWeapp
|
|
287
|
+
? ((_e = (_b = (_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.scrollTop) !== null && _b !== void 0 ? _b : (_d = (_c = e === null || e === void 0 ? void 0 : e.mpEvent) === null || _c === void 0 ? void 0 : _c.detail) === null || _d === void 0 ? void 0 : _d.scrollTop) !== null && _e !== void 0 ? _e : 0)
|
|
288
|
+
: target.scrollTop;
|
|
289
|
+
const offset = scrollTop - getStartOffset();
|
|
290
|
+
const effectiveOffset = Math.max(0, offset);
|
|
291
|
+
const prevOffset = root.getState().scrollOffset;
|
|
292
|
+
const scrollDirection = prevOffset < effectiveOffset ? 'forward' : 'backward';
|
|
293
|
+
(_f = nodeCacheCtlRef.current) === null || _f === void 0 ? void 0 : _f.onScrollSample(effectiveOffset);
|
|
294
|
+
root.setStateBatch({
|
|
295
|
+
scrollDirection,
|
|
296
|
+
scrollOffset: effectiveOffset,
|
|
297
|
+
isScrolling: true,
|
|
298
|
+
});
|
|
299
|
+
};
|
|
300
|
+
if (isWeapp) {
|
|
301
|
+
if (!target.id)
|
|
302
|
+
target.id = `_wf_${contentId}`;
|
|
303
|
+
const scrollViewId = target.id;
|
|
304
|
+
const instance = Taro.getCurrentInstance();
|
|
305
|
+
const query = (instance === null || instance === void 0 ? void 0 : instance.page)
|
|
306
|
+
? Taro.createSelectorQuery().in(instance.page)
|
|
307
|
+
: Taro.createSelectorQuery();
|
|
308
|
+
query.select(`#${scrollViewId}`).scrollOffset().exec((res) => {
|
|
309
|
+
var _a;
|
|
310
|
+
if (cancelled)
|
|
139
311
|
return;
|
|
312
|
+
const info = res === null || res === void 0 ? void 0 : res[0];
|
|
313
|
+
if (info) {
|
|
314
|
+
const scrollTopVal = (_a = info.scrollTop) !== null && _a !== void 0 ? _a : 0;
|
|
315
|
+
const initialOffset = Math.max(0, scrollTopVal - getStartOffset());
|
|
316
|
+
root.setStateBatch({ scrollOffset: initialOffset, isScrolling: true });
|
|
140
317
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
const initialOffset = Math.max(0, target.scrollTop - getStartOffset());
|
|
322
|
+
root.setStateBatch({ scrollOffset: initialOffset, isScrolling: true });
|
|
144
323
|
}
|
|
324
|
+
target.addEventListener('scroll', handler, isWeapp ? undefined : { passive: true });
|
|
325
|
+
teardown = () => target.removeEventListener('scroll', handler);
|
|
326
|
+
};
|
|
327
|
+
tryAttach();
|
|
328
|
+
return () => {
|
|
329
|
+
cancelled = true;
|
|
330
|
+
teardown === null || teardown === void 0 ? void 0 : teardown();
|
|
331
|
+
};
|
|
332
|
+
}, [useScrollElementMode, effectiveScrollElement, root, effectiveStartOffset, contentId]);
|
|
333
|
+
// scrollHeight 变化时回调(props 优先,其次从 Context),便于 List 动高联动;防抖 150ms 上报
|
|
334
|
+
const reportHeight = onScrollHeightChange !== null && onScrollHeightChange !== void 0 ? onScrollHeightChange : scrollElementCtx === null || scrollElementCtx === void 0 ? void 0 : scrollElementCtx.reportNestedHeightChange;
|
|
335
|
+
useEffect(() => {
|
|
336
|
+
if (!reportHeight || scrollHeight$ <= 0)
|
|
337
|
+
return;
|
|
338
|
+
const timer = setTimeout(() => {
|
|
339
|
+
if (Math.abs(lastReportedHeightRef.current - scrollHeight$) < 1)
|
|
340
|
+
return;
|
|
341
|
+
lastReportedHeightRef.current = scrollHeight$;
|
|
342
|
+
reportHeight(scrollHeight$);
|
|
343
|
+
}, 150);
|
|
344
|
+
return () => clearTimeout(timer);
|
|
345
|
+
}, [scrollHeight$, reportHeight]);
|
|
346
|
+
// scrollElement 模式下监听容器尺寸:H5 用 ResizeObserver,小程序用 createSelectorQuery 轮询
|
|
347
|
+
useEffect(() => {
|
|
348
|
+
if (!useScrollElementMode || !effectiveScrollElement)
|
|
349
|
+
return;
|
|
350
|
+
const el = effectiveScrollElement.current;
|
|
351
|
+
if (!el)
|
|
352
|
+
return;
|
|
353
|
+
if (isWeapp) {
|
|
354
|
+
if (!el.id)
|
|
355
|
+
el.id = `_wf_${contentId}`;
|
|
356
|
+
const scrollViewId = el.id;
|
|
357
|
+
const measure = () => {
|
|
358
|
+
const instance = Taro.getCurrentInstance();
|
|
359
|
+
const query = (instance === null || instance === void 0 ? void 0 : instance.page)
|
|
360
|
+
? Taro.createSelectorQuery().in(instance.page)
|
|
361
|
+
: Taro.createSelectorQuery();
|
|
362
|
+
query.select(`#${scrollViewId}`).boundingClientRect().exec((res) => {
|
|
363
|
+
var _a;
|
|
364
|
+
const rect = res === null || res === void 0 ? void 0 : res[0];
|
|
365
|
+
if (rect && rect.height > 0 && rect.width > 0) {
|
|
366
|
+
const height = (_a = containerHeightRef.current) !== null && _a !== void 0 ? _a : rect.height;
|
|
367
|
+
root.setStateIn('containerSize', { width: rect.width, height });
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
};
|
|
371
|
+
measure();
|
|
372
|
+
const interval = setInterval(measure, 150);
|
|
373
|
+
return () => clearInterval(interval);
|
|
145
374
|
}
|
|
146
|
-
|
|
375
|
+
if (typeof ResizeObserver === 'undefined')
|
|
376
|
+
return;
|
|
377
|
+
const update = () => {
|
|
378
|
+
var _a;
|
|
379
|
+
const height = (_a = containerHeightRef.current) !== null && _a !== void 0 ? _a : el.clientHeight;
|
|
380
|
+
const width = el.clientWidth;
|
|
381
|
+
if (height > 0 && width > 0) {
|
|
382
|
+
root.setStateIn('containerSize', { width, height });
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
update();
|
|
386
|
+
const ro = new ResizeObserver(update);
|
|
387
|
+
ro.observe(el);
|
|
388
|
+
return () => ro.disconnect();
|
|
389
|
+
}, [useScrollElementMode, effectiveScrollElement, root, effectiveContainerHeight, contentId]);
|
|
390
|
+
// scrollElement 模式下只渲染内容 View(不渲染 ScrollView);内容高度须为 scrollHeight 以支持父级滚动;needAutoFind 且 pending 时 probe 渲染以便查找父容器
|
|
391
|
+
const renderView = useScrollElementMode || (!!needAutoFind && autoFindStatus === 'pending');
|
|
392
|
+
if (renderView) {
|
|
393
|
+
return createElement(View, {
|
|
394
|
+
ref: setContainerRef,
|
|
395
|
+
id: root.id,
|
|
396
|
+
style: Object.assign(Object.assign({}, style), { width: '100%', position: 'relative', height: scrollHeight$, pointerEvents: isScrolling$ ? 'none' : 'auto' }),
|
|
397
|
+
className,
|
|
398
|
+
}, sections);
|
|
399
|
+
}
|
|
147
400
|
return createElement(ScrollView, Object.assign({ id: root.id, style: Object.assign({ WebkitOverflowScrolling: 'touch', overflow: 'auto' }, style), className, scrollY: true, onScroll: handleScroll }, rest), createElement(View, {
|
|
401
|
+
ref: setContainerRef,
|
|
148
402
|
id: 'waterflow-root',
|
|
149
403
|
style: {
|
|
150
404
|
width: '100%',
|
|
@@ -153,7 +407,8 @@ function WaterFlow(_a) {
|
|
|
153
407
|
pointerEvents: isScrolling$ ? 'none' : 'auto',
|
|
154
408
|
},
|
|
155
409
|
}, sections));
|
|
156
|
-
}
|
|
410
|
+
};
|
|
411
|
+
const WaterFlow = forwardRef(InnerWaterFlow);
|
|
157
412
|
|
|
158
413
|
export { WaterFlow };
|
|
159
414
|
//# sourceMappingURL=water-flow.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"water-flow.js","sources":["../../../src/components/water-flow/water-flow.ts"],"sourcesContent":["import { BaseEventOrig, ScrollView, ScrollViewProps, View } from '@tarojs/components'\nimport { nextTick } from '@tarojs/taro'\nimport {\n Children,\n cloneElement,\n createElement,\n PropsWithChildren,\n ReactElement,\n useEffect,\n useId,\n useMemo,\n useRef,\n} from 'react'\n\nimport { debounce, getScrollViewContextNode } from '../../utils'\nimport { _FlowSectionProps } from './flow-section'\nimport { Root, RootEvents } from './root'\nimport { Section } from './section'\nimport { useMemoizedFn } from './use-memoized-fn'\nimport { useObservedAttr } from './use-observed-attr'\nimport { getSysInfo } from './utils'\n\nimport type { ScrollDirection, WaterFlowProps } from './interface'\n\ngetSysInfo()\n\nexport function WaterFlow({ children, ...props }: PropsWithChildren<WaterFlowProps>) {\n const {\n id,\n style = {},\n className,\n cacheCount = 1,\n onScrollToUpper,\n onScrollToLower,\n upperThresholdCount,\n lowerThresholdCount,\n scrollIntoView,\n ...rest\n } = props\n const defaultId = useId().replace(/:/g, '')\n /**\n * 初始化数据模型\n */\n const root = useMemo(() => {\n return new Root({\n id: id ?? defaultId,\n cacheCount,\n upperThresholdCount,\n lowerThresholdCount,\n })\n }, [id, cacheCount, upperThresholdCount, lowerThresholdCount])\n const isScrolling$ = useObservedAttr(root, 'isScrolling')\n const scrollHeight$ = useObservedAttr(root, 'scrollHeight')\n const renderRange$ = useObservedAttr(root, 'renderRange')\n const refEventOrig = useRef<BaseEventOrig>()\n\n /**\n * 滚动事件\n */\n const handleScroll = useMemoizedFn((ev: BaseEventOrig<ScrollViewProps.onScrollDetail>) => {\n refEventOrig.current = ev\n root.sections.forEach((section) => section.getNodeRenderRange())\n const { scrollTop } = ev.detail\n // 确定滚动方向\n const scrollDirection: ScrollDirection = root.getState().scrollOffset < scrollTop ? 'forward' : 'backward'\n // 设置滚动信息,包括方向和偏移量\n root.setStateBatch({\n scrollDirection: scrollDirection,\n scrollOffset: scrollTop,\n isScrolling: true,\n })\n })\n\n const sections = useMemo(() => {\n const [start, end] = renderRange$\n return Children.map(children, (child: ReactElement<PropsWithChildren<_FlowSectionProps>>, order) => {\n if (Object.is(child, null)) {\n return null\n }\n const sectionProps = child.props\n const sectionId = sectionProps.id || `section-${order}`\n const childCount = Children.count(sectionProps.children)\n let section = root.findSection(sectionId)\n if (section) {\n const originalCount = section.count\n if (childCount > originalCount) {\n section.pushNodes(childCount - originalCount)\n }\n } else {\n section = new Section(root, {\n id: sectionId,\n order,\n col: sectionProps.column ?? 1,\n rowGap: sectionProps.rowGap || 0,\n columnGap: sectionProps.columnGap || 0,\n count: Children.count(sectionProps.children),\n })\n }\n\n return cloneElement(child, { section, key: `${props.id}-${order}` })\n })?.slice(start, end + 1)\n }, [renderRange$[0], renderRange$[1], children, root, props.id])\n\n const scrollTo = useMemoizedFn((scrollOffset = 0) => {\n scrollOffset = Math.max(0, scrollOffset)\n if (root.getState().scrollOffset === scrollOffset) return\n getScrollViewContextNode(`#${root.id}`).then((node: any) => {\n node.scrollTo({\n animated: true,\n duration: 300,\n top: scrollOffset,\n })\n })\n })\n\n const resetScrolling = useMemoizedFn(() => {\n root.setStateIn('isScrolling', false)\n })\n\n const debouncedResetScrolling = debounce(resetScrolling)\n\n useEffect(() => {\n debouncedResetScrolling()\n }, [isScrolling$])\n\n /**\n * 处理滚动阈值\n */\n useEffect(() => {\n const disposers = [\n root.sub(\n RootEvents.ReachUpperThreshold,\n debounce(() => {\n onScrollToUpper?.(refEventOrig.current!)\n })\n ),\n root.sub(\n RootEvents.ReachLowerThreshold,\n debounce(() => {\n onScrollToLower?.(refEventOrig.current!)\n })\n ),\n ]\n return () => {\n disposers.forEach((disposer) => {\n disposer()\n })\n }\n }, [onScrollToUpper, onScrollToLower])\n\n /**\n * 处理 scrollIntoView\n */\n useEffect(() => {\n handleScrollIntoView()\n async function handleScrollIntoView() {\n if (scrollIntoView) {\n if (root.getState().scrollOffset > 0) {\n // 说明在自动滚动前手动滚动过了,不应该自动滚动了,避免造成困扰\n return\n }\n const targetNode = root.findNode(scrollIntoView)\n if (targetNode) {\n const targetSection = targetNode.section\n if (!targetSection.getState().layouted) {\n const order = targetSection.order\n root.setStateIn('renderRange', [renderRange$[0], order])\n nextTick(async () => {\n await targetNode.section.layoutedSignal.promise\n scrollTo(targetNode.getState().scrollTop)\n })\n return\n }\n await targetNode.section.layoutedSignal.promise\n scrollTo(targetNode.getState().scrollTop)\n }\n }\n }\n }, [scrollIntoView, renderRange$[0]])\n\n return createElement(\n ScrollView,\n {\n id: root.id,\n style: {\n WebkitOverflowScrolling: 'touch',\n overflow: 'auto',\n ...style,\n },\n className,\n scrollY: true,\n onScroll: handleScroll,\n ...rest,\n },\n createElement(\n View,\n {\n id: 'waterflow-root',\n style: {\n width: '100%',\n position: 'relative',\n height: scrollHeight$,\n pointerEvents: isScrolling$ ? 'none' : 'auto',\n },\n },\n sections\n )\n )\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAwBA,UAAU,EAAE;AAEN,SAAU,SAAS,CAAC,EAAyD,EAAA;AAAzD,IAAA,IAAA,EAAE,QAAQ,EAA+C,GAAA,EAAA,EAA1C,KAAK,GAAA,MAAA,CAAA,EAAA,EAApB,YAAsB,CAAF;AAC5C,IAAA,MAAM,EACJ,EAAE,EACF,KAAK,GAAG,EAAE,EACV,SAAS,EACT,UAAU,GAAG,CAAC,EACd,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EAEZ,GAAA,KAAK,EADJ,IAAI,GACL,MAAA,CAAA,KAAK,EAXH,CAAA,IAAA,EAAA,OAAA,EAAA,WAAA,EAAA,YAAA,EAAA,iBAAA,EAAA,iBAAA,EAAA,qBAAA,EAAA,qBAAA,EAAA,gBAAA,CAWL,CAAQ;IACT,MAAM,SAAS,GAAG,KAAK,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;AAC3C;;AAEG;AACH,IAAA,MAAM,IAAI,GAAG,OAAO,CAAC,MAAK;QACxB,OAAO,IAAI,IAAI,CAAC;AACd,YAAA,EAAE,EAAE,EAAE,KAAA,IAAA,IAAF,EAAE,KAAF,KAAA,CAAA,GAAA,EAAE,GAAI,SAAS;YACnB,UAAU;YACV,mBAAmB;YACnB,mBAAmB;AACpB,SAAA,CAAC;KACH,EAAE,CAAC,EAAE,EAAE,UAAU,EAAE,mBAAmB,EAAE,mBAAmB,CAAC,CAAC;IAC9D,MAAM,YAAY,GAAG,eAAe,CAAC,IAAI,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AO,EAAE,IAAI,EACb,QAAQ,EAAE,YAAY,EACnB,EAAA,IAAI,GAET,aAAa,CACX,IAAI,EACJ;AACE,QAAA,EAAE,EAAE,gBAAgB;AACpB,QAAA,KAAK,EAAE;AACL,YAAA,KAAK,EAAE,MAAM;AACb,YAAA,QAAQ,EAAE,UAAU;AACpB,YAAA,MAAM,EAAE,aAAa;YACrB,aAAa,EAAE,YAAY,GAAG,MAAM,GAAG,MAAM;AAC9C,SAAA;KACF,EACD,QAAQ,CACT,CACF;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"water-flow.js","sources":["../../../src/components/water-flow/water-flow.ts"],"sourcesContent":["import { BaseEventOrig, ScrollView, ScrollViewProps, View } from '@tarojs/components'\nimport Taro, { nextTick } from '@tarojs/taro'\nimport {\n Children,\n cloneElement,\n createElement,\n forwardRef,\n PropsWithChildren,\n ReactElement,\n useCallback,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n} from 'react'\n\nimport { debounce, getScrollViewContextNode } from '../../utils'\nimport {\n type ScrollElementContextValueShape,\n ScrollElementContextOrFallback,\n} from '../../utils/scrollElementContext'\nimport { useMeasureStartOffset } from '../list/hooks/useMeasureStartOffset'\nimport { useMeasureStartOffsetWeapp } from '../list/hooks/useMeasureStartOffsetWeapp'\nimport { useScrollParentAutoFind } from '../list/hooks/useScrollParentAutoFind'\nimport { _FlowSectionProps } from './flow-section'\nimport { Root, RootEvents } from './root'\nimport { Section } from './section'\nimport { useMemoizedFn } from './use-memoized-fn'\nimport { useObservedAttr } from './use-observed-attr'\nimport { getSysInfo, isH5, isWeapp } from './utils'\nimport { createWaterFlowNodeCacheControl } from './water-flow-node-cache'\n\nimport type { ScrollDirection, WaterFlowProps } from './interface'\n\ngetSysInfo()\n\nconst InnerWaterFlow = (\n { children, ...props }: PropsWithChildren<WaterFlowProps>,\n ref: React.ForwardedRef<HTMLElement>\n) => {\n const {\n id,\n style = {},\n className,\n cacheCount = 1,\n onScrollToUpper,\n onScrollToLower,\n upperThresholdCount,\n lowerThresholdCount,\n scrollIntoView,\n nestedScroll,\n scrollElement,\n startOffset,\n containerHeight,\n onScrollHeightChange,\n onScrollIntoViewComplete,\n ...rest\n } = props\n const flowType = nestedScroll === true ? 'nested' : 'default'\n // 从 ScrollElementContext 获取 scrollRef(List/ScrollView 内嵌时提供);无 Context 时兜底为 fallback\n const scrollElementCtx = useContext(ScrollElementContextOrFallback) as ScrollElementContextValueShape | null\n const contentWrapperRef = useRef<HTMLDivElement>(null)\n const setContainerRef = useCallback(\n (el: HTMLElement | null) => {\n (contentWrapperRef as React.MutableRefObject<HTMLElement | null>).current = el\n if (typeof ref === 'function') ref(el)\n else if (ref) (ref as React.MutableRefObject<HTMLElement | null>).current = el\n },\n [ref]\n )\n const defaultId = useId().replace(/:/g, '')\n const contentId = useMemo(() => id ?? defaultId, [id, defaultId])\n const needAutoFind =\n flowType === 'nested' &&\n !scrollElement &&\n !scrollElementCtx?.scrollRef &&\n (isH5 || isWeapp)\n const { scrollParentRef: autoFoundRef, status: autoFindStatus } = useScrollParentAutoFind(\n contentWrapperRef,\n { enabled: !!needAutoFind, isHorizontal: false, contentId: isWeapp ? contentId : undefined }\n )\n const effectiveScrollElement =\n scrollElement ??\n scrollElementCtx?.scrollRef ??\n (needAutoFind && autoFindStatus === 'found' ? autoFoundRef : null)\n const ctxStart = scrollElementCtx?.startOffset\n const hasExplicitStartOffset = ctxStart != null && ctxStart > 0\n const needMeasureStartOffset =\n flowType === 'nested' &&\n effectiveScrollElement &&\n isH5 &&\n startOffset == null &&\n !hasExplicitStartOffset\n const needMeasureStartOffsetWeapp =\n flowType === 'nested' &&\n effectiveScrollElement &&\n isWeapp &&\n startOffset == null &&\n !hasExplicitStartOffset\n const measuredStartOffset = useMeasureStartOffset(\n effectiveScrollElement ?? { current: null },\n contentWrapperRef,\n { enabled: !!needMeasureStartOffset, isHorizontal: false }\n )\n const effectiveStartOffsetRef = useRef(0)\n const measuredStartOffsetWeapp = useMeasureStartOffsetWeapp(\n effectiveScrollElement ?? { current: null },\n contentId,\n { enabled: !!needMeasureStartOffsetWeapp, isHorizontal: false, startOffsetRef: effectiveStartOffsetRef }\n )\n const effectiveStartOffset =\n startOffset ??\n (ctxStart != null && ctxStart > 0 ? ctxStart : null) ??\n measuredStartOffset ??\n measuredStartOffsetWeapp ??\n 0\n\n const effectiveContainerHeight = containerHeight ?? scrollElementCtx?.containerHeight\n\n const startOffsetRef = useRef(effectiveStartOffset)\n const containerHeightRef = useRef(effectiveContainerHeight)\n const lastReportedHeightRef = useRef<number>(0)\n startOffsetRef.current = effectiveStartOffset\n if (!needMeasureStartOffsetWeapp) {\n effectiveStartOffsetRef.current = effectiveStartOffset\n }\n containerHeightRef.current = effectiveContainerHeight\n\n const useScrollElementMode =\n flowType === 'nested' && !!(effectiveScrollElement && (isH5 || isWeapp))\n if (flowType === 'nested' && !effectiveScrollElement && (isH5 || isWeapp) && autoFindStatus === 'not-found') {\n // eslint-disable-next-line no-console\n console.warn('[WaterFlow] nestedScroll 模式但无 scrollElement(props/Context/自动查找),回退为 default,将渲染自有 ScrollView')\n }\n /**\n * 初始化数据模型\n */\n const root = useMemo(() => {\n return new Root({\n id: contentId,\n cacheCount,\n upperThresholdCount,\n lowerThresholdCount,\n skipContainerMeasure: useScrollElementMode || (!!needAutoFind && autoFindStatus === 'pending'),\n })\n }, [contentId, upperThresholdCount, lowerThresholdCount, useScrollElementMode, needAutoFind, autoFindStatus])\n\n /** props 动态修改 cacheCount 时同步到 Root,避免重建 Root;并收敛快滑单边放大到新的基线 */\n useLayoutEffect(() => {\n root.cacheCount = cacheCount\n root.setNodeCacheRange(cacheCount, cacheCount)\n }, [root, cacheCount])\n const isScrolling$ = useObservedAttr(root, 'isScrolling')\n const scrollHeight$ = useObservedAttr(root, 'scrollHeight')\n const renderRange$ = useObservedAttr(root, 'renderRange')\n const refEventOrig = useRef<BaseEventOrig>()\n const nodeCacheCtlRef = useRef<ReturnType<typeof createWaterFlowNodeCacheControl> | null>(null)\n\n useEffect(() => {\n const ctl = createWaterFlowNodeCacheControl(root, () => root.cacheCount)\n nodeCacheCtlRef.current = ctl\n return () => {\n ctl.dispose()\n nodeCacheCtlRef.current = null\n }\n }, [root])\n\n /**\n * 滚动事件\n */\n const handleScroll = useMemoizedFn((ev: BaseEventOrig<ScrollViewProps.onScrollDetail>) => {\n refEventOrig.current = ev\n const { scrollTop } = ev.detail\n nodeCacheCtlRef.current?.onScrollSample(scrollTop)\n const scrollDirection: ScrollDirection = root.getState().scrollOffset < scrollTop ? 'forward' : 'backward'\n root.setStateBatch({\n scrollDirection: scrollDirection,\n scrollOffset: scrollTop,\n isScrolling: true,\n })\n })\n\n const sections = useMemo(() => {\n const [start, end] = renderRange$\n return Children.map(children, (child: ReactElement<PropsWithChildren<_FlowSectionProps>>, order) => {\n if (Object.is(child, null)) {\n return null\n }\n const sectionProps = child.props\n const sectionId = sectionProps.id || `section-${order}`\n const childCount = Children.count(sectionProps.children)\n let section = root.findSection(sectionId)\n if (section) {\n const originalCount = section.count\n if (childCount > originalCount) {\n section.pushNodesStructuralOnly(childCount - originalCount)\n }\n } else {\n section = new Section(root, {\n id: sectionId,\n order,\n col: sectionProps.column ?? 1,\n rowGap: sectionProps.rowGap || 0,\n columnGap: sectionProps.columnGap || 0,\n count: Children.count(sectionProps.children),\n })\n }\n\n return cloneElement(child, { section, key: `${props.id}-${order}` })\n })?.slice(start, end + 1)\n }, [renderRange$[0], renderRange$[1], children, root, props.id])\n\n /** 配对 pushNodesStructuralOnly:在 layout 阶段完成 Section 状态,避免 useMemo 内 setState 告警 */\n useLayoutEffect(() => {\n Children.forEach(children, (child: ReactElement<PropsWithChildren<_FlowSectionProps>>, order) => {\n if (Object.is(child, null)) {\n return\n }\n const sectionProps = child.props\n const sectionId = sectionProps.id || `section-${order}`\n root.findSection(sectionId)?.finalizePushNodesStateIfNeeded()\n })\n }, [children, root])\n\n const scrollTo = useMemoizedFn((scrollOffset = 0) => {\n scrollOffset = Math.max(0, scrollOffset)\n if (root.getState().scrollOffset === scrollOffset) return\n if (useScrollElementMode && effectiveScrollElement?.current) {\n const el = effectiveScrollElement.current as any\n const startOff = isWeapp ? effectiveStartOffsetRef.current : (startOffsetRef.current ?? 0)\n const scrollTarget = scrollOffset + startOff\n if (isH5) {\n el.scrollTo({ top: scrollTarget })\n } else if (isWeapp) {\n const scrollViewId = el.id || `_wf_${contentId}`\n if (!el.id) el.id = scrollViewId\n getScrollViewContextNode(`#${scrollViewId}`).then((node: any) => {\n node?.scrollTo?.({ top: scrollTarget, animated: true, duration: 300 })\n })\n }\n root.setStateBatch({ scrollOffset, isScrolling: true })\n return\n }\n getScrollViewContextNode(`#${root.id}`).then((node: any) => {\n node.scrollTo({\n animated: true,\n duration: 300,\n top: scrollOffset,\n })\n })\n })\n\n const resetScrolling = useMemoizedFn(() => {\n root.setStateIn('isScrolling', false)\n })\n\n const debouncedResetScrolling = debounce(resetScrolling)\n\n useEffect(() => {\n debouncedResetScrolling()\n }, [isScrolling$])\n\n /**\n * 处理滚动阈值\n * root 需入参:autoFind 从 pending→found 时 root 会重建,必须对新 root 重新订阅\n */\n useEffect(() => {\n const disposers = [\n root.sub(\n RootEvents.ReachUpperThreshold,\n debounce(() => {\n onScrollToUpper?.(refEventOrig.current!)\n })\n ),\n root.sub(\n RootEvents.ReachLowerThreshold,\n debounce(() => {\n onScrollToLower?.(refEventOrig.current!)\n })\n ),\n ]\n return () => {\n disposers.forEach((disposer) => {\n disposer()\n })\n }\n }, [root, onScrollToUpper, onScrollToLower])\n\n /**\n * 处理 scrollIntoView\n * 竞态:快速切换目标时,取消前一次滚动,避免后发先至\n */\n useEffect(() => {\n let cancelled = false\n handleScrollIntoView()\n async function handleScrollIntoView() {\n if (!scrollIntoView) return\n const targetNode = root.findNode(scrollIntoView)\n if (!targetNode) {\n nextTick(() => { if (!cancelled) onScrollIntoViewComplete?.() })\n return\n }\n const targetSection = targetNode.section\n const doScroll = () => {\n if (cancelled) return\n scrollTo(targetNode.getState().scrollTop)\n if (cancelled) return\n nextTick(() => { if (!cancelled) onScrollIntoViewComplete?.() })\n }\n if (!targetSection.getState().layouted) {\n const order = targetSection.order\n root.setStateIn('renderRange', [\n Math.min(renderRange$[0], order),\n Math.max(renderRange$[1], order),\n ])\n nextTick(async () => {\n await targetNode.section.layoutedSignal.promise\n if (cancelled) return\n doScroll()\n })\n return\n }\n await targetSection.layoutedSignal.promise\n if (cancelled) return\n doScroll()\n }\n return () => { cancelled = true }\n }, [scrollIntoView, renderRange$[0], renderRange$[1], onScrollIntoViewComplete])\n\n // scrollElement 模式下监听外部滚动,更新 root.scrollOffset;effectiveStartOffset 变化时重新同步;内嵌时 scrollRef 可能尚未就绪,需重试\n useEffect(() => {\n if (!useScrollElementMode || !effectiveScrollElement) return\n\n let cancelled = false\n let teardown: (() => void) | null = null\n const maxRetries = 20\n\n const tryAttach = (retryCount = 0) => {\n if (cancelled) return\n const target = effectiveScrollElement.current as any\n if (!target) {\n if (retryCount < maxRetries) {\n setTimeout(() => tryAttach(retryCount + 1), 50)\n }\n return\n }\n\n const getStartOffset = () => (isWeapp ? effectiveStartOffsetRef.current : (startOffsetRef.current ?? 0))\n\n const handler = (e?: any) => {\n const scrollTop = isWeapp\n ? (e?.target?.scrollTop ?? e?.mpEvent?.detail?.scrollTop ?? 0)\n : target.scrollTop\n const offset = scrollTop - getStartOffset()\n const effectiveOffset = Math.max(0, offset)\n const prevOffset = root.getState().scrollOffset\n const scrollDirection: ScrollDirection = prevOffset < effectiveOffset ? 'forward' : 'backward'\n\n nodeCacheCtlRef.current?.onScrollSample(effectiveOffset)\n root.setStateBatch({\n scrollDirection,\n scrollOffset: effectiveOffset,\n isScrolling: true,\n })\n }\n\n if (isWeapp) {\n if (!target.id) target.id = `_wf_${contentId}`\n const scrollViewId = target.id\n const instance = Taro.getCurrentInstance()\n const query = instance?.page\n ? Taro.createSelectorQuery().in(instance.page as any)\n : Taro.createSelectorQuery()\n query.select(`#${scrollViewId}`).scrollOffset().exec((res) => {\n if (cancelled) return\n const info = res?.[0]\n if (info) {\n const scrollTopVal = info.scrollTop ?? 0\n const initialOffset = Math.max(0, scrollTopVal - getStartOffset())\n root.setStateBatch({ scrollOffset: initialOffset, isScrolling: true })\n }\n })\n } else {\n const initialOffset = Math.max(0, target.scrollTop - getStartOffset())\n root.setStateBatch({ scrollOffset: initialOffset, isScrolling: true })\n }\n\n target.addEventListener('scroll', handler, isWeapp ? undefined : { passive: true })\n teardown = () => target.removeEventListener('scroll', handler)\n }\n\n tryAttach()\n return () => {\n cancelled = true\n teardown?.()\n }\n }, [useScrollElementMode, effectiveScrollElement, root, effectiveStartOffset, contentId])\n\n // scrollHeight 变化时回调(props 优先,其次从 Context),便于 List 动高联动;防抖 150ms 上报\n const reportHeight = onScrollHeightChange ?? scrollElementCtx?.reportNestedHeightChange\n useEffect(() => {\n if (!reportHeight || scrollHeight$ <= 0) return\n const timer = setTimeout(() => {\n if (Math.abs(lastReportedHeightRef.current - scrollHeight$) < 1) return\n lastReportedHeightRef.current = scrollHeight$\n reportHeight(scrollHeight$)\n }, 150)\n return () => clearTimeout(timer)\n }, [scrollHeight$, reportHeight])\n\n // scrollElement 模式下监听容器尺寸:H5 用 ResizeObserver,小程序用 createSelectorQuery 轮询\n useEffect(() => {\n if (!useScrollElementMode || !effectiveScrollElement) return\n const el = effectiveScrollElement.current as any\n if (!el) return\n\n if (isWeapp) {\n if (!el.id) el.id = `_wf_${contentId}`\n const scrollViewId = el.id\n const measure = () => {\n const instance = Taro.getCurrentInstance()\n const query = instance?.page\n ? Taro.createSelectorQuery().in(instance.page as any)\n : Taro.createSelectorQuery()\n query.select(`#${scrollViewId}`).boundingClientRect().exec((res) => {\n const rect = res?.[0]\n if (rect && rect.height > 0 && rect.width > 0) {\n const height = containerHeightRef.current ?? rect.height\n root.setStateIn('containerSize', { width: rect.width, height })\n }\n })\n }\n measure()\n const interval = setInterval(measure, 150)\n return () => clearInterval(interval)\n }\n\n if (typeof ResizeObserver === 'undefined') return\n const update = () => {\n const height = containerHeightRef.current ?? el.clientHeight\n const width = el.clientWidth\n if (height > 0 && width > 0) {\n root.setStateIn('containerSize', { width, height })\n }\n }\n update()\n const ro = new ResizeObserver(update)\n ro.observe(el)\n return () => ro.disconnect()\n }, [useScrollElementMode, effectiveScrollElement, root, effectiveContainerHeight, contentId])\n\n // scrollElement 模式下只渲染内容 View(不渲染 ScrollView);内容高度须为 scrollHeight 以支持父级滚动;needAutoFind 且 pending 时 probe 渲染以便查找父容器\n const renderView =\n useScrollElementMode || (!!needAutoFind && autoFindStatus === 'pending')\n if (renderView) {\n return createElement(\n View,\n {\n ref: setContainerRef as any,\n id: root.id,\n style: {\n ...style,\n width: '100%',\n position: 'relative',\n height: scrollHeight$,\n pointerEvents: isScrolling$ ? 'none' : 'auto',\n },\n className,\n },\n sections\n )\n }\n\n return createElement(\n ScrollView,\n {\n id: root.id,\n style: {\n WebkitOverflowScrolling: 'touch',\n overflow: 'auto',\n ...style,\n },\n className,\n scrollY: true,\n onScroll: handleScroll,\n ...rest,\n },\n createElement(\n View,\n {\n ref: setContainerRef as any,\n id: 'waterflow-root',\n style: {\n width: '100%',\n position: 'relative',\n height: scrollHeight$,\n pointerEvents: isScrolling$ ? 'none' : 'auto',\n },\n },\n sections\n )\n )\n}\n\nexport const WaterFlow = forwardRef<HTMLElement, PropsWithChildren<WaterFlowProps>>(InnerWaterFlow)\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAoCA,UAAU,EAAE;AAEZ,MAAM,cAAc,GAAG,CACrB,EAAyD,EACzD,GAAoC,KAClC;;AAFF,IAAA,IAAA,EAAE,QAAQ,EAA+C,GAAA,EAAA,EAA1C,KAAK,GAAA,MAAA,CAAA,EAAA,EAApB,YAAsB,CAAF;AAGpB,IAAA,MAAM,EACJ,EAAE,EACF,KAAK,GAAG,EAAE,EACV,SAAS,EACT,UAAU,GAAG,CAAC,EACd,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,mBAAm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,SAAS,GAAG,UAAU,CAAiD,cAAc;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import './components/index.js';
|
|
2
2
|
import './utils/index.js';
|
|
3
|
+
export { ScrollElementContextOrFallback as ListScrollElementContext } from './utils/scrollElementContext.js';
|
|
3
4
|
export { List, accumulate, isShaking } from './components/list/index.js';
|
|
4
5
|
export { ListItem } from './components/list/ListItem.js';
|
|
6
|
+
export { NoMore } from './components/list/NoMore.js';
|
|
5
7
|
export { StickyHeader } from './components/list/StickyHeader.js';
|
|
6
8
|
export { StickySection } from './components/list/StickySection.js';
|
|
7
9
|
export { VirtualList } from './components/virtual-list/index.js';
|
|
@@ -14,5 +16,6 @@ export { getRectSize, getRectSizeSync, getScrollViewContextNode } from './utils/
|
|
|
14
16
|
export { defaultItemKey, getOffsetForIndexAndAlignment } from './utils/helper.js';
|
|
15
17
|
export { debounce, omit, throttle } from './utils/lodash.js';
|
|
16
18
|
export { getMiddleNumber, isCosDistributing } from './utils/math.js';
|
|
19
|
+
export { findScrollParent, findScrollParentTaro, isScrollableElement } from './utils/scrollParent.js';
|
|
17
20
|
export { cancelTimeout, requestTimeout } from './utils/timer.js';
|
|
18
21
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -3,5 +3,6 @@ export { getRectSize, getRectSizeSync, getScrollViewContextNode } from './dom.js
|
|
|
3
3
|
export { defaultItemKey, getOffsetForIndexAndAlignment } from './helper.js';
|
|
4
4
|
export { debounce, omit, throttle } from './lodash.js';
|
|
5
5
|
export { getMiddleNumber, isCosDistributing } from './math.js';
|
|
6
|
+
export { findScrollParent, findScrollParentTaro, isScrollableElement } from './scrollParent.js';
|
|
6
7
|
export { cancelTimeout, requestTimeout } from './timer.js';
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MutableRefObject } from 'react';
|
|
2
|
+
/** 与 ScrollElementContextValue 同构,components-react 未导出时兜底 */
|
|
3
|
+
export interface ScrollElementContextValueShape {
|
|
4
|
+
scrollRef: MutableRefObject<HTMLElement | null>;
|
|
5
|
+
containerHeight: number;
|
|
6
|
+
startOffset: number;
|
|
7
|
+
reportNestedHeightChange?: (scrollHeight: number) => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 当 @tarojs/components-react 未导出 ScrollElementContext 时(版本过旧)兜底,
|
|
11
|
+
* 避免 useContext(undefined) 报错。等效于无 Context,useContext 返回 null。
|
|
12
|
+
*/
|
|
13
|
+
export declare const FALLBACK_SCROLL_ELEMENT_CTX: import("react").Context<ScrollElementContextValueShape>;
|
|
14
|
+
/** 安全获取 ScrollElementContext:存在则用原版,否则用兜底 */
|
|
15
|
+
export declare const ScrollElementContextOrFallback: import("react").Context<ScrollElementContextValueShape>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as ComponentsReact from '@tarojs/components-react';
|
|
2
|
+
import { createContext } from 'react';
|
|
3
|
+
|
|
4
|
+
var _a;
|
|
5
|
+
/**
|
|
6
|
+
* 当 @tarojs/components-react 未导出 ScrollElementContext 时(版本过旧)兜底,
|
|
7
|
+
* 避免 useContext(undefined) 报错。等效于无 Context,useContext 返回 null。
|
|
8
|
+
*/
|
|
9
|
+
const FALLBACK_SCROLL_ELEMENT_CTX = createContext(null);
|
|
10
|
+
/** 安全获取 ScrollElementContext:存在则用原版,否则用兜底 */
|
|
11
|
+
const ScrollElementContextOrFallback = (_a = ComponentsReact.ScrollElementContext) !== null && _a !== void 0 ? _a : FALLBACK_SCROLL_ELEMENT_CTX;
|
|
12
|
+
|
|
13
|
+
export { FALLBACK_SCROLL_ELEMENT_CTX, ScrollElementContextOrFallback };
|
|
14
|
+
//# sourceMappingURL=scrollElementContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrollElementContext.js","sources":["../../src/utils/scrollElementContext.ts"],"sourcesContent":["import * as ComponentsReact from '@tarojs/components-react'\nimport { createContext } from 'react'\n\nimport type { MutableRefObject } from 'react'\n\n/** 与 ScrollElementContextValue 同构,components-react 未导出时兜底 */\nexport interface ScrollElementContextValueShape {\n scrollRef: MutableRefObject<HTMLElement | null>\n containerHeight: number\n startOffset: number\n reportNestedHeightChange?: (scrollHeight: number) => void\n}\n\n/**\n * 当 @tarojs/components-react 未导出 ScrollElementContext 时(版本过旧)兜底,\n * 避免 useContext(undefined) 报错。等效于无 Context,useContext 返回 null。\n */\nexport const FALLBACK_SCROLL_ELEMENT_CTX =\n createContext<ScrollElementContextValueShape | null>(null)\n\n/** 安全获取 ScrollElementContext:存在则用原版,否则用兜底 */\nexport const ScrollElementContextOrFallback =\n (ComponentsReact as { ScrollElementContext?: typeof FALLBACK_SCROLL_ELEMENT_CTX }).ScrollElementContext ??\n FALLBACK_SCROLL_ELEMENT_CTX\n"],"names":[],"mappings":";;;;AAaA;;;AAGG;MACU,2BAA2B,GACtC,aAAa,CAAwC,IAAI;AAE3D;AACa,MAAA,8BAA8B,GACzC,CAAA,EAAA,GAAC,eAAiF,CAAC,oBAAoB,MACvG,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA;;;;"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 查找元素的真实滚动父节点。
|
|
3
|
+
* 用于 nestedScroll 模式下无 props/Context 时自动获取 scrollElement。
|
|
4
|
+
*
|
|
5
|
+
* 策略:
|
|
6
|
+
* 1. 优先命中 Taro ScrollView 类名 .taro-scroll
|
|
7
|
+
* 2. 回退:向上遍历找通用可滚动祖先
|
|
8
|
+
*
|
|
9
|
+
* 严格条件(均需满足):
|
|
10
|
+
* - overflow 为 auto | scroll | overlay
|
|
11
|
+
* - scrollHeight > clientHeight(纵向)或 scrollWidth > clientWidth(横向)
|
|
12
|
+
* - 在 document.body 前停止
|
|
13
|
+
*/
|
|
14
|
+
import type { TaroElement } from '@tarojs/runtime';
|
|
15
|
+
/**
|
|
16
|
+
* 判断元素是否可滚动(严格:overflow 可滚动 + 实际有溢出)
|
|
17
|
+
*/
|
|
18
|
+
export declare function isScrollableElement(el: HTMLElement | null, vertical?: boolean): el is HTMLElement;
|
|
19
|
+
/**
|
|
20
|
+
* 从给定元素向上查找最近的滚动父节点。
|
|
21
|
+
* 优先匹配 .taro-scroll,未命中则按通用可滚动条件查找。
|
|
22
|
+
*/
|
|
23
|
+
export declare function findScrollParent(el: HTMLElement | null, vertical?: boolean): HTMLElement | null;
|
|
24
|
+
/**
|
|
25
|
+
* 小程序端:基于 Taro 虚拟 DOM 查找父级 scroll-view。
|
|
26
|
+
* 从 contentId 对应节点沿 parentNode 向上遍历,找到 nodeName === 'scroll-view' 的节点。
|
|
27
|
+
*
|
|
28
|
+
* 仅用于小程序环境,H5 请使用 findScrollParent。
|
|
29
|
+
*
|
|
30
|
+
* @param contentId - content 节点的 id(需在 eventSource 中已注册)
|
|
31
|
+
* @returns 找到的 TaroElement(scroll-view)或 null
|
|
32
|
+
*/
|
|
33
|
+
export declare function findScrollParentTaro(contentId: string): TaroElement | null;
|