@@ -136,13 +136,19 @@ export default {
136
136
const items = this .items
137
137
const field = this .sizeField
138
138
const minItemSize = this .minItemSize
139
+ let computedMinSize = 10000
139
140
let accumulator = 0
140
141
let current
141
142
for (let i = 0 , l = items .length ; i < l; i++ ) {
142
143
current = items[i][field] || minItemSize
144
+ if (current < computedMinSize) {
145
+ computedMinSize = current
146
+ }
143
147
accumulator += current
144
148
sizes[i] = { accumulator, size: current }
145
149
}
150
+ // eslint-disable-next-line
151
+ this .$_computedMinItemSize = computedMinSize
146
152
return sizes
147
153
}
148
154
return []
@@ -175,6 +181,7 @@ export default {
175
181
this .$_views = new Map ()
176
182
this .$_unusedViews = new Map ()
177
183
this .$_scrollDirty = false
184
+ this .$_lastUpdateScrollPosition = 0
178
185
179
186
// In SSR mode, we also prerender the same number of item for the first render
180
187
// to avoir mismatch between server and client templates
@@ -245,7 +252,7 @@ export default {
245
252
this .$_scrollDirty = true
246
253
requestAnimationFrame (() => {
247
254
this .$_scrollDirty = false
248
- const { continuous } = this .updateVisibleItems (false )
255
+ const { continuous } = this .updateVisibleItems (false , true )
249
256
250
257
// It seems sometimes chrome doesn't fire scroll event :/
251
258
// When non continous scrolling is ending, we force a refresh
@@ -270,8 +277,9 @@ export default {
270
277
}
271
278
},
272
279
273
- updateVisibleItems (checkItem ) {
280
+ updateVisibleItems (checkItem , checkPositionDiff = false ) {
274
281
const itemSize = this .itemSize
282
+ const minItemSize = this .$_computedMinItemSize
275
283
const typeField = this .typeField
276
284
const keyField = this .simpleArray ? null : this .keyField
277
285
const items = this .items
@@ -291,6 +299,18 @@ export default {
291
299
totalSize = null
292
300
} else {
293
301
const scroll = this .getScroll ()
302
+
303
+ // Skip update if use hasn't scrolled enough
304
+ if (checkPositionDiff) {
305
+ let positionDiff = scroll .start - this .$_lastUpdateScrollPosition
306
+ if (positionDiff < 0 ) positionDiff = - positionDiff
307
+ if ((itemSize === null && positionDiff < minItemSize) || positionDiff < itemSize) {
308
+ return {
309
+ continuous: false ,
310
+ }
311
+ }
312
+ }
313
+
294
314
const buffer = this .buffer
295
315
scroll .start -= buffer
296
316
scroll .end += buffer
0 commit comments