| 828 | } |
| 829 | |
| 830 | protected buildItem(node: Node<T>, x: number, y: number): LayoutNode { |
| 831 | let widthProperty = this.orientation === 'horizontal' ? 'height' : 'width'; |
| 832 | let heightProperty = this.orientation === 'horizontal' ? 'width' : 'height'; |
| 833 | |
| 834 | let width = |
| 835 | this.virtualizer!.size[widthProperty] - |
| 836 | this.padding - |
| 837 | (this.orientation === 'horizontal' ? y : x); |
| 838 | let rectHeight = this.rowSize; |
| 839 | let isEstimated = false; |
| 840 | |
| 841 | // If no explicit height is available, use an estimated height. |
| 842 | if (rectHeight == null) { |
| 843 | // If a previous version of this layout info exists, reuse its height. |
| 844 | // Mark as estimated if the size of the overall virtualizer changed, |
| 845 | // or the content of the item changed. |
| 846 | let previousLayoutNode = this.layoutNodes.get(node.key); |
| 847 | if (previousLayoutNode) { |
| 848 | rectHeight = previousLayoutNode.layoutInfo.rect[heightProperty]; |
| 849 | isEstimated = |
| 850 | width !== previousLayoutNode.layoutInfo.rect[widthProperty] || |
| 851 | node !== previousLayoutNode.node || |
| 852 | previousLayoutNode.layoutInfo.estimatedSize; |
| 853 | } else { |
| 854 | rectHeight = this.estimatedRowSize; |
| 855 | isEstimated = true; |
| 856 | } |
| 857 | } |
| 858 | |
| 859 | if (rectHeight == null) { |
| 860 | rectHeight = DEFAULT_HEIGHT; |
| 861 | } |
| 862 | |
| 863 | let rect = |
| 864 | this.orientation === 'horizontal' |
| 865 | ? new Rect(x, y, rectHeight, width) |
| 866 | : new Rect(x, y, width, rectHeight); |
| 867 | let layoutInfo = new LayoutInfo(node.type, node.key, rect); |
| 868 | layoutInfo.estimatedSize = isEstimated; |
| 869 | return { |
| 870 | layoutInfo, |
| 871 | children: [], |
| 872 | validRect: layoutInfo.rect.intersection(this.requestedRect), |
| 873 | node |
| 874 | }; |
| 875 | } |
| 876 | |
| 877 | updateItemSize(key: Key, size: Size): boolean { |
| 878 | let layoutNode = this.layoutNodes.get(key); |