({
collection,
persistedKeys,
scrollRef,
renderDropIndicator
}: CollectionRootProps)
| 90 | } |
| 91 | |
| 92 | function CollectionRoot({ |
| 93 | collection, |
| 94 | persistedKeys, |
| 95 | scrollRef, |
| 96 | renderDropIndicator |
| 97 | }: CollectionRootProps) { |
| 98 | let {layout, layoutOptions} = useContext(LayoutContext)!; |
| 99 | let layoutOptions2 = layout.useLayoutOptions?.(); |
| 100 | let state = useVirtualizerState({ |
| 101 | allowsWindowScrolling: true, |
| 102 | layout, |
| 103 | collection, |
| 104 | renderView: (type, item) => { |
| 105 | return item?.render?.(item); |
| 106 | }, |
| 107 | onVisibleRectChange(rect) { |
| 108 | let element = scrollRef?.current; |
| 109 | if (element) { |
| 110 | element.scrollLeft = rect.x; |
| 111 | element.scrollTop = rect.y; |
| 112 | } |
| 113 | }, |
| 114 | persistedKeys, |
| 115 | layoutOptions: useMemo(() => { |
| 116 | if (layoutOptions && layoutOptions2) { |
| 117 | return {...layoutOptions, ...layoutOptions2}; |
| 118 | } |
| 119 | return layoutOptions || layoutOptions2; |
| 120 | }, [layoutOptions, layoutOptions2]) |
| 121 | }); |
| 122 | |
| 123 | let {contentProps} = useScrollView( |
| 124 | { |
| 125 | onVisibleRectChange: state.setVisibleRect, |
| 126 | onSizeChange: state.setSize, |
| 127 | contentSize: state.contentSize, |
| 128 | onScrollStart: state.startScrolling, |
| 129 | onScrollEnd: state.endScrolling, |
| 130 | allowsWindowScrolling: true |
| 131 | }, |
| 132 | scrollRef! |
| 133 | ); |
| 134 | |
| 135 | return ( |
| 136 | <div {...contentProps}> |
| 137 | <VirtualizerContext.Provider value={state}> |
| 138 | {renderChildren(null, state.visibleViews, renderDropIndicator)} |
| 139 | </VirtualizerContext.Provider> |
| 140 | </div> |
| 141 | ); |
| 142 | } |
| 143 | |
| 144 | function CollectionBranch({parent, renderDropIndicator}: CollectionBranchProps) { |
| 145 | let virtualizer = useContext(VirtualizerContext); |
nothing calls this directly
no test coverage detected