MCPcopy Create free account
hub / github.com/adobe/react-spectrum / buildLoader

Method buildLoader

packages/@react-spectrum/ai/src/ListLayout.ts:689–711  ·  view source on GitHub ↗
(node: Node<T>, x: number, y: number)

Source from the content-addressed store, hash-verified

687 }
688
689 protected buildLoader(node: Node<T>, x: number, y: number): LayoutNode {
690 let rect = new Rect(x, y, this.padding, 0);
691 let layoutInfo = new LayoutInfo(node.type, node.key, rect);
692
693 // Note that if the user provides isLoading to their sentinel during a case where they only want to render the emptyState, this will reserve
694 // room for the loader alongside rendering the emptyState
695 if (this.orientation === 'horizontal') {
696 rect.height = this.virtualizer!.contentSize.height - this.padding - y;
697 rect.width = node.props.isLoading
698 ? (this.loaderSize ?? this.rowSize ?? this.estimatedRowSize ?? DEFAULT_HEIGHT)
699 : 0;
700 } else {
701 rect.width = this.virtualizer!.contentSize.width - this.padding - x;
702 rect.height = node.props.isLoading
703 ? (this.loaderSize ?? this.rowSize ?? this.estimatedRowSize ?? DEFAULT_HEIGHT)
704 : 0;
705 }
706
707 return {
708 layoutInfo,
709 validRect: rect.intersection(this.requestedRect)
710 };
711 }
712
713 protected buildSection(node: Node<T>, x: number, y: number): LayoutNode {
714 if (this.anchorTo === 'end' && this.orientation === 'vertical') {

Callers 1

buildNodeMethod · 0.95

Calls 1

intersectionMethod · 0.95

Tested by

no test coverage detected