Skip to content

Commit 291d8d8

Browse files
committed
Avoid offensive scroll cased by estimate paddingBottom.
1 parent de2d1b1 commit 291d8d8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,26 +212,26 @@
212212
}
213213

214214
delta.lastCalcIndex = Math.max(delta.lastCalcIndex, index)
215+
delta.lastCalcIndex = Math.min(delta.lastCalcIndex, delta.total - 1)
215216

216217
return offset
217218
},
218219

219220
// return a variable size (height) from a given index.
220221
getVarSize: function (index) {
221222
var cache = this.delta.varCache[index]
222-
return (cache && cache.size) || this.variable(index) || 0
223+
return (cache && cache.size) || this.variable(index) || this.size
223224
},
224225

225226
// return the paddingBottom when variable height base current zone.
226227
getVarPaddingBottom () {
227228
var delta = this.delta
228-
var rest = delta.total - delta.lastCalcIndex
229-
if (rest <= delta.keeps || delta.lastCalcIndex >= delta.total) {
229+
if (delta.total - delta.end <= delta.keeps || delta.lastCalcIndex === delta.total - 1) {
230230
return this.getVarOffset(delta.total) - this.getVarOffset(delta.end)
231231
} else {
232232
// if unreached last zone or uncalculate real behind offset
233233
// continue return the estimate paddingBottom avoid max calculate.
234-
return (delta.total - delta.lastCalcIndex) * (delta.averageSize || this.size)
234+
return (delta.total - delta.end) * (delta.averageSize || this.size)
235235
}
236236
},
237237

0 commit comments

Comments
 (0)