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

Method buildLoader

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

Source from the content-addressed store, hash-verified

711 }
712
713 protected buildLoader(node: Node<T>, x: number, y: number): LayoutNode {
714 let rect = new Rect(x, y, this.padding, 0);
715 let layoutInfo = new LayoutInfo(node.type, node.key, rect);
716
717 // Note that if the user provides isLoading to their sentinel during a case where they only want to render the emptyState, this will reserve
718 // room for the loader alongside rendering the emptyState
719 if (this.orientation === 'horizontal') {
720 rect.height = this.virtualizer!.contentSize.height - this.padding - y;
721 rect.width = node.props.isLoading
722 ? (this.loaderSize ?? this.rowSize ?? this.estimatedRowSize ?? DEFAULT_HEIGHT)
723 : 0;
724 } else {
725 rect.width = this.virtualizer!.contentSize.width - this.padding - x;
726 rect.height = node.props.isLoading
727 ? (this.loaderSize ?? this.rowSize ?? this.estimatedRowSize ?? DEFAULT_HEIGHT)
728 : 0;
729 }
730
731 return {
732 layoutInfo,
733 validRect: rect.intersection(this.requestedRect)
734 };
735 }
736
737 protected buildSection(node: Node<T>, x: number, y: number): LayoutNode {
738 if (this.anchorTo === 'end' && this.orientation === 'vertical') {

Callers 1

buildNodeMethod · 0.95

Calls 1

intersectionMethod · 0.95

Tested by

no test coverage detected