Skip to content

Commit fc10cce

Browse files
committed
Extract getVarPaddingTop from filter.
1 parent 139f445 commit fc10cce

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

index.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,16 @@
203203
return (cache && cache.size) || this.variable(index) || 0
204204
},
205205

206+
// return the variable paddingTop base current zone.
207+
// @todo: if set a large `start` before variable was calculated,
208+
// here will also case too much offset calculate when list is very large,
209+
// consider use estimate paddingTop in this case just like `getVarPaddingBottom`.
210+
getVarPaddingTop: function () {
211+
return this.getVarOffset(this.delta.start)
212+
},
213+
206214
// return the variable paddingBottom base current zone.
207-
getVarPaddingBottom () {
215+
getVarPaddingBottom: function () {
208216
var delta = this.delta
209217
if (delta.total - delta.end <= delta.keeps || delta.varLastCalcIndex === delta.total - 1) {
210218
return this.getVarOffset(delta.total) - this.getVarOffset(delta.end)
@@ -235,7 +243,7 @@
235243
}
236244
},
237245

238-
// return the right zone info base on start/index.
246+
// return the right zone info base on `start/index`.
239247
getZone (index) {
240248
var start, end
241249
var delta = this.delta
@@ -265,7 +273,7 @@
265273
this.$refs.vsl.scrollTop = scrollTop
266274
},
267275

268-
// filter the shown items base on start and end.
276+
// filter the shown items base on `start` and `end`.
269277
filter: function () {
270278
var delta = this.delta
271279
var slots = this.$slots.default
@@ -281,7 +289,7 @@
281289
var hasPadding = slots.length > delta.keeps
282290

283291
if (this.variable) {
284-
paddingTop = hasPadding ? this.getVarOffset(delta.start) : 0
292+
paddingTop = hasPadding ? this.getVarPaddingTop() : 0
285293
paddingBottom = hasPadding ? this.getVarPaddingBottom() : 0
286294
} else {
287295
paddingTop = this.size * (hasPadding ? delta.start : 0)

0 commit comments

Comments
 (0)