Skip to content

Commit dcf44bc

Browse files
committed
fix: ignore display none or position absolute fixed when compute avg item size
1 parent 0dfcd09 commit dcf44bc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/VirtualList.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ export const VirtualList = forwardRef(function <ITEM>(
149149
continue
150150
}
151151
const style = getComputedStyle(el)
152+
if (style.display === 'none') {
153+
continue
154+
}
155+
if (style.position !== 'static' && style.position !== 'relative') {
156+
continue
157+
}
152158
totalHeight += (el as HTMLElement).offsetHeight + parseFloat(style.marginTop) + parseFloat(style.marginBottom) + gap
153159
count++
154160
}

0 commit comments

Comments
 (0)