File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ export interface ListboxVirtualizerProps<T extends AcceptableValue = AcceptableV
55 /** Number of items rendered outside the visible area */
66 overscan? : number
77 /** Estimated size (in px) of each item */
8- estimateSize? : number
8+ estimateSize? : number | (( index : number ) => number )
99 /** Text content for each item to achieve type-ahead feature */
1010 textContent? : (option : T ) => string
1111}
@@ -64,7 +64,10 @@ const virtualizer = useVirtualizer(
6464 get scrollPaddingEnd() { return padding .value .end },
6565 get count() { return props .options .length },
6666 get horizontal() { return rootContext .orientation .value === ' horizontal' },
67- estimateSize() {
67+ estimateSize(index ) {
68+ if (typeof props .estimateSize === ' function' )
69+ return props .estimateSize (index )
70+
6871 return props .estimateSize ?? 28
6972 },
7073 getScrollElement() { return parentEl .value },
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ export interface TreeVirtualizerProps {
33 /** Number of items rendered outside the visible area */
44 overscan? : number
55 /** Estimated size (in px) of each item */
6- estimateSize? : number
6+ estimateSize? : number | (( index : number ) => number )
77 /** Text content for each item to achieve type-ahead feature */
88 textContent? : (item : Record <string , any >) => string
99}
@@ -79,7 +79,10 @@ const virtualizer = useVirtualizer(
7979 getItemKey(index ) {
8080 return index + rootContext .getKey (rootContext .expandedItems .value [index ].value )
8181 },
82- estimateSize() {
82+ estimateSize(index ) {
83+ if (typeof props .estimateSize === ' function' )
84+ return props .estimateSize (index )
85+
8386 return props .estimateSize ?? 28
8487 },
8588 getScrollElement() { return parentEl .value },
You can’t perform that action at this time.
0 commit comments