From 227aa2835581759f74d7c8ac613c32d2b9382089 Mon Sep 17 00:00:00 2001 From: hope <1962926166@qq.com> Date: Sat, 20 May 2023 10:00:56 +0800 Subject: [PATCH] Fix remove useless "lastCalcIndex" judgment --- src/virtual.js | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/virtual.js b/src/virtual.js index 2435cb0..3dab124 100644 --- a/src/virtual.js +++ b/src/virtual.js @@ -27,7 +27,6 @@ export default class Virtual { this.sizes = new Map() this.firstRangeTotalSize = 0 this.firstRangeAverageSize = 0 - this.lastCalcIndex = 0 this.fixedSizeValue = 0 this.calcType = CALC_TYPE.INIT @@ -226,10 +225,6 @@ export default class Virtual { offset = offset + (typeof indexSize === 'number' ? indexSize : this.getEstimateSize()) } - // remember last calculate index - this.lastCalcIndex = Math.max(this.lastCalcIndex, givenIndex - 1) - this.lastCalcIndex = Math.min(this.lastCalcIndex, this.getLastIndex()) - return offset } @@ -297,13 +292,7 @@ export default class Virtual { return (lastIndex - end) * this.fixedSizeValue } - // if it's all calculated, return the exactly offset - if (this.lastCalcIndex === lastIndex) { - return this.getIndexOffset(lastIndex) - this.getIndexOffset(end) - } else { - // if not, use a estimated value - return (lastIndex - end) * this.getEstimateSize() - } + return (lastIndex - end) * this.getEstimateSize() } // get the item estimate size