Skip to content

Commit 8b2bd32

Browse files
author
Guillaume Chau
committed
New delayPreviousItems prop
1 parent 89dbd0d commit 8b2bd32

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/components/VirtualScroller.vue

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ export default {
134134
type: Boolean,
135135
default: false,
136136
},
137+
delayPreviousItems: {
138+
type: Boolean,
139+
default: false,
140+
},
137141
},
138142
139143
data () {
@@ -296,19 +300,23 @@ export default {
296300
) {
297301
this.keysEnabled = !(startIndex > this._endIndex || endIndex < this._startIndex)
298302
299-
// Add next items
300-
this.visibleItems = items.slice(this._startIndex, endIndex)
301303
this.itemContainerStyle = {
302304
height: containerHeight + 'px',
303305
}
304306
this.itemsStyle = {
305307
marginTop: offsetTop + 'px',
306308
}
307309
308-
// Remove previous items
309-
this.$nextTick(() => {
310+
if (this.delayPreviousItems) {
311+
// Add next items
312+
this.visibleItems = items.slice(this._startIndex, endIndex)
313+
// Remove previous items
314+
this.$nextTick(() => {
315+
this.visibleItems = items.slice(startIndex, endIndex)
316+
})
317+
} else {
310318
this.visibleItems = items.slice(startIndex, endIndex)
311-
})
319+
}
312320
313321
this.emitUpdate && this.$emit('update', startIndex, endIndex)
314322

0 commit comments

Comments
 (0)