File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -130,17 +130,22 @@ export const VirtualList = forwardRef(function <ITEM>(
130130 setListSize ( list . current ! . clientHeight )
131131 // get avg item size
132132 if ( props . itemSize == null ) {
133+ // get gap
134+ const listInnerEl = listInner . current as HTMLElement
135+ let gap = parseFloat ( getComputedStyle ( listInnerEl ) . rowGap )
136+ gap = isNaN ( gap ) ? 0 : gap
137+ //
133138 let count = 0
134139 let totalHeight = 0
135140 const persistentIndices = new Set ( props . persistentIndices || [ ] )
136141 let i = - 1
137- for ( const el of listInner . current ! . children ) {
142+ for ( const el of listInnerEl . children ) {
138143 i ++
139144 if ( persistentIndices . has ( visibleIndices [ i ] ) ) {
140145 continue
141146 }
142147 const style = getComputedStyle ( el )
143- totalHeight += ( el as HTMLElement ) . offsetHeight + parseFloat ( style . marginTop ) + parseFloat ( style . marginBottom )
148+ totalHeight += ( el as HTMLElement ) . offsetHeight + parseFloat ( style . marginTop ) + parseFloat ( style . marginBottom ) + gap
144149 count ++
145150 }
146151 setItemSize ( totalHeight / count )
You can’t perform that action at this time.
0 commit comments