@@ -286,19 +286,37 @@ export default {
286
286
containerHeight = l * itemHeight
287
287
}
288
288
289
- this .keysEnabled = ! (startIndex > this ._endIndex || endIndex < this ._startIndex )
290
- this ._startIndex = startIndex
291
- this ._endIndex = endIndex
292
- this ._length = l
293
- this .visibleItems = items .slice (startIndex, endIndex)
294
- this .itemContainerStyle = {
295
- height: containerHeight + ' px' ,
296
- }
297
- this .itemsStyle = {
298
- marginTop: offsetTop + ' px' ,
299
- }
289
+ if (
290
+ this ._startIndex !== startIndex ||
291
+ this ._endIndex !== endIndex ||
292
+ this ._offsetTop !== offsetTop ||
293
+ this ._height !== containerHeight ||
294
+ this ._length !== l
295
+ ) {
296
+ this .keysEnabled = ! (startIndex > this ._endIndex || endIndex < this ._startIndex )
297
+
298
+ // Add next items
299
+ this .visibleItems = items .slice (this ._startIndex , endIndex)
300
+ this .itemContainerStyle = {
301
+ height: containerHeight + ' px' ,
302
+ }
303
+ this .itemsStyle = {
304
+ marginTop: offsetTop + ' px' ,
305
+ }
300
306
301
- this .emitUpdate && this .$emit (' update' , startIndex, endIndex)
307
+ // Remove previous items
308
+ this .$nextTick (() => {
309
+ this .visibleItems = items .slice (startIndex, endIndex)
310
+ })
311
+
312
+ this .emitUpdate && this .$emit (' update' , startIndex, endIndex)
313
+
314
+ this ._startIndex = startIndex
315
+ this ._endIndex = endIndex
316
+ this ._length = l
317
+ this ._offsetTop = offsetTop
318
+ this ._height = containerHeight
319
+ }
302
320
}
303
321
},
304
322
0 commit comments