@tarojs/components-advanced 4.2.0 → 4.2.1-beta.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 (85) hide show
  1. package/dist/components/index.js +2 -0
  2. package/dist/components/index.js.map +1 -1
  3. package/dist/components/list/NoMore.d.ts +30 -0
  4. package/dist/components/list/NoMore.js +10 -0
  5. package/dist/components/list/NoMore.js.map +1 -0
  6. package/dist/components/list/hooks/useItemSizeCache.d.ts +13 -0
  7. package/dist/components/list/hooks/useItemSizeCache.js +40 -0
  8. package/dist/components/list/hooks/useItemSizeCache.js.map +1 -0
  9. package/dist/components/list/hooks/useListNestedScroll.d.ts +18 -0
  10. package/dist/components/list/hooks/useListNestedScroll.js +61 -0
  11. package/dist/components/list/hooks/useListNestedScroll.js.map +1 -0
  12. package/dist/components/list/hooks/useListScrollElementAttach.d.ts +25 -0
  13. package/dist/components/list/hooks/useListScrollElementAttach.js +88 -0
  14. package/dist/components/list/hooks/useListScrollElementAttach.js.map +1 -0
  15. package/dist/components/list/hooks/useListScrollElementAttachWeapp.d.ts +15 -0
  16. package/dist/components/list/hooks/useListScrollElementAttachWeapp.js +135 -0
  17. package/dist/components/list/hooks/useListScrollElementAttachWeapp.js.map +1 -0
  18. package/dist/components/list/hooks/useMeasureStartOffset.d.ts +12 -0
  19. package/dist/components/list/hooks/useMeasureStartOffset.js +84 -0
  20. package/dist/components/list/hooks/useMeasureStartOffset.js.map +1 -0
  21. package/dist/components/list/hooks/useMeasureStartOffsetWeapp.d.ts +14 -0
  22. package/dist/components/list/hooks/useMeasureStartOffsetWeapp.js +87 -0
  23. package/dist/components/list/hooks/useMeasureStartOffsetWeapp.js.map +1 -0
  24. package/dist/components/list/hooks/useRefresher.d.ts +80 -0
  25. package/dist/components/list/hooks/useRefresher.js +561 -0
  26. package/dist/components/list/hooks/useRefresher.js.map +1 -0
  27. package/dist/components/list/hooks/useResizeObserver.d.ts +29 -0
  28. package/dist/components/list/hooks/useResizeObserver.js +153 -0
  29. package/dist/components/list/hooks/useResizeObserver.js.map +1 -0
  30. package/dist/components/list/hooks/useScrollCorrection.d.ts +19 -0
  31. package/dist/components/list/hooks/useScrollCorrection.js +74 -0
  32. package/dist/components/list/hooks/useScrollCorrection.js.map +1 -0
  33. package/dist/components/list/hooks/useScrollParentAutoFind.d.ts +20 -0
  34. package/dist/components/list/hooks/useScrollParentAutoFind.js +81 -0
  35. package/dist/components/list/hooks/useScrollParentAutoFind.js.map +1 -0
  36. package/dist/components/list/index.d.ts +64 -7
  37. package/dist/components/list/index.js +1081 -162
  38. package/dist/components/list/index.js.map +1 -1
  39. package/dist/components/list/utils.d.ts +28 -0
  40. package/dist/components/list/utils.js +41 -0
  41. package/dist/components/list/utils.js.map +1 -0
  42. package/dist/components/virtual-list/vue/list.d.ts +12 -12
  43. package/dist/components/virtual-waterfall/vue/waterfall.d.ts +11 -11
  44. package/dist/components/water-flow/flow-item.js +18 -11
  45. package/dist/components/water-flow/flow-item.js.map +1 -1
  46. package/dist/components/water-flow/flow-section.js +1 -1
  47. package/dist/components/water-flow/flow-section.js.map +1 -1
  48. package/dist/components/water-flow/index.d.ts +1 -1
  49. package/dist/components/water-flow/interface.d.ts +32 -2
  50. package/dist/components/water-flow/node.d.ts +3 -0
  51. package/dist/components/water-flow/node.js +34 -1
  52. package/dist/components/water-flow/node.js.map +1 -1
  53. package/dist/components/water-flow/root.d.ts +39 -4
  54. package/dist/components/water-flow/root.js +144 -44
  55. package/dist/components/water-flow/root.js.map +1 -1
  56. package/dist/components/water-flow/section.d.ts +11 -1
  57. package/dist/components/water-flow/section.js +81 -19
  58. package/dist/components/water-flow/section.js.map +1 -1
  59. package/dist/components/water-flow/utils.d.ts +4 -0
  60. package/dist/components/water-flow/utils.js +5 -1
  61. package/dist/components/water-flow/utils.js.map +1 -1
  62. package/dist/components/water-flow/water-flow-node-cache.d.ts +24 -0
  63. package/dist/components/water-flow/water-flow-node-cache.js +161 -0
  64. package/dist/components/water-flow/water-flow-node-cache.js.map +1 -0
  65. package/dist/components/water-flow/water-flow.d.ts +2 -3
  66. package/dist/components/water-flow/water-flow.js +316 -36
  67. package/dist/components/water-flow/water-flow.js.map +1 -1
  68. package/dist/index.js +4 -0
  69. package/dist/index.js.map +1 -1
  70. package/dist/utils/dom.d.ts +2 -2
  71. package/dist/utils/dom.js +7 -6
  72. package/dist/utils/dom.js.map +1 -1
  73. package/dist/utils/index.d.ts +2 -0
  74. package/dist/utils/index.js +2 -0
  75. package/dist/utils/index.js.map +1 -1
  76. package/dist/utils/scrollElementContext.d.ts +15 -0
  77. package/dist/utils/scrollElementContext.js +14 -0
  78. package/dist/utils/scrollElementContext.js.map +1 -0
  79. package/dist/utils/scrollParent.d.ts +33 -0
  80. package/dist/utils/scrollParent.js +88 -0
  81. package/dist/utils/scrollParent.js.map +1 -0
  82. package/dist/utils/weapp-scope.d.ts +7 -0
  83. package/dist/utils/weapp-scope.js +20 -0
  84. package/dist/utils/weapp-scope.js.map +1 -0
  85. package/package.json +9 -8
@@ -15,9 +15,7 @@ const useFlowItemPositioner = () => {
15
15
  const scrollTop$ = useObservedAttr(nodeModel, 'scrollTop');
16
16
  return {
17
17
  resize: useMemoizedFn(() => {
18
- if (!isWeb()) {
19
- nodeModel.pub(NodeEvents.Resize);
20
- }
18
+ nodeModel.pub(NodeEvents.Resize);
21
19
  }),
22
20
  top: top$,
23
21
  scrollTop: scrollTop$,
@@ -35,32 +33,41 @@ function FlowItemContainer(_a) {
35
33
  const itemStyle = useMemo(() => {
36
34
  const baseStyle = {
37
35
  width: '100%',
38
- minHeight: node.section.defaultSize,
36
+ position: 'absolute',
37
+ top: 0,
38
+ left: 0,
39
+ transform: `translate3d(0px, ${top$}px, 0px)`,
39
40
  };
40
41
  if (!layouted$) {
41
- return baseStyle;
42
+ return Object.assign(Object.assign({}, baseStyle), { minHeight: node.section.defaultSize });
42
43
  }
43
- Reflect.deleteProperty(baseStyle, 'minHeight');
44
- return Object.assign(Object.assign({}, baseStyle), { height: height$, transition: 'transform 20ms cubic-bezier(0.075, 0.82, 0.165, 1)', willChange: 'transform', position: 'absolute', top: 0, left: 0, transform: `translate3d(0px, ${top$}px, 0px)` });
44
+ return Object.assign(Object.assign({}, baseStyle), { height: height$ });
45
45
  }, [top$, layouted$, height$]);
46
+ const setInnerMeasureRef = useMemoizedFn((el) => {
47
+ const innerRef = refFlowItem;
48
+ innerRef.current = el !== null && el !== void 0 ? el : undefined;
49
+ node.attachMeasureElement(el);
50
+ });
46
51
  useEffect(() => {
47
52
  let observer;
48
- if (isWeb() && typeof ResizeObserver !== 'undefined') {
53
+ const el = refFlowItem.current;
54
+ if (isWeb() && typeof ResizeObserver !== 'undefined' && el) {
49
55
  observer = new ResizeObserver(() => {
50
56
  node.pub(NodeEvents.Resize);
51
57
  });
52
- observer.observe(refFlowItem.current);
58
+ observer.observe(el);
53
59
  }
54
60
  return () => {
55
61
  if (observer) {
56
62
  observer.disconnect();
57
63
  }
64
+ node.attachMeasureElement(null);
58
65
  };
59
66
  }, [node]);
60
67
  useLayoutEffect(() => {
61
- node.measure();
68
+ node.measure().catch(() => { });
62
69
  }, [node]);
63
- return createElement(View, { style: itemStyle, key: node.id }, createElement(View, { id: node.id, ref: refFlowItem }, createElement(FlowItemContext.Provider, { value: { node } }, children)));
70
+ return createElement(View, { style: itemStyle, key: node.id }, createElement(View, { id: node.id, ref: setInnerMeasureRef }, createElement(FlowItemContext.Provider, { value: { node } }, children)));
64
71
  }
65
72
  function FlowItem(props) {
66
73
  return props.children;
@@ -1 +1 @@
1
- {"version":3,"file":"flow-item.js","sources":["../../../src/components/water-flow/flow-item.ts"],"sourcesContent":["import { View } from '@tarojs/components'\nimport {\n type CSSProperties,\n type PropsWithChildren,\n createContext,\n createElement,\n useContext,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n} from 'react'\n\nimport { Node, NodeEvents } from './node'\nimport { useMemoizedFn } from './use-memoized-fn'\nimport { useObservedAttr } from './use-observed-attr'\nimport { isWeb } from './utils'\n\nimport type { FlowItemContainerProps } from './interface'\n\nconst FlowItemContext = createContext<{ node: Node }>(Object.create(null))\nexport const useFlowItemPositioner = () => {\n const nodeModel = useContext(FlowItemContext).node\n const width$ = useObservedAttr(nodeModel, 'width')\n const height$ = useObservedAttr(nodeModel, 'height')\n const top$ = useObservedAttr(nodeModel, 'top')\n const scrollTop$ = useObservedAttr(nodeModel, 'scrollTop')\n\n return {\n resize: useMemoizedFn(() => {\n if (!isWeb()) {\n nodeModel.pub(NodeEvents.Resize)\n }\n }),\n top: top$,\n scrollTop: scrollTop$,\n width: width$,\n height: height$,\n }\n}\n\nexport function FlowItemContainer({\n children,\n ...props\n}: PropsWithChildren<FlowItemContainerProps>) {\n const { node } = props\n const layouted$ = useObservedAttr(node, 'layouted')\n const top$ = useObservedAttr(node, 'top')\n const height$ = useObservedAttr(node, 'height')\n const refFlowItem = useRef<HTMLElement>()\n\n const itemStyle: CSSProperties = useMemo(() => {\n const baseStyle: CSSProperties = {\n width: '100%',\n minHeight: node.section.defaultSize,\n }\n if (!layouted$) {\n return baseStyle\n }\n Reflect.deleteProperty(baseStyle, 'minHeight')\n return {\n ...baseStyle,\n height: height$,\n transition: 'transform 20ms cubic-bezier(0.075, 0.82, 0.165, 1)',\n willChange: 'transform',\n position: 'absolute',\n top: 0,\n left: 0,\n transform: `translate3d(0px, ${top$}px, 0px)`,\n }\n }, [top$, layouted$, height$])\n\n useEffect(() => {\n let observer: ResizeObserver\n if (isWeb() && typeof ResizeObserver !== 'undefined') {\n observer = new ResizeObserver(() => {\n node.pub(NodeEvents.Resize)\n })\n observer.observe(refFlowItem.current!)\n }\n return () => {\n if (observer) {\n observer.disconnect()\n }\n }\n }, [node])\n\n useLayoutEffect(() => {\n node.measure()\n }, [node])\n\n return createElement(\n View,\n { style: itemStyle, key: node.id },\n createElement(\n View,\n { id: node.id, ref: refFlowItem },\n createElement(FlowItemContext.Provider, { value: { node } }, children)\n )\n )\n}\n\nexport function FlowItem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C,EAAE,EAAE,EAClC,aAAa,CACX,IAAI,EACJ,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,EACjC,aAAa,CAAC,eAAe,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,CAAC,CACvE,CACF;AACH;AAEM,SAAU,QAAQ,CAAC,KAAwB,EAAA;IAC/C,OAAO,KAAK,CAAC,QAAQ;AACvB;;;;"}
1
+ {"version":3,"file":"flow-item.js","sources":["../../../src/components/water-flow/flow-item.ts"],"sourcesContent":["import { View } from '@tarojs/components'\nimport {\n type CSSProperties,\n type PropsWithChildren,\n createContext,\n createElement,\n useContext,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n} from 'react'\n\nimport { Node, NodeEvents } from './node'\nimport { useMemoizedFn } from './use-memoized-fn'\nimport { useObservedAttr } from './use-observed-attr'\nimport { isWeb } from './utils'\n\nimport type { FlowItemContainerProps } from './interface'\n\nconst FlowItemContext = createContext<{ node: Node }>(Object.create(null))\nexport const useFlowItemPositioner = () => {\n const nodeModel = useContext(FlowItemContext).node\n const width$ = useObservedAttr(nodeModel, 'width')\n const height$ = useObservedAttr(nodeModel, 'height')\n const top$ = useObservedAttr(nodeModel, 'top')\n const scrollTop$ = useObservedAttr(nodeModel, 'scrollTop')\n\n return {\n resize: useMemoizedFn(() => {\n nodeModel.pub(NodeEvents.Resize)\n }),\n top: top$,\n scrollTop: scrollTop$,\n width: width$,\n height: height$,\n }\n}\n\nexport function FlowItemContainer({\n children,\n ...props\n}: PropsWithChildren<FlowItemContainerProps>) {\n const { node } = props\n const layouted$ = useObservedAttr(node, 'layouted')\n const top$ = useObservedAttr(node, 'top')\n const height$ = useObservedAttr(node, 'height')\n const refFlowItem = useRef<HTMLElement>()\n\n const itemStyle: CSSProperties = useMemo(() => {\n const baseStyle: CSSProperties = {\n width: '100%',\n position: 'absolute',\n top: 0,\n left: 0,\n transform: `translate3d(0px, ${top$}px, 0px)`,\n }\n if (!layouted$) {\n return {\n ...baseStyle,\n minHeight: node.section.defaultSize,\n }\n }\n return {\n ...baseStyle,\n height: height$,\n }\n }, [top$, layouted$, height$])\n\n const setInnerMeasureRef = useMemoizedFn((el: HTMLElement | null) => {\n const innerRef = refFlowItem as React.MutableRefObject<HTMLElement | undefined>\n innerRef.current = el ?? undefined\n node.attachMeasureElement(el)\n })\n\n useEffect(() => {\n let observer: ResizeObserver\n const el = refFlowItem.current\n if (isWeb() && typeof ResizeObserver !== 'undefined' && el) {\n observer = new ResizeObserver(() => {\n node.pub(NodeEvents.Resize)\n })\n observer.observe(el)\n }\n return () => {\n if (observer) {\n observer.disconnect()\n }\n node.attachMeasureElement(null)\n }\n }, [node])\n\n useLayoutEffect(() => {\n node.measure().catch(() => {})\n }, [node])\n\n return createElement(\n View,\n { style: itemStyle, key: node.id },\n createElement(\n View,\n { id: node.id, ref: setInnerMeasureRef as any },\n createElement(FlowItemContext.Provider, { value: { node } }, children)\n )\n )\n}\n\nexport function FlowItem(props: PropsWithChildren) {\n return props.children\n}\n"],"names":[],"mappings":";;;;;;;;AAoBA,MAAM,eAAe,GAAG,aAAa,CAAiB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACnE,MAAM,qBAAqB,GAAG,MAAK;IACxC,MAAM,SAAS,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC,IAAI;IAClD,MAAM,MAAM,GAAG,eAAe,CAAC,SAAS,EAAE,OAAO,CAAC;IAClD,MAAM,OAAO,GAAG,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAC;IACpD,MAAM,IAAI,GAAG,eAAe,CAAC,SAAS,EAAE,KAAK,CAAC;IAC9C,MAAM,UAAU,GAAG,eAAe,CAAC,SAAS,EAAE,WAAW,CAAC;IAE1D,OAAO;AACL,QAAA,MAAM,EAAE,aAAa,CAAC,MAAK;AACzB,YAAA,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM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EM,SAAU,QAAQ,CAAC,KAAwB,EAAA;IAC/C,OAAO,KAAK,CAAC,QAAQ;AACvB;;;;"}
@@ -58,7 +58,7 @@ function FlowSection(_a) {
58
58
  return createElement(FlowItemContainer, columnProps, childNode);
59
59
  }));
60
60
  });
61
- }, [children, layouted$, section.columnMap, renderRange$, id]);
61
+ }, [children, layouted$, section.columnMap, renderRange$]);
62
62
  return createElement(View, { style: sectionStyle, className, id: id !== null && id !== void 0 ? id : section.id }, columns);
63
63
  }
64
64
 
@@ -1 +1 @@
1
- {"version":3,"file":"flow-section.js","sources":["../../../src/components/water-flow/flow-section.ts"],"sourcesContent":["import { View } from '@tarojs/components'\nimport {\n type CSSProperties,\n type PropsWithChildren,\n Children,\n createElement,\n useMemo,\n} from 'react'\n\nimport { FlowItemContainer } from './flow-item'\nimport { Section } from './section'\nimport { useObservedAttr } from './use-observed-attr'\n\nimport type { FlowSectionProps } from './interface'\n\nexport interface _FlowSectionProps extends FlowSectionProps {\n section: Section\n}\n\nexport function FlowSection({\n children,\n ...props\n}: PropsWithChildren<FlowSectionProps>) {\n const {\n id,\n className,\n style,\n section,\n rowGap = 0,\n columnGap = 0,\n } = props as _FlowSectionProps\n const layouted$ = useObservedAttr(section, 'layouted')\n const height$ = useObservedAttr(section, 'height')\n const renderRange$ = useObservedAttr(section, 'renderRange')\n const scrollTop$ = useObservedAttr(section, 'scrollTop')\n\n const sectionStyle: CSSProperties = useMemo(() => {\n const baseStyle: CSSProperties = {\n display: 'flex',\n flexDirection: 'row',\n width: '100%',\n height: height$,\n gap: columnGap,\n visibility: layouted$ ? 'visible' : 'hidden',\n ...style,\n }\n\n if (!layouted$) {\n return baseStyle\n }\n\n return {\n ...baseStyle,\n position: 'absolute',\n top: 0,\n transform: `translate3d(0px, ${scrollTop$}px, 0px)`,\n left: 0,\n }\n }, [height$, style, layouted$, scrollTop$, columnGap])\n\n const columns = useMemo(() => {\n const childNodes = Children.toArray(children)\n const columnStyle: CSSProperties = {\n position: 'relative',\n display: 'flex',\n flexDirection: 'column',\n gap: rowGap,\n flex: 1,\n }\n /** 已经完成布局计算,使用虚拟滚动 */\n if (layouted$) {\n return renderRange$.map(([startIndex, endIndex], colIndex) => {\n const columnId = `col-${colIndex}`\n return createElement(\n View,\n {\n style: columnStyle,\n id: columnId,\n key: columnId,\n },\n section.columnMap[colIndex]\n .slice(startIndex, endIndex + 1)\n .map((node) => {\n const childNode = childNodes[node.childIndex]\n const columnProps: any = {\n node,\n key: node.id,\n }\n return createElement(FlowItemContainer, columnProps, childNode)\n })\n )\n })\n }\n\n return section.columnMap.map((column, colIndex) => {\n const columnId = `col-${colIndex}`\n return createElement(\n View,\n { style: columnStyle, id: columnId, key: columnId },\n column.map((node) => {\n const childNode = childNodes[node.childIndex]\n const columnProps: any = {\n node,\n key: node.id,\n }\n return createElement(FlowItemContainer, columnProps, childNode)\n })\n )\n })\n }, [children, layouted$, section.columnMap, renderRange$, id])\n\n return createElement(\n View,\n { style: sectionStyle, className, id: id ?? section.id },\n columns\n )\n}\n"],"names":[],"mappings":";;;;;;AAmBM,SAAU,WAAW,CAAC,EAGU,EAAA;AAHV,IAAA,IAAA,EAC1B,QAAQ,EAE4B,GAAA,EAAA,EADjC,KAAK,GAAA,MAAA,CAAA,EAAA,EAFkB,YAG3B,CADS;AAER,IAAA,MAAM,EACJ,EAAE,EACF,SAAS,EACT,KAAK,EACL,OAAO,EACP,MAAM,GAAG,CAAC,EACV,SAAS,GAAG,CAAC,GACd,GAAG,KAA0B;IAC9B,MAAM,SAAS,GAAG,eAAe,CAAC,OAAO,EAAE,UAAU,CAAC;IACtD,MAAM,OAAO,GAAG,eAAe,CAAC,OAAO,EAAE,QAAQ,CAAC;IAClD,MAAM,YAAY,GAAG,eAAe,CAAC,OAAO,EAAE,aAAa,CAAC;IAC5D,MAAM,UAAU,GAAG,eAAe,CAAC,OAAO,EAAE,WAAW,CAAC;AAExD,IAAA,MAAM,YAAY,GAAkB,OAAO,CAAC,MAAK;AAC/C,QAA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ACxD,OAAO,CACR;AACH;;;;"}
1
+ {"version":3,"file":"flow-section.js","sources":["../../../src/components/water-flow/flow-section.ts"],"sourcesContent":["import { View } from '@tarojs/components'\nimport {\n type CSSProperties,\n type PropsWithChildren,\n Children,\n createElement,\n useMemo,\n} from 'react'\n\nimport { FlowItemContainer } from './flow-item'\nimport { Section } from './section'\nimport { useObservedAttr } from './use-observed-attr'\n\nimport type { FlowSectionProps } from './interface'\n\nexport interface _FlowSectionProps extends FlowSectionProps {\n section: Section\n}\n\nexport function FlowSection({\n children,\n ...props\n}: PropsWithChildren<FlowSectionProps>) {\n const {\n id,\n className,\n style,\n section,\n rowGap = 0,\n columnGap = 0,\n } = props as _FlowSectionProps\n const layouted$ = useObservedAttr(section, 'layouted')\n const height$ = useObservedAttr(section, 'height')\n const renderRange$ = useObservedAttr(section, 'renderRange')\n const scrollTop$ = useObservedAttr(section, 'scrollTop')\n\n const sectionStyle: CSSProperties = useMemo(() => {\n const baseStyle: CSSProperties = {\n display: 'flex',\n flexDirection: 'row',\n width: '100%',\n height: height$,\n gap: columnGap,\n visibility: layouted$ ? 'visible' : 'hidden',\n ...style,\n }\n\n if (!layouted$) {\n return baseStyle\n }\n\n return {\n ...baseStyle,\n position: 'absolute',\n top: 0,\n transform: `translate3d(0px, ${scrollTop$}px, 0px)`,\n left: 0,\n }\n }, [height$, style, layouted$, scrollTop$, columnGap])\n\n const columns = useMemo(() => {\n const childNodes = Children.toArray(children)\n const columnStyle: CSSProperties = {\n position: 'relative',\n display: 'flex',\n flexDirection: 'column',\n gap: rowGap,\n flex: 1,\n }\n /** 已经完成布局计算,使用虚拟滚动 */\n if (layouted$) {\n return renderRange$.map(([startIndex, endIndex], colIndex) => {\n const columnId = `col-${colIndex}`\n return createElement(\n View,\n {\n style: columnStyle,\n id: columnId,\n key: columnId,\n },\n section.columnMap[colIndex]\n .slice(startIndex, endIndex + 1)\n .map((node) => {\n const childNode = childNodes[node.childIndex]\n const columnProps: any = {\n node,\n key: node.id,\n }\n return createElement(FlowItemContainer, columnProps, childNode)\n })\n )\n })\n }\n\n return section.columnMap.map((column, colIndex) => {\n const columnId = `col-${colIndex}`\n return createElement(\n View,\n { style: columnStyle, id: columnId, key: columnId },\n column.map((node) => {\n const childNode = childNodes[node.childIndex]\n const columnProps: any = {\n node,\n key: node.id,\n }\n return createElement(FlowItemContainer, columnProps, childNode)\n })\n )\n })\n }, [children, layouted$, section.columnMap, renderRange$])\n\n return createElement(\n View,\n { style: sectionStyle, className, id: id ?? section.id },\n columns\n )\n}\n"],"names":[],"mappings":";;;;;;AAmBM,SAAU,WAAW,CAAC,EAGU,EAAA;AAHV,IAAA,IAAA,EAC1B,QAAQ,EAE4B,GAAA,EAAA,EADjC,KAAK,GAAA,MAAA,CAAA,EAAA,EAFkB,YAG3B,CADS;AAER,IAAA,MAAM,EACJ,EAAE,EACF,SAAS,EACT,KAAK,EACL,OAAO,EACP,MAAM,GAAG,CAAC,EACV,SAAS,GAAG,CAAC,GACd,GAAG,KAA0B;IAC9B,MAAM,SAAS,GAAG,eAAe,CAAC,OAAO,EAAE,UAAU,CAAC;IACtD,MAAM,OAAO,GAAG,eAAe,CAAC,OAAO,EAAE,QAAQ,CAAC;IAClD,MAAM,YAAY,GAAG,eAAe,CAAC,OAAO,EAAE,aAAa,CAAC;IAC5D,MAAM,UAAU,GAAG,eAAe,CAAC,OAAO,EAAE,WAAW,CAAC;AAExD,IAAA,MAAM,YAAY,GAAkB,OAAO,CAAC,MAAK;AAC/C,QAAA,MAAM,SAAS,GACb,MAAA,CAAA,MAAA,CAAA,EAAA,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,KAAK,EACpB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,OAAO,EACf,GAAG,EAAE,SAAS,EACd,UAAU,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,EACzC,EAAA,KAAK,CACT;QAED,IAAI,CAAC,SAAS,EAAE;AACd,YAAA,OAAO,SAAS;;AAGlB,QAAA,OAAA,M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AAa,CAAC,iBAAiB,EAAE,WAAW,EAAE,SAAS,CAAC;iBAChE,CAAC,CACL;AACH,aAAC,CAAC;;QAGJ,OAAO,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,QAAQ,KAAI;AAChD,YAAA,MAAM,QAAQ,GAAG,CAAO,IAAA,EAAA,QAAQ,EAAE;YAClC,OAAO,aAAa,CAClB,IAAI,EACJ,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,EACnD,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,KAAI;gBAClB,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC;AAC7C,gBAAA,MAAM,WAAW,GAAQ;oBACvB,IAAI;oBACJ,GAAG,EAAE,IAAI,CAAC,EAAE;iBACb;gBACD,OAAO,aAAa,CAAC,iBAAiB,EAAE,WAAW,EAAE,SAAS,CAAC;aAChE,CAAC,CACH;AACH,SAAC,CAAC;AACJ,KAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IAE1D,OAAO,aAAa,CAClB,IAAI,EACJ,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,KAAF,IAAA,IAAA,EAAE,KAAF,KAAA,CAAA,GAAA,EAAE,GAAI,OAAO,CAAC,EAAE,EAAE,EACxD,OAAO,CACR;AACH;;;;"}
@@ -1,4 +1,4 @@
1
1
  export { FlowItem, useFlowItemPositioner } from './flow-item';
2
2
  export { FlowSection } from './flow-section';
3
- export type { FlowSectionProps, WaterFlowProps } from './interface';
3
+ export type { FlowSectionProps, WaterFlowProps, WaterFlowRef } from './interface';
4
4
  export { WaterFlow } from './water-flow';
@@ -1,12 +1,12 @@
1
1
  import { ScrollViewProps } from '@tarojs/components';
2
2
  import { Node } from './node';
3
- import type { CSSProperties } from 'react';
3
+ import type { CSSProperties, RefObject } from 'react';
4
4
  export interface BaseProps {
5
5
  id?: string;
6
6
  className?: string;
7
7
  style?: CSSProperties;
8
8
  }
9
- export interface WaterFlowProps extends Omit<ScrollViewProps, 'cacheExtent' | 'upperThreshold' | 'lowerThreshold' | 'style'>, Pick<BaseProps, 'style'> {
9
+ export interface WaterFlowProps extends Omit<ScrollViewProps, 'cacheExtent' | 'upperThreshold' | 'lowerThreshold' | 'style' | 'type'>, Pick<BaseProps, 'style'> {
10
10
  /**
11
11
  * 距顶部多少个FlowItem时,触发 scrolltoupper 事件
12
12
  * @default 0
@@ -22,6 +22,36 @@ export interface WaterFlowProps extends Omit<ScrollViewProps, 'cacheExtent' | 'u
22
22
  * @default 50
23
23
  */
24
24
  cacheCount?: number;
25
+ /**
26
+ * 滚动事件。与内部虚拟列表滚动处理链式调用,不会覆盖触底/分页逻辑。
27
+ * 仅 default 模式(自带 ScrollView)时生效。
28
+ */
29
+ onScroll?: ScrollViewProps['onScroll'];
30
+ /**
31
+ * 受控竖向滚动位置。仅传入有效 number 时下发给 ScrollView;
32
+ * undefined/null 表示取消受控(避免 H5 将 null 转为 0 导致归顶)。
33
+ */
34
+ scrollTop?: number;
35
+ /**
36
+ * 受控横向滚动位置,语义同 scrollTop。
37
+ */
38
+ scrollLeft?: number;
39
+ /** 是否嵌套模式,与 plato 对齐;true=使用父级滚动,需配合 scrollElement 或 Context;不传或 false=default */
40
+ nestedScroll?: boolean;
41
+ /** 自定义滚动容器 ref,nestedScroll 模式下从 props 或 Context 获取 */
42
+ scrollElement?: RefObject<HTMLElement | null>;
43
+ /** WaterFlow 内容在滚动容器中的起始偏移(上方有其他内容时使用) */
44
+ startOffset?: number;
45
+ /** 可视区高度,scrollElement 模式下可选,不传则从 scrollElement.clientHeight 获取 */
46
+ containerHeight?: number;
47
+ /** 瀑布流内容高度变化时回调,便于 List 动高联动(避免底部空白) */
48
+ onScrollHeightChange?: (height: number) => void;
49
+ /** scrollIntoView 滚动完成后回调,便于父组件清空 scrollIntoView 以支持重复点击同一目标 */
50
+ onScrollIntoViewComplete?: () => void;
51
+ }
52
+ /** WaterFlow ref 类型,current 指向内容容器,用于 IntersectionObserver root、SelectorQuery.in 等 */
53
+ export interface WaterFlowRef {
54
+ current: HTMLElement | null;
25
55
  }
26
56
  export interface FlowSectionProps extends BaseProps {
27
57
  /**
@@ -29,6 +29,8 @@ export declare const NodeEvents: {
29
29
  export declare class Node extends StatefulEventBus<NodeState> {
30
30
  root: Root;
31
31
  section: Section;
32
+ /** 小程序:测量用内层 View 的 DOM;H5:getBoundingClientRect 用 */
33
+ private _measureEl;
32
34
  id: string;
33
35
  /**
34
36
  * 原始索引,即一维数组中的索引
@@ -43,6 +45,7 @@ export declare class Node extends StatefulEventBus<NodeState> {
43
45
  */
44
46
  col: number;
45
47
  constructor(root: Root, section: Section, props: NodeProps);
48
+ attachMeasureElement(el: HTMLElement | null): void;
46
49
  private setupSubscriptions;
47
50
  /**
48
51
  * 测量节点的尺寸信息
@@ -1,6 +1,8 @@
1
1
  import '../../utils/index.js';
2
2
  import { SectionEvents } from './section.js';
3
3
  import { StatefulEventBus } from './stateful-event-bus.js';
4
+ import { isWeb, isWeapp } from './utils.js';
5
+ import { weappScope } from '../../utils/weapp-scope.js';
4
6
  import { getRectSizeSync } from '../../utils/dom.js';
5
7
 
6
8
  const NodeEvents = {
@@ -18,10 +20,15 @@ class Node extends StatefulEventBus {
18
20
  });
19
21
  this.root = root;
20
22
  this.section = section;
23
+ /** 小程序:测量用内层 View 的 DOM;H5:getBoundingClientRect 用 */
24
+ this._measureEl = null;
21
25
  const nodeId = `${root.id}-${section.id}-item-${childIndex}`;
22
26
  Object.assign(this, { id: nodeId, childIndex, order, col });
23
27
  this.setupSubscriptions();
24
28
  }
29
+ attachMeasureElement(el) {
30
+ this._measureEl = el;
31
+ }
25
32
  setupSubscriptions() {
26
33
  this.sub('layouted', () => {
27
34
  /**
@@ -56,7 +63,33 @@ class Node extends StatefulEventBus {
56
63
  * 测量节点的尺寸信息
57
64
  */
58
65
  async measure() {
59
- const { height, width } = await getRectSizeSync(`#${this.id}`, 100, 3);
66
+ let width;
67
+ let height;
68
+ if (isWeb() && this._measureEl) {
69
+ const r = this._measureEl.getBoundingClientRect();
70
+ width = r.width;
71
+ height = r.height;
72
+ }
73
+ else if (isWeapp && this._measureEl) {
74
+ const scope = weappScope({ current: this._measureEl });
75
+ const res = await getRectSizeSync(`#${this.id}`, 100, 3, scope);
76
+ width = res.width;
77
+ height = res.height;
78
+ }
79
+ else {
80
+ const res = await getRectSizeSync(`#${this.id}`, 100, 3);
81
+ width = res.width;
82
+ height = res.height;
83
+ }
84
+ if (typeof width !== 'number' ||
85
+ typeof height !== 'number' ||
86
+ !Number.isFinite(width) ||
87
+ !Number.isFinite(height) ||
88
+ width <= 0 ||
89
+ height <= 0) {
90
+ const s = this.getState();
91
+ return { width: s.width, height: s.height };
92
+ }
60
93
  this.setStateBatch({
61
94
  width,
62
95
  height,
@@ -1 +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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I,GAAG,aAAa,CAAC,KAAK,CAAC;YACjC,MAAM,YAAY,GAAG,aAAa,CAAC,KAAK,GAAG,CAAC,CAAC;AAC7C,YAAA,MAAM,EACJ,GAAG,EAAE,eAAe,EACpB,MAAM,EAAE,kBAAkB,EAC1B,SAAS,EAAE,qBAAqB,GACjC,GAAG,YAAY,CAAC,QAAQ,EAAE;AAC3B,YAAA,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM;YAClC,IAAI,CAAC,aAAa,CAAC;AACjB,gBAAA,GAAG,EAAE,eAAe,GAAG,kBAAkB,GAAG,MAAM;AAClD,gBAAA,SAAS,EAAE,qBAAqB,GAAG,kBAAkB,GAAG,MAAM;AAC/D,aAAA,CAAC;;;AAIN;;AAEG;AACH,IAAA,IAAI,SAAS,GAAA;QACX,MAAM,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAAC,IAAI;AAC5D,QAAA,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE;QACxE,QACE,aAAa,GAAG,iBAAiB;AACjC,YAAA,aAAa,GAAG,UAAU,GAAG,mBAAmB;;AAGrD;;;;"}
1
+ {"version":3,"file":"node.js","sources":["../../../src/components/water-flow/node.ts"],"sourcesContent":["import { getRectSizeSync, weappScope } from '../../utils'\nimport { Root } from './root'\nimport { Section, SectionEvents } from './section'\nimport { StatefulEventBus } from './stateful-event-bus'\nimport { isWeapp, isWeb } from './utils'\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 /** 小程序:测量用内层 View 的 DOM;H5:getBoundingClientRect 用 */\n private _measureEl: HTMLElement | null = null\n\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 attachMeasureElement (el: HTMLElement | null) {\n this._measureEl = el\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 let width: number | undefined\n let height: number | undefined\n if (isWeb() && this._measureEl) {\n const r = this._measureEl.getBoundingClientRect()\n width = r.width\n height = r.height\n } else if (isWeapp && this._measureEl) {\n const scope = weappScope({ current: this._measureEl as any })\n const res = await getRectSizeSync(`#${this.id}`, 100, 3, scope)\n width = res.width\n height = res.height\n } else {\n const res = await getRectSizeSync(`#${this.id}`, 100, 3)\n width = res.width\n height = res.height\n }\n if (\n typeof width !== 'number' ||\n typeof height !== 'number' ||\n !Number.isFinite(width) ||\n !Number.isFinite(height) ||\n width <= 0 ||\n height <= 0\n ) {\n const s = this.getState()\n return { width: s.width, height: s.height }\n }\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":";;;;;;;AA8Ba,MAAA,UAAU,GAAG;AACxB,IAAA,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;;AAGxB,MAAO,IAAK,SAAQ,gBAA2B,CAAA;AAiBnD,IAAA,WAAA,CAAmB,IAAU,EAAS,OAAgB,EAAE,KAAgB,EAAA;QACtE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,KAAK;AAChD,QAAA,KAAK,CAAC;AACJ,YAAA,GAAG,EAAE,CAAC;AACN,YAAA,KAAK,EAAE,CAAC;YACR,MAAM;AACN,YAAA,SAAS,EAAE,CAAC;AACZ,YAAA,QAAQ,EAAE,KAAK;AAChB,SAAA,CAAC;QARe,IAAI,CAAA,IAAA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EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC,QAAQ,EAAE;QACxE,QACE,aAAa,GAAG,iBAAiB;AACjC,YAAA,aAAa,GAAG,UAAU,GAAG,mBAAmB;;AAGrD;;;;"}
@@ -2,7 +2,10 @@ import { Node } from './node';
2
2
  import { Section } from './section';
3
3
  import { StatefulEventBus } from './stateful-event-bus';
4
4
  import type { BaseProps, ScrollDirection, Size, WaterFlowProps } from './interface';
5
- export type RootProps = Pick<WaterFlowProps, 'cacheCount' | 'lowerThresholdCount' | 'upperThresholdCount'> & Required<Pick<BaseProps, 'id'>>;
5
+ export type RootProps = Pick<WaterFlowProps, 'cacheCount' | 'lowerThresholdCount' | 'upperThresholdCount'> & Required<Pick<BaseProps, 'id'>> & {
6
+ /** scrollElement 模式下为 true,不测量自有容器;此时需布局全部 section 以展开完整高度 */
7
+ skipContainerMeasure?: boolean;
8
+ };
6
9
  type RootState = {
7
10
  /** 是否在滚动中 */
8
11
  isScrolling: boolean;
@@ -52,9 +55,17 @@ export declare class Root extends StatefulEventBus<RootState, Events> {
52
55
  */
53
56
  sections: Section[];
54
57
  /**
55
- * 设置预加载的 Item 条数。
58
+ * 设置预加载的 Item 条数(与 props.cacheCount 一致,收敛目标)。
56
59
  */
57
60
  cacheCount: number;
61
+ /**
62
+ * Node 层向上(列索引减小方向)预缓存条数,可与 cacheCount 不同(快速滑动单边放大)。
63
+ */
64
+ nodeCacheBackward: number;
65
+ /**
66
+ * Node 层向下(列索引增大方向)预缓存条数。
67
+ */
68
+ nodeCacheForward: number;
58
69
  upperThresholdCount: number;
59
70
  lowerThresholdCount: number;
60
71
  /**
@@ -65,7 +76,19 @@ export declare class Root extends StatefulEventBus<RootState, Events> {
65
76
  * 触发滚动阈值对应的 scrollTop 值
66
77
  */
67
78
  lowerThresholdScrollTop: number;
79
+ /** scrollElement 模式下为 true,需布局全部 section 以展开完整高度供父容器滚动 */
80
+ skipContainerMeasure: boolean;
81
+ /** 当前是否处于触顶区域;初始为 true(起始在顶部),只有从 false→true 时才触发事件 */
82
+ private _inUpperZone;
83
+ /** 当前是否处于触底区域;初始为 false */
84
+ private _inLowerZone;
85
+ /** scrollHeight 更新防抖(raf),减轻 pushNodes 后测量前后的高度跳变 */
86
+ private _scrollHeightRafId;
68
87
  constructor(props: RootProps);
88
+ /**
89
+ * 挂载后由 WaterFlow 调用:用当前根容器 DOM(与 #id 同节点或 ScrollView 外壳)测量 containerSize。
90
+ */
91
+ measureContainerSize(measureEl: HTMLElement | null): Promise<void>;
69
92
  /**
70
93
  * 设置订阅事件
71
94
  */
@@ -94,8 +117,15 @@ export declare class Root extends StatefulEventBus<RootState, Events> {
94
117
  /**
95
118
  * 处理滚动到阈值的情况
96
119
  * 检测当前滚动位置是否达到了上下阈值,并触发相应的事件
120
+ * scrollElement 模式:scrollOffset 为内容内偏移(scrollTop - startOffset),upper/lowerThresholdScrollTop 基于本组件内容计算,触顶/触底以本 WaterFlow 内容为基准
97
121
  */
98
122
  private handleReachThreshold;
123
+ /**
124
+ * 列表追加并完成 finalize 后调用:重置触底边沿状态(_inLowerZone),
125
+ * 使用户仍在底部时下一次滚动能再次触发 onScrollToLower,而不必先上滑再下滑。
126
+ * 不在此处同步调用 handleReachThreshold,避免仍在底部时立刻连发触底(与误触区分)。
127
+ */
128
+ resetLowerReachEdgeAfterContentChange(): void;
99
129
  /**
100
130
  * 容器的滚动上边界
101
131
  */
@@ -113,9 +143,10 @@ export declare class Root extends StatefulEventBus<RootState, Events> {
113
143
  */
114
144
  get sectionRange(): number[][];
115
145
  /**
116
- * 计算滚动高度
146
+ * 更新总滚动高度(各 Section 累计)。
147
+ * @param immediate true 时跳过 raf 防抖(如 finalizePushNodesStateIfNeeded),避免高度滞后引起跳动
117
148
  */
118
- updateScrollHeight(): void;
149
+ updateScrollHeight(immediate?: boolean): void;
119
150
  /**
120
151
  * 注册分组
121
152
  */
@@ -132,6 +163,10 @@ export declare class Root extends StatefulEventBus<RootState, Events> {
132
163
  * 查找节点
133
164
  */
134
165
  findNode(id: string): Node;
166
+ /**
167
+ * 设置 Node 层上下方向预缓存条数,并刷新可见分组内的列渲染区间。
168
+ */
169
+ setNodeCacheRange(backward: number, forward: number): void;
135
170
  /**
136
171
  * 获取分组渲染区间
137
172
  */