Skip to content

Commit

Permalink
fix: ignore display none or position absolute fixed when compute avg …
Browse files Browse the repository at this point in the history
…item size
  • Loading branch information
phphe committed Mar 7, 2024
1 parent 0dfcd09 commit dcf44bc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/VirtualList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ export const VirtualList = forwardRef(function <ITEM>(
continue
}
const style = getComputedStyle(el)
if (style.display === 'none') {
continue
}
if (style.position !== 'static' && style.position !== 'relative') {
continue
}
totalHeight += (el as HTMLElement).offsetHeight + parseFloat(style.marginTop) + parseFloat(style.marginBottom) + gap
count++
}
Expand Down

0 comments on commit dcf44bc

Please sign in to comment.