Skip to content

Commit 1a687dc

Browse files
authored
Fix remove useless "lastCalcIndex" judgment (#407)
1 parent afa413d commit 1a687dc

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

src/virtual.js

+1-12
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export default class Virtual {
2727
this.sizes = new Map()
2828
this.firstRangeTotalSize = 0
2929
this.firstRangeAverageSize = 0
30-
this.lastCalcIndex = 0
3130
this.fixedSizeValue = 0
3231
this.calcType = CALC_TYPE.INIT
3332

@@ -226,10 +225,6 @@ export default class Virtual {
226225
offset = offset + (typeof indexSize === 'number' ? indexSize : this.getEstimateSize())
227226
}
228227

229-
// remember last calculate index
230-
this.lastCalcIndex = Math.max(this.lastCalcIndex, givenIndex - 1)
231-
this.lastCalcIndex = Math.min(this.lastCalcIndex, this.getLastIndex())
232-
233228
return offset
234229
}
235230

@@ -297,13 +292,7 @@ export default class Virtual {
297292
return (lastIndex - end) * this.fixedSizeValue
298293
}
299294

300-
// if it's all calculated, return the exactly offset
301-
if (this.lastCalcIndex === lastIndex) {
302-
return this.getIndexOffset(lastIndex) - this.getIndexOffset(end)
303-
} else {
304-
// if not, use a estimated value
305-
return (lastIndex - end) * this.getEstimateSize()
306-
}
295+
return (lastIndex - end) * this.getEstimateSize()
307296
}
308297

309298
// get the item estimate size

0 commit comments

Comments
 (0)