File tree 1 file changed +7
-2
lines changed
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>(
130
130
setListSize ( list . current ! . clientHeight )
131
131
// get avg item size
132
132
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
+ //
133
138
let count = 0
134
139
let totalHeight = 0
135
140
const persistentIndices = new Set ( props . persistentIndices || [ ] )
136
141
let i = - 1
137
- for ( const el of listInner . current ! . children ) {
142
+ for ( const el of listInnerEl . children ) {
138
143
i ++
139
144
if ( persistentIndices . has ( visibleIndices [ i ] ) ) {
140
145
continue
141
146
}
142
147
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
144
149
count ++
145
150
}
146
151
setItemSize ( totalHeight / count )
You can’t perform that action at this time.
0 commit comments