From fc9aaf5d50e74cf3c0195b97f441fc88f132f55b Mon Sep 17 00:00:00 2001 From: Sven Martinov Date: Wed, 18 Nov 2020 22:38:18 +0100 Subject: [PATCH] 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. --- src/virtual.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/virtual.js b/src/virtual.js index f1c16ab..d86a125 100644 --- a/src/virtual.js +++ b/src/virtual.js @@ -106,7 +106,7 @@ export default class Virtual { // calculate the average size only in the first range if (this.calcType !== CALC_TYPE.FIXED && typeof this.firstRangeTotalSize !== 'undefined') { if (this.sizes.size < Math.min(this.param.keeps, this.param.uniqueIds.length)) { - this.firstRangeTotalSize = this.firstRangeTotalSize + size + this.firstRangeTotalSize = [...this.sizes.values()].reduce((acc, val) => acc + val, 0) this.firstRangeAverageSize = Math.round(this.firstRangeTotalSize / this.sizes.size) } else { // it's done using