Skip to content

Commit dbd4bf7

Browse files
punkt2tangbc
authored andcommitted
Calculate correct average size
firstRangeAverageSize is calculated wrong when the first items of the first range have the same size and the following a different size.
1 parent b9fa428 commit dbd4bf7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/virtual.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export default class Virtual {
106106
// calculate the average size only in the first range
107107
if (this.calcType !== CALC_TYPE.FIXED && typeof this.firstRangeTotalSize !== 'undefined') {
108108
if (this.sizes.size < Math.min(this.param.keeps, this.param.uniqueIds.length)) {
109-
this.firstRangeTotalSize = this.firstRangeTotalSize + size
109+
this.firstRangeTotalSize = [...this.sizes.values()].reduce((acc, val) => acc + val, 0)
110110
this.firstRangeAverageSize = Math.round(this.firstRangeTotalSize / this.sizes.size)
111111
} else {
112112
// it's done using

0 commit comments

Comments
 (0)